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 (implements IWithAttributes and GpxConstants).
Since:
15496
  • Field Details

  • Constructor Details

    • GpxExtension

      public GpxExtension(String prefix, String key, String value)
      Constructs a new GpxExtension.
      Parameters:
      prefix - the prefix
      key - the key
      value - the value
    • GpxExtension

      public GpxExtension(String namespaceURI, String qName, Attributes atts)
      Creates a new GpxExtension
      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 prefix
      atts - the attributes
  • Method Details

    • 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 be null if not found.
    • 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 for
      sKey - 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
    • setValue

      public void setValue(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:
      IllegalStateException - if parent not set
    • hide

      public void hide()
      Hides this extension and all then-empty parents so it isn't written
      See Also:
    • show

      public void show()
      Shows this extension and all parents so it can be written
      See Also:
    • 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

      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 class WithAttributes
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class WithAttributes