Package org.openstreetmap.josm.data.gpx
Class GpxExtension
- java.lang.Object
-
- org.openstreetmap.josm.data.gpx.WithAttributes
-
- org.openstreetmap.josm.data.gpx.GpxExtension
-
- All Implemented Interfaces:
GpxConstants,IWithAttributes
public class GpxExtension extends WithAttributes
A GpxExtension that has attributes and child extensions (implementsIWithAttributesandGpxConstants).- Since:
- 15496
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.data.gpx.GpxConstants
GpxConstants.ColorFormat
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringkeyprivate IWithAttributesparentprivate java.lang.Stringprefixprivate java.lang.StringqualifiedNameprivate java.lang.Stringvalueprivate booleanvisible-
Fields inherited from class org.openstreetmap.josm.data.gpx.WithAttributes
attr
-
Fields inherited from interface org.openstreetmap.josm.data.gpx.GpxConstants
EXTENSION_ABBREVIATIONS, FIX_VALUES, GARMIN_COLORS, GPX_CMT, GPX_DESC, GPX_NAME, GPX_PREFIX, GPX_SRC, JOSM_CREATOR_NAME, META_AUTHOR_EMAIL, META_AUTHOR_LINK, META_AUTHOR_NAME, META_BOUNDS, META_COPYRIGHT_AUTHOR, META_COPYRIGHT_LICENSE, META_COPYRIGHT_YEAR, META_DESC, META_KEYWORDS, META_LINKS, META_NAME, META_PREFIX, META_TIME, PT_AGEOFDGPSDATA, PT_COURSE, PT_DGPSID, PT_ELE, PT_FIX, PT_GEOIDHEIGHT, PT_HDOP, PT_MAGVAR, PT_PDOP, PT_SAT, PT_STD_HDEV, PT_STD_VDEV, PT_SYM, PT_TIME, PT_TYPE, PT_VDOP, RTE_TRK_KEYS, RTKLIB_AGE, RTKLIB_Q, RTKLIB_RATIO, RTKLIB_SDE, RTKLIB_SDEU, RTKLIB_SDN, RTKLIB_SDNE, RTKLIB_SDU, RTKLIB_SDUN, WPT_KEYS, XML_URI_EXTENSIONS_DRAWING, XML_URI_EXTENSIONS_GARMIN, XML_URI_EXTENSIONS_JOSM, XML_URI_XSD, XML_XSD_EXTENSIONS_DRAWING, XML_XSD_EXTENSIONS_GARMIN, XML_XSD_EXTENSIONS_JOSM
-
-
Constructor Summary
Constructors Constructor Description GpxExtension(java.lang.String prefix, java.lang.String key, java.lang.String value)Constructs a newGpxExtension.GpxExtension(java.lang.String namespaceURI, java.lang.String qName, org.xml.sax.Attributes atts)Creates a newGpxExtension
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)GpxExtensionfindExtension(java.lang.String sPrefix, java.lang.String sKey)Searches recursively for the extension with the given key in all childrenstatic GpxData.XMLNamespacefindNamespace(java.lang.String prefix)Finds the namespace for the given default prefix, if supported with schema locationstatic java.lang.StringfindPrefix(java.lang.String namespaceURI)Finds the default prefix used by JOSM for the given namespaceURI as the document is free specify another one.java.lang.StringgetFlatKey()Returns the flattened extension key of this extension.java.lang.StringgetKey()Returns the key (local element name) of the extension.IWithAttributesgetParent()Returns the parent element of this extension.java.lang.StringgetPrefix()Returns the prefix of the XML namespace.java.lang.StringgetQualifiedName()Returns the qualified name of the XML element.java.lang.StringgetValue()Returns the value of the extension.inthashCode()voidhide()Hides this extension and all then-empty parents so it isn't writtenbooleanisVisible()Determines if this extension should be written.voidremove()Removes this extension from its parent and all then-empty parentsvoidsetParent(IWithAttributes parent)Sets the parent for this extensionvoidsetValue(java.lang.String value)Sets the value.voidshow()Shows this extension and all parents so it can be written-
Methods inherited from class org.openstreetmap.josm.data.gpx.WithAttributes
get, getAttributes, getCollection, getExtensions, getString, hasExtensions, put
-
-
-
-
Field Detail
-
qualifiedName
private final java.lang.String qualifiedName
-
prefix
private final java.lang.String prefix
-
key
private final java.lang.String key
-
parent
private IWithAttributes parent
-
value
private java.lang.String value
-
visible
private boolean visible
-
-
Constructor Detail
-
GpxExtension
public GpxExtension(java.lang.String prefix, java.lang.String key, java.lang.String value)
Constructs a newGpxExtension.- Parameters:
prefix- the prefixkey- the keyvalue- the value
-
GpxExtension
public GpxExtension(java.lang.String namespaceURI, java.lang.String qName, org.xml.sax.Attributes atts)
Creates a newGpxExtension- Parameters:
namespaceURI- the URI of the XML namespace, used to determine supported extensions (josm, gpxx, gpxd) regardless of the prefix that could legally vary from file to file.qName- the qualified name of the XML element including prefixatts- the attributes
-
-
Method Detail
-
findPrefix
public static java.lang.String findPrefix(java.lang.String namespaceURI)
Finds the default prefix used by JOSM for the given namespaceURI as the document is free specify another one.- Parameters:
namespaceURI- namespace URI- Returns:
- the prefix
-
findNamespace
public static GpxData.XMLNamespace findNamespace(java.lang.String prefix)
Finds the namespace for the given default prefix, if supported with schema location- Parameters:
prefix- the prefix used by JOSM- Returns:
- the
GpxData.XMLNamespaceelement, location and URI can benullif not found.
-
getQualifiedName
public java.lang.String getQualifiedName()
Returns the qualified name of the XML element.- Returns:
- the qualified name of the XML element
-
getPrefix
public java.lang.String getPrefix()
Returns the prefix of the XML namespace.- Returns:
- the prefix of the XML namespace
-
getKey
public java.lang.String getKey()
Returns the key (local element name) of the extension.- Returns:
- the key (local element name) of the extension
-
getFlatKey
public java.lang.String getFlatKey()
Returns the flattened extension key of this extension.- Returns:
- the flattened extension key of this extension, used for conversion to OSM layers
-
findExtension
public GpxExtension findExtension(java.lang.String sPrefix, java.lang.String sKey)
Searches recursively for the extension with the given key in all children- Parameters:
sPrefix- the prefix to look forsKey- the key to look for- Returns:
- the extension if found, otherwise
null
-
getValue
public java.lang.String getValue()
Returns the value of the extension.- Returns:
- the value of the extension
-
setValue
public void setValue(java.lang.String value)
Sets the value.- Parameters:
value- the value to set
-
remove
public void remove()
Removes this extension from its parent and all then-empty parents- Throws:
java.lang.IllegalStateException- if parent not set
-
hide
public void hide()
Hides this extension and all then-empty parents so it isn't written- See Also:
isVisible()
-
show
public void show()
Shows this extension and all parents so it can be written- See Also:
isVisible()
-
isVisible
public boolean isVisible()
Determines if this extension should be written.- Returns:
- if this extension should be written, used for hiding colors during export without removing them
-
getParent
public IWithAttributes getParent()
Returns the parent element of this extension.- Returns:
- the parent element of this extension, can be another extension or gpx elements (data, track, segment, ...)
-
setParent
public void setParent(IWithAttributes parent)
Sets the parent for this extension- Parameters:
parent- the parent- Throws:
java.lang.IllegalStateException- if parent already set
-
hashCode
public int hashCode()
- Overrides:
hashCodein classWithAttributes
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classWithAttributes
-
-