Class GpxExtension

    • Constructor Detail

      • GpxExtension

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

        public GpxExtension​(java.lang.String namespaceURI,
                            java.lang.String qName,
                            org.xml.sax.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 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.XMLNamespace element, location and URI can be null if 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 for
        sKey - 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