Class XMLGISElementUtil


  • public final class XMLGISElementUtil
    extends Object
    This class provides tools to create an XML representation of map elements or to create map elements from an XML representation.
    Since:
    15.0
    Version:
    17.0 2020-01-04 14:41:54
    Author:
    Stéphane GALLAND
    See Also:
    XMLUtil
    Maven Group Id:
    org.arakhne.afc.gis
    Maven Artifact Id:
    gisinputoutput
    • Method Detail

      • writeMapElement

        public static Element writeMapElement​(MapElement primitive,
                                              XMLBuilder builder,
                                              XMLResources resources)
                                       throws IOException
        Write the XML description for the given map element.
        Parameters:
        primitive - is the map element to output.
        builder - is the tool to create XML nodes.
        resources - is the tool that permits to gather the resources.
        Returns:
        the XML node of the map element.
        Throws:
        IOException - in case of error.
      • writeMapElement

        public static Element writeMapElement​(MapElement primitive,
                                              String primitiveNodeName,
                                              XMLBuilder builder,
                                              XMLResources resources)
                                       throws IOException
        Write the XML description for the given map element.
        Parameters:
        primitive - is the map element to output.
        primitiveNodeName - is the name of the XML node that should contains the map element data. It may be null to use the default name.
        builder - is the tool to create XML nodes.
        resources - is the tool that permits to gather the resources.
        Returns:
        the XML node of the map element.
        Throws:
        IOException - in case of error.
      • readMapElement

        public static MapElement readMapElement​(Element element,
                                                String elementNodeName,
                                                PathBuilder pathBuilder,
                                                XMLResources resources)
                                         throws IOException
        Read a map element from the XML description.
        Parameters:
        element - is the XML node to read.
        elementNodeName - is the name of the XML node that should contains the map element data. It must be one of NODE_POINT, NODE_CIRCLE, NODE_POLYGON, NODE_POLYLINE, NODE_MULTIPOINT, or null for the XML node name itself.
        pathBuilder - is the tool to make paths absolute.
        resources - is the tool that permits to gather the resources.
        Returns:
        the map element.
        Throws:
        IOException - in case of error.
      • readMapElement

        public static <T extends MapElement> T readMapElement​(Element element,
                                                              String elementNodeName,
                                                              Class<T> type,
                                                              PathBuilder pathBuilder,
                                                              XMLResources resources)
                                                       throws IOException
        Read a map element from the XML description.
        Type Parameters:
        T - is the type of the element to create.
        Parameters:
        element - is the XML node to read.
        elementNodeName - is the name of the XML node that should contains the map element data. It must be one of NODE_POINT, NODE_CIRCLE, NODE_POLYGON, NODE_POLYLINE, NODE_MULTIPOINT, or null for the XML node name itself.
        type - is the type of the element to create, or null to use the default.
        pathBuilder - is the tool to make paths absolute.
        resources - is the tool that permits to gather the resources.
        Returns:
        the map element.
        Throws:
        IOException - in case of error.
      • getDefaultMapElementNodeName

        public static String getDefaultMapElementNodeName​(Class<? extends MapElement> type)
        Replies the default name of the XML node for the given type of map element.
        Parameters:
        type - the type of the map element.
        Returns:
        the default XML node name; or null if the type if unknown.
      • writeGISElementContainer

        public static void writeGISElementContainer​(Element xmlNode,
                                                    GISElementContainer<?> primitive,
                                                    XMLBuilder builder,
                                                    PathBuilder pathBuilder,
                                                    XMLResources resources)
                                             throws IOException
        Write the XML description for the given container of map elements.
        Parameters:
        xmlNode - is the XML node to fill with the container data.
        primitive - is the container of map elements to output.
        builder - is the tool to create XML nodes.
        pathBuilder - is the tool to make paths relative.
        resources - is the tool that permits to gather the resources.
        Throws:
        IOException - in case of error.
      • writeGISElementContainer

        public static void writeGISElementContainer​(Element xmlNode,
                                                    GISElementContainer<?> primitive,
                                                    String elementNodeName,
                                                    XMLBuilder builder,
                                                    PathBuilder pathBuilder,
                                                    XMLResources resources)
                                             throws IOException
        Write the XML description for the given container of map elements.
        Parameters:
        xmlNode - is the XML node to fill with the container data.
        primitive - is the container of map elements to output.
        elementNodeName - is the name of the XML node that should contains the map element data. It may be null to use the default name.
        builder - is the tool to create XML nodes.
        pathBuilder - is the tool to make paths relative.
        resources - is the tool that permits to gather the resources.
        Throws:
        IOException - in case of error.
      • readGISElementContainer

        public static <T extends MapElement> void readGISElementContainer​(Element xmlNode,
                                                                          GISElementContainer<T> primitive,
                                                                          PathBuilder pathBuilder,
                                                                          XMLResources resources)
                                                                   throws IOException
        Read map elements from the XML description.
        Type Parameters:
        T - is the type of the elements inside the container.
        Parameters:
        xmlNode - is the XML node to read.
        primitive - is the container of map elements to output.
        pathBuilder - is the tool to make paths absolute.
        resources - is the tool that permits to gather the resources.
        Throws:
        IOException - in case of error.
      • readGISElementContainer

        public static <T extends MapElement> void readGISElementContainer​(Element xmlNode,
                                                                          GISElementContainer<T> primitive,
                                                                          String elementNodeName,
                                                                          PathBuilder pathBuilder,
                                                                          XMLResources resources)
                                                                   throws IOException
        Read map elements from the XML description.
        Type Parameters:
        T - is the type of the elements inside the container.
        Parameters:
        xmlNode - is the XML node to read.
        primitive - is the container of map elements to output.
        elementNodeName - is the name of the XML node that should contains the map element data. It may be null to use the default name.
        pathBuilder - is the tool to make paths absolute.
        resources - is the tool that permits to gather the resources.
        Throws:
        IOException - in case of error.
      • writeGISElementAttributes

        public static void writeGISElementAttributes​(Element element,
                                                     GISElement primitive,
                                                     XMLBuilder builder,
                                                     XMLResources resources)
                                              throws IOException
        Write the attributes of the given GISElement in the the XML description. Only the name, geoId, id, and additional attributes are written. Icon and color are not written.
        Parameters:
        element - is the XML node to fill with the attributes
        primitive - is the map element to output. It may be null to use the default name.
        builder - is the tool to create XML nodes.
        resources - is the tool that permits to gather the resources.
        Throws:
        IOException - in case of error.
      • readGISElementAttributes

        public static void readGISElementAttributes​(Element element,
                                                    GISElement primitive,
                                                    PathBuilder pathBuilder,
                                                    XMLResources resources)
                                             throws IOException
        Read the attributes of a GISElement from the XML description. Only the name and additional attributes are read. Id, geoId, icon and color are not read.
        Parameters:
        element - is the XML node to read.
        primitive - is the GISElement to set up.
        pathBuilder - is the tool to make paths absolute.
        resources - is the tool that permits to gather the resources.
        Throws:
        IOException - in case of error.