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 (implementsIWithAttributes
andGpxConstants
).- 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 String
key
private IWithAttributes
parent
private String
prefix
private String
qualifiedName
private String
value
private boolean
visible
-
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_DGPSID, PT_ELE, PT_FIX, PT_GEOIDHEIGHT, PT_HDOP, PT_MAGVAR, PT_PDOP, PT_SAT, 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(String prefix, String key, String value)
Constructs a newGpxExtension
.GpxExtension(String namespaceURI, String qName, Attributes atts)
Creates a newGpxExtension
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
GpxExtension
findExtension(String sPrefix, String sKey)
Searches recursively for the extension with the given key in all childrenstatic GpxData.XMLNamespace
findNamespace(String prefix)
Finds the namespace for the given default prefix, if supported with schema locationstatic String
findPrefix(String namespaceURI)
Finds the default prefix used by JOSM for the given namespaceURI as the document is free specify another one.String
getFlatKey()
Returns the flattened extension key of this extension.String
getKey()
Returns the key (local element name) of the extension.IWithAttributes
getParent()
Returns the parent element of this extension.String
getPrefix()
Returns the prefix of the XML namespace.String
getQualifiedName()
Returns the qualified name of the XML element.String
getValue()
Returns the value of the extension.int
hashCode()
void
hide()
Hides this extension and all then-empty parents so it isn't writtenboolean
isVisible()
Determines if this extension should be written.void
remove()
Removes this extension from its parent and all then-empty parentsvoid
setParent(IWithAttributes parent)
Sets the parent for this extensionvoid
setValue(String value)
Sets the value.void
show()
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
-
-
-
-
Constructor Detail
-
GpxExtension
public GpxExtension(String prefix, String key, String value)
Constructs a newGpxExtension
.- Parameters:
prefix
- the prefixkey
- the keyvalue
- the value
-
GpxExtension
public GpxExtension(String namespaceURI, String qName, 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 String findPrefix(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(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.XMLNamespace
element, location and URI can benull
if not found.
-
getQualifiedName
public String getQualifiedName()
Returns the qualified name of the XML element.- Returns:
- the qualified name of the XML element
-
getPrefix
public String getPrefix()
Returns the prefix of the XML namespace.- Returns:
- the prefix of the XML namespace
-
getKey
public String getKey()
Returns the key (local element name) of the extension.- Returns:
- the key (local element name) of the extension
-
getFlatKey
public 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(String sPrefix, 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 String getValue()
Returns the value of the extension.- Returns:
- the value of the extension
-
remove
public void remove()
Removes this extension from its parent and all then-empty parents- Throws:
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:
IllegalStateException
- if parent already set
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classWithAttributes
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classWithAttributes
-
-