Class XMLUtil


  • public final class XMLUtil
    extends Object
    Utility class for manipulating XML data and files.
    Since:
    14.0
    Version:
    17.0 2020-01-04 14:41:40
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    inputoutput
    • Method Detail

      • getAttributeBoolean

        @Pure
        public static boolean getAttributeBoolean​(Node document,
                                                  boolean caseSensitive,
                                                  String... path)
        Replies the boolean value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the boolean value of the specified attribute or false if it was node found in the document
      • getAttributeBoolean

        @Pure
        public static boolean getAttributeBoolean​(Node document,
                                                  String... path)
        Replies the boolean value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the boolean value of the specified attribute or 0.
      • getAttributeBooleanWithDefault

        @Pure
        public static Boolean getAttributeBooleanWithDefault​(Node document,
                                                             boolean caseSensitive,
                                                             Boolean defaultValue,
                                                             String... path)
        Replies the boolean value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the boolean value of the specified attribute or false if it was node found in the document
      • getAttributeBooleanWithDefault

        @Pure
        public static Boolean getAttributeBooleanWithDefault​(Node document,
                                                             Boolean defaultValue,
                                                             String... path)
        Replies the boolean value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the boolean value of the specified attribute or false if it was node found in the document
      • getAttributeClass

        @Pure
        public static Class<?> getAttributeClass​(Node document,
                                                 boolean caseSensitive,
                                                 String... path)
        Read an enumeration value.
        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the java class or null if none.
      • getAttributeClass

        @Pure
        public static Class<?> getAttributeClass​(Node document,
                                                 String... path)
        Read an enumeration value.
        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the java class or null if none.
      • getAttributeClassWithDefault

        @Pure
        public static Class<?> getAttributeClassWithDefault​(Node document,
                                                            boolean caseSensitive,
                                                            Class<?> defaultValue,
                                                            String... path)
        Read a java class.
        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value replied if no attribute was found.
        path - is the list of and ended by the attribute's name.
        Returns:
        the java class or defaultValue if none.
      • getAttributeClassWithDefault

        @Pure
        public static Class<?> getAttributeClassWithDefault​(Node document,
                                                            Class<?> defaultValue,
                                                            String... path)
        Read an enumeration value.
        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value replied if no attribute was found.
        path - is the list of and ended by the attribute's name.
        Returns:
        the java class or defaultValue if none.
      • getAttributeColor

        @Pure
        public static int getAttributeColor​(Node document,
                                            boolean caseSensitive,
                                            String... path)
        Replies the color that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the color of the specified attribute.
      • getAttributeColor

        @Pure
        public static int getAttributeColor​(Node document,
                                            String... path)
        Replies the color that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the color of the specified attribute.
      • getAttributeColorWithDefault

        @Pure
        public static Integer getAttributeColorWithDefault​(Node document,
                                                           boolean caseSensitive,
                                                           Integer defaultValue,
                                                           String... path)
        Replies the color that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the color of the specified attribute or null if it was node found in the document
      • getAttributeColorWithDefault

        @Pure
        public static Integer getAttributeColorWithDefault​(Node document,
                                                           Integer defaultValue,
                                                           String... path)
        Replies the color that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        defaultValue - is the default value to reply.
        Returns:
        the color of the specified attribute.
      • getAttributeDate

        @Pure
        public static Date getAttributeDate​(Node document,
                                            boolean caseSensitive,
                                            String... path)
        Replies the date that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the date of the specified attribute or null if it was node found in the document
      • getAttributeDate

        @Pure
        public static Date getAttributeDate​(Node document,
                                            String... path)
        Replies the date that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the date of the specified attribute or null if it was node found in the document
      • getAttributeDateWithDefault

        @Pure
        public static Date getAttributeDateWithDefault​(Node document,
                                                       boolean caseSensitive,
                                                       Date defaultValue,
                                                       String... path)
        Replies the date that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the date of the specified attribute or null if it was node found in the document
      • getAttributeDateWithDefault

        @Pure
        public static Date getAttributeDateWithDefault​(Node document,
                                                       Date defaultValue,
                                                       String... path)
        Replies the date that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        defaultValue - is the default value to reply.
        Returns:
        the date of the specified attribute or null if it was node found in the document
      • getAttributeDouble

        @Pure
        public static double getAttributeDouble​(Node document,
                                                boolean caseSensitive,
                                                String... path)
        Replies the double value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the double value of the specified attribute or null if it was node found in the document
      • getAttributeDouble

        @Pure
        public static double getAttributeDouble​(Node document,
                                                String... path)
        Replies the double value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the double value of the specified attribute or 0.
      • getAttributeDoubleWithDefault

        @Pure
        public static Double getAttributeDoubleWithDefault​(Node document,
                                                           boolean caseSensitive,
                                                           Double defaultValue,
                                                           String... path)
        Replies the double value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the double value of the specified attribute or null if it was node found in the document
      • getAttributeDoubleWithDefault

        @Pure
        public static Double getAttributeDoubleWithDefault​(Node document,
                                                           Double defaultValue,
                                                           String... path)
        Replies the double value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the double value of the specified attribute or 0.
      • getAttributeEnum

        @Pure
        public static <T extends Enum<T>> T getAttributeEnum​(Node document,
                                                             Class<T> type,
                                                             boolean caseSensitive,
                                                             String... path)
        Read an enumeration value.
        Type Parameters:
        T - is the type of the enumeration.
        Parameters:
        document - is the XML document to explore.
        type - is the type of the enumeration.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the enumeration or null if none.
      • getAttributeEnum

        @Pure
        public static <T extends Enum<T>> T getAttributeEnum​(Node document,
                                                             Class<T> type,
                                                             String... path)
        Read an enumeration value.
        Type Parameters:
        T - is the type of the enumeration.
        Parameters:
        document - is the XML document to explore.
        type - is the type of the enumeration.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the enumeration or null if none.
      • getAttributeEnumWithDefault

        @Pure
        public static <T extends Enum<T>> T getAttributeEnumWithDefault​(Node document,
                                                                        Class<T> type,
                                                                        boolean caseSensitive,
                                                                        T defaultValue,
                                                                        String... path)
        Read an enumeration value.
        Type Parameters:
        T - is the type of the enumeration.
        Parameters:
        document - is the XML document to explore.
        type - is the type of the enumeration.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value replied if no attribute was found.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the enumeration or null if none.
      • getAttributeEnumWithDefault

        @Pure
        public static <T extends Enum<T>> T getAttributeEnumWithDefault​(Node document,
                                                                        Class<T> type,
                                                                        T defaultValue,
                                                                        String... path)
        Read an enumeration value.
        Type Parameters:
        T - is the type of the enumeration.
        Parameters:
        document - is the XML document to explore.
        type - is the type of the enumeration.
        defaultValue - is the default value replied if no attribute was found.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the enumeration or null if none.
      • getAttributeFloat

        @Pure
        public static float getAttributeFloat​(Node document,
                                              boolean caseSensitive,
                                              String... path)
        Replies the float value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the float value of the specified attribute or null if it was node found in the document
      • getAttributeFloat

        @Pure
        public static float getAttributeFloat​(Node document,
                                              String... path)
        Replies the float value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the float value of the specified attribute or 0.
      • getAttributeFloatWithDefault

        @Pure
        public static Float getAttributeFloatWithDefault​(Node document,
                                                         boolean caseSensitive,
                                                         Float defaultValue,
                                                         String... path)
        Replies the float value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the float value of the specified attribute or null if it was node found in the document
      • getAttributeFloatWithDefault

        @Pure
        public static Float getAttributeFloatWithDefault​(Node document,
                                                         Float defaultValue,
                                                         String... path)
        Replies the float value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the float value of the specified attribute or 0.
      • getAttributeInt

        @Pure
        public static int getAttributeInt​(Node document,
                                          boolean caseSensitive,
                                          String... path)
        Replies the integer value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the integer value of the specified attribute or null if it was node found in the document
      • getAttributeInt

        @Pure
        public static int getAttributeInt​(Node document,
                                          String... path)
        Replies the integer value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the integer value of the specified attribute or 0.
      • getAttributeIntWithDefault

        @Pure
        public static Integer getAttributeIntWithDefault​(Node document,
                                                         boolean caseSensitive,
                                                         Integer defaultValue,
                                                         String... path)
        Replies the integer value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the integer value of the specified attribute or null if it was node found in the document
      • getAttributeIntWithDefault

        @Pure
        public static Integer getAttributeIntWithDefault​(Node document,
                                                         Integer defaultValue,
                                                         String... path)
        Replies the integer value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the integer value of the specified attribute or 0.
      • getAttributeLong

        @Pure
        public static long getAttributeLong​(Node document,
                                            boolean caseSensitive,
                                            String... path)
        Replies the long value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the long value of the specified attribute or null if it was node found in the document
      • getAttributeLong

        @Pure
        public static long getAttributeLong​(Node document,
                                            String... path)
        Replies the long value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the long value of the specified attribute or 0.
      • getAttributeLongWithDefault

        @Pure
        public static Long getAttributeLongWithDefault​(Node document,
                                                       boolean caseSensitive,
                                                       Long defaultValue,
                                                       String... path)
        Replies the long value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the long value of the specified attribute or null if it was node found in the document
      • getAttributeLongWithDefault

        @Pure
        public static Long getAttributeLongWithDefault​(Node document,
                                                       Long defaultValue,
                                                       String... path)
        Replies the long value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the long value of the specified attribute or 0.
      • getAttributeURL

        @Pure
        public static URL getAttributeURL​(Node document,
                                          boolean caseSensitive,
                                          String... path)
        Replies the URL that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the URL in the specified attribute or null if it was node found in the document
      • getAttributeURL

        @Pure
        public static URL getAttributeURL​(Node document,
                                          String... path)
        Replies the URL that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the URL in the specified attribute or null if it was node found in the document
      • getAttributeURLWithDefault

        @Pure
        public static URL getAttributeURLWithDefault​(Node document,
                                                     boolean caseSensitive,
                                                     URL defaultValue,
                                                     String... path)
        Replies the URL that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the URL in the specified attribute or null if it was node found in the document
      • getAttributeURLWithDefault

        @Pure
        public static URL getAttributeURLWithDefault​(Node document,
                                                     URL defaultValue,
                                                     String... path)
        Replies the URL that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the URL in the specified attribute or null if it was node found in the document
      • getAttributeUUID

        @Pure
        public static UUID getAttributeUUID​(Node document,
                                            boolean caseSensitive,
                                            String... path)
        Replies the UUID that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the UUID in the specified attribute or null if it was node found in the document
      • getAttributeUUID

        @Pure
        public static UUID getAttributeUUID​(Node document,
                                            String... path)
        Replies the UUID that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the UUID in the specified attribute or null if it was node found in the document
      • getAttributeUUIDs

        @Pure
        public static List<UUID> getAttributeUUIDs​(Node document,
                                                   boolean caseSensitive,
                                                   String... path)
        Replies the UUIDs that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the UUIDs in the specified attribute, never null
      • getAttributeUUIDs

        @Pure
        public static List<UUID> getAttributeUUIDs​(Node document,
                                                   String... path)
        Replies the UUIDs that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the UUIDs in the specified attribute, never null
      • getAttributeUUIDWithDefault

        @Pure
        public static UUID getAttributeUUIDWithDefault​(Node document,
                                                       boolean caseSensitive,
                                                       UUID defaultValue,
                                                       String... path)
        Replies the UUID that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the UUID in the specified attribute or null if it was node found in the document
      • getAttributeUUIDWithDefault

        @Pure
        public static UUID getAttributeUUIDWithDefault​(Node document,
                                                       UUID defaultValue,
                                                       String... path)
        Replies the UUID that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply.
        path - is the list of and ended by the attribute's name.
        Returns:
        the UUID in the specified attribute or null if it was node found in the document
      • getAttributeValue

        @Pure
        public static String getAttributeValue​(Node document,
                                               boolean casesSensitive,
                                               String... path)
        Replies the value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        casesSensitive - indicates of the path's components are case sensitive.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the specified attribute or null if it was node found in the document
      • getAttributeValue

        @Pure
        public static String getAttributeValue​(Node document,
                                               String... path)
        Replies the value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the specified attribute or null if it was node found in the document
      • getAttributeValueWithDefault

        @Pure
        public static String getAttributeValueWithDefault​(Node document,
                                                          boolean caseSensitive,
                                                          String defaultValue,
                                                          String... path)
        Replies the value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        defaultValue - is the default value to reply if no attribute value was found.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the specified attribute or null if it was node found in the document
      • getAttributeValueWithDefault

        @Pure
        public static String getAttributeValueWithDefault​(Node document,
                                                          String defaultValue,
                                                          String... path)
        Replies the value that corresponds to the specified attribute's path.

        The path is an ordered list of tag's names and ended by the name of the attribute.

        Parameters:
        document - is the XML document to explore.
        defaultValue - is the default value to reply if no attribute value was found.
        path - is the list of and ended by the attribute's name.
        Returns:
        the value of the specified attribute or null if it was node found in the document
      • getChild

        @Pure
        public static <T extends Node> T getChild​(Node parent,
                                                  Class<T> type)
        Replies the first child node that has the specified type.
        Type Parameters:
        T - is the type of the desired child
        Parameters:
        parent - is the element from which the child must be extracted.
        type - is the type of the desired child
        Returns:
        the child node or null if none.
      • getDocumentFor

        @Pure
        public static Document getDocumentFor​(Node node)
        Replies the XML Document that is containing the given node.
        Parameters:
        node - the node.
        Returns:
        the Document in which the given node is, or null if not found.
      • getElementFromPath

        @Pure
        public static Element getElementFromPath​(Node document,
                                                 boolean caseSensitive,
                                                 String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getElementFromPath

        @Pure
        public static Element getElementFromPath​(Node document,
                                                 String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getElementMatching

        @Pure
        public static Element getElementMatching​(Node document,
                                                 XMLConstraint constraint,
                                                 boolean caseSensitive,
                                                 String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node.

        Parameters:
        document - is the XML document to explore.
        constraint - is the constraint that the replied element must respect.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getElementMatching

        @Pure
        public static Element getElementMatching​(Node document,
                                                 XMLConstraint constraint,
                                                 String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node.

        Parameters:
        document - is the XML document to explore.
        constraint - is the constraint that the replied element must respect.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getElementsFromPath

        @Pure
        public static List<Element> getElementsFromPath​(Node document,
                                                        boolean caseSensitive,
                                                        String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getElementsFromPath

        @Pure
        public static List<Element> getElementsFromPath​(Node document,
                                                        String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getNodeFromPath

        @Pure
        public static Node getNodeFromPath​(Node document,
                                           boolean caseSensitive,
                                           String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getNodeFromPath

        @Pure
        public static Node getNodeFromPath​(Node document,
                                           String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getNodesFromPath

        @Pure
        public static List<Node> getNodesFromPath​(Node document,
                                                  boolean caseSensitive,
                                                  String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node.

        Parameters:
        document - is the XML document to explore.
        caseSensitive - indicates of the path's components are case sensitive.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getNodesFromPath

        @Pure
        public static List<Node> getNodesFromPath​(Node document,
                                                  String... path)
        Replies the node that corresponds to the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of names.
        Returns:
        the node or null if it was not found in the document.
      • getText

        @Pure
        public static String getText​(Node document,
                                     String... path)
        Replies the text inside the node at the specified path.

        The path is an ordered list of tag's names and ended by the name of the desired node. Be careful about the fact that the names are case sensitives.

        Parameters:
        document - is the XML document to explore.
        path - is the list of names. This path may be empty.
        Returns:
        the text or null if the node was not found in the document or the text inside was empty.
      • iterate

        @Pure
        public static Iterator<Node> iterate​(Node parent,
                                             String nodeName)
        Replies an iterator on nodes that have the specified node name.
        Parameters:
        parent - is the node from which the children must be extracted.
        nodeName - is the name of the extracted nodes
        Returns:
        the iterator on the parents.
      • parseColor

        @Pure
        public static int parseColor​(String xmlColor)
                              throws ColorFormatException
        Parses an XML/HTML color.

        The supported formats of color are:

        • #hex
        • name
        • rgb(r, g, b)
        • rgba(r, g, b, a)
        • hsl(h[%], s[%], l[%])
        • hsla(h[%], s[%], l[%], a)

        The supported color names are listed in ColorNames.

        Parameters:
        xmlColor - is the color to translate from a XML/HTML string.
        Returns:
        the color.
        Throws:
        ColorFormatException - if the color has invalid format.
        See Also:
        see
      • parseObject

        @Pure
        public static Object parseObject​(String xmlSerializedObject)
                                  throws IOException,
                                         ClassNotFoundException
        Deserialize an object from the given XML string.
        Parameters:
        xmlSerializedObject - is the string which is containing the serialized object.
        Returns:
        the serialized object extracted from the XML string.
        Throws:
        IOException - if something wrong append during deserialization.
        ClassNotFoundException - is thrown when the class for the deserialized object is not found.
      • parseString

        @Pure
        public static byte[] parseString​(String text)
        Parse a Base64 string with contains a set of bytes.
        Parameters:
        text - is the string to uudecode
        Returns:
        the decoding result
        See Also:
        toString(byte[])
      • parseXML

        @Pure
        public static Document parseXML​(String xmlString)
        Parse a string representation of an XML document.
        Parameters:
        xmlString - is the string representation of the XML document.
        Returns:
        the document or null in case of error.
      • readXMLFragment

        public static DocumentFragment readXMLFragment​(File file,
                                                       boolean skipRoot)
                                                throws IOException,
                                                       SAXException,
                                                       ParserConfigurationException
        Read an XML fragment from an XML file. The XML file is well-formed. It means that the fragment will contains a single element: the root element within the input file.
        Parameters:
        file - is the file to read
        skipRoot - if true the root element itself is not part of the fragment, and the children of the root element are directly added within the fragment.
        Returns:
        the fragment from the file.
        Throws:
        IOException - if the stream cannot be read.
        SAXException - if the stream does not contains valid XML data.
        ParserConfigurationException - if the parser cannot be configured.
      • readXMLFragment

        public static DocumentFragment readXMLFragment​(InputStream stream,
                                                       boolean skipRoot)
                                                throws IOException,
                                                       SAXException,
                                                       ParserConfigurationException
        Read an XML fragment from an XML file. The XML file is well-formed. It means that the fragment will contains a single element: the root element within the input stream.
        Parameters:
        stream - is the stream to read
        skipRoot - if true the root element itself is not part of the fragment, and the children of the root element are directly added within the fragment.
        Returns:
        the fragment from the stream.
        Throws:
        IOException - if the stream cannot be read.
        SAXException - if the stream does not contains valid XML data.
        ParserConfigurationException - if the parser cannot be configured.
      • readXMLFragment

        public static DocumentFragment readXMLFragment​(Reader reader,
                                                       boolean skipRoot)
                                                throws IOException,
                                                       SAXException,
                                                       ParserConfigurationException
        Read an XML fragment from an XML file. The XML file is well-formed. It means that the fragment will contains a single element: the root element within the input stream.
        Parameters:
        reader - is the stream to read
        skipRoot - if true the root element itself is not part of the fragment, and the children of the root element are directly added within the fragment.
        Returns:
        the fragment from the reader.
        Throws:
        IOException - if the stream cannot be read.
        SAXException - if the stream does not contains valid XML data.
        ParserConfigurationException - if the parser cannot be configured.
      • readXMLFragment

        public static DocumentFragment readXMLFragment​(String file,
                                                       boolean skipRoot)
                                                throws IOException,
                                                       SAXException,
                                                       ParserConfigurationException
        Read an XML fragment from an XML file. The XML file is well-formed. It means that the fragment will contains a single element: the root element within the input file.
        Parameters:
        file - is the file to read
        skipRoot - if true the root element itself is not part of the fragment, and the children of the root element are directly added within the fragment.
        Returns:
        the fragment from the file.
        Throws:
        IOException - if the stream cannot be read.
        SAXException - if the stream does not contains valid XML data.
        ParserConfigurationException - if the parser cannot be configured.
      • readXMLFragment

        public static DocumentFragment readXMLFragment​(URL file,
                                                       boolean skipRoot)
                                                throws IOException,
                                                       SAXException,
                                                       ParserConfigurationException
        Read an XML fragment from an XML file. The XML file is well-formed. It means that the fragment will contains a single element: the root element within the input file.
        Parameters:
        file - is the file to read
        skipRoot - if true the root element itself is not part of the fragment, and the children of the root element are directly added within the fragment.
        Returns:
        the fragment from the file.
        Throws:
        IOException - if the stream cannot be read.
        SAXException - if the stream does not contains valid XML data.
        ParserConfigurationException - if the parser cannot be configured.
      • setAttributeEnum

        public static <T extends Enum<T>> boolean setAttributeEnum​(Node document,
                                                                   Class<T> type,
                                                                   boolean caseSensitive,
                                                                   T value,
                                                                   String... path)
        Write an enumeration value.
        Type Parameters:
        T - is the type of the enumeration.
        Parameters:
        document - is the XML document to explore.
        type - is the type of the enumeration.
        caseSensitive - indicates of the path's components are case sensitive.
        value - is the value to put in the document.
        path - is the list of and ended by the attribute's name.
        Returns:
        true if written, false if not written.
      • setAttributeEnum

        public static <T extends Enum<T>> boolean setAttributeEnum​(Node document,
                                                                   Class<T> type,
                                                                   T value,
                                                                   String... path)
        Write an enumeration value.
        Type Parameters:
        T - is the type of the enumeration.
        Parameters:
        document - is the XML document to explore.
        type - is the type of the enumeration.
        value - is the value to put in the document.
        path - is the list of and ended by the attribute's name.
        Returns:
        true if written, false if not written.
      • toColor

        @Pure
        public static String toColor​(int rgba)
        Replies an XML/HTML color.
        Parameters:
        rgba - the color components.
        Returns:
        the XML color encoding.
        See Also:
        parseColor(String)
      • toColor

        @Pure
        public static String toColor​(int red,
                                     int green,
                                     int blue,
                                     int alpha)
        Replies an XML/HTML color.
        Parameters:
        red - the red component.
        green - the green component.
        blue - the blue component.
        alpha - the alpha component.
        Returns:
        the XML color encoding.
        See Also:
        parseColor(String)
      • toString

        @Pure
        public static String toString​(byte[] array)
        Translate a set of bytes into an XML-compliant set of characters.
        Parameters:
        array - is the string to uuencode.
        Returns:
        the string representation of the given array.
        See Also:
        parseString(String)
      • toString

        @Pure
        public static String toString​(Date date)
        Replies an XML/HTML date.
        Parameters:
        date - is the date to translate into a XML/HTML string.
        Returns:
        the XML date encoding.
        See Also:
        parseDate(String)
      • toString

        @Pure
        public static String toString​(Node node)
        Translate the XML tree into a string representation.
        Parameters:
        node - is the object that contains the node tree
        Returns:
        the string representation or null in case of error.
      • toString

        @Pure
        public static String toString​(Serializable object)
                               throws IOException
        Serialize the given object and put it in a string which is compliant with XML format.
        Parameters:
        object - is the object to serialize.
        Returns:
        the XML representation of the object.
        Throws:
        IOException - if something wrong append during serialization.
      • writeXML

        public static void writeXML​(Document xmldocument,
                                    OutputStream stream)
                             throws IOException
        Write the given node tree into a XML file.
        Parameters:
        xmldocument - is the object that contains the node tree
        stream - is the target stream
        Throws:
        IOException - if the stream cannot be read.
      • writeXML

        public static void writeXML​(Document xmldocument,
                                    Writer writer)
                             throws IOException
        Write the given node tree into a XML file.
        Parameters:
        xmldocument - is the object that contains the node tree
        writer - is the target stream
        Throws:
        IOException - if the stream cannot be read.
      • writeXML

        public static void writeXML​(DocumentFragment fragment,
                                    OutputStream stream)
                             throws IOException
        Write the given node tree into a XML file.
        Parameters:
        fragment - is the object that contains the node tree
        stream - is the target stream
        Throws:
        IOException - if the stream cannot be read.
      • writeXML

        public static void writeXML​(DocumentFragment fragment,
                                    Writer writer)
                             throws IOException
        Write the given node tree into a XML file.
        Parameters:
        fragment - is the object that contains the node tree
        writer - is the target stream
        Throws:
        IOException - if the stream cannot be read.
      • writeXML

        public static void writeXML​(Node node,
                                    OutputStream stream)
                             throws IOException
        Write the given node tree into a XML file.
        Parameters:
        node - is the object that contains the node tree
        stream - is the target stream
        Throws:
        IOException - if the stream cannot be read.
      • writeXML

        public static void writeXML​(Node node,
                                    Writer writer)
                             throws IOException
        Write the given node tree into a XML file.
        Parameters:
        node - is the object that contains the node tree
        writer - is the target stream
        Throws:
        IOException - if the writer cannot be used.
      • writeResources

        public static void writeResources​(Element node,
                                          XMLResources resources,
                                          XMLBuilder builder)
        Write the given resources into the given XML node.
        Parameters:
        node - is the XML node to fill.
        resources - are the resources to put out.
        builder - is the tool to create XML nodes.
      • readResources

        public static int readResources​(Element node,
                                        XMLResources resources)
                                 throws IOException
        Read the given resources from the given XML node. The node should have a node named "resources" with a node named "resource" for each resource inside.

        The given resources are not cleared before the XML document is read.

        Parameters:
        node - is the XML node to read.
        resources - is the collection of resources to fill out.
        Returns:
        the number of read resources.
        Throws:
        IOException - in case of error.
      • readResourceURL

        @Pure
        public static URL readResourceURL​(Element node,
                                          XMLResources resources,
                                          String... path)
        Replies the resource URL that is contained inside the XML attribute defined in the given node and with the given XML path.
        Parameters:
        node - is the XML node to read.
        resources - is the collection of resources to read.
        path - is the XML path, relative to the node, of the attribute. The last element of the array is the name of the attribute.
        Returns:
        the resource URL, or null if it cannot be retrieved.