Class GpxExtension

    • Constructor Detail

      • 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 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 be null 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 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:
        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, ...)