- java.lang.Object
-
- org.arakhne.afc.inputoutput.xml.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
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_COLORcolor="".static StringATTR_FILEfile="".static StringATTR_IDid="".static StringATTR_MIMETYPEmime="".static StringATTR_NAMEname="".static StringATTR_URLurl="".static StringDATE_FORMATFormat of the date in XML files.static StringNODE_RESOURCE<resource />.static StringNODE_RESOURCES<resources />.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleangetAttributeBoolean(Node document, boolean caseSensitive, String... path)Replies the boolean value that corresponds to the specified attribute's path.static booleangetAttributeBoolean(Node document, String... path)Replies the boolean value that corresponds to the specified attribute's path.static BooleangetAttributeBooleanWithDefault(Node document, boolean caseSensitive, Boolean defaultValue, String... path)Replies the boolean value that corresponds to the specified attribute's path.static BooleangetAttributeBooleanWithDefault(Node document, Boolean defaultValue, String... path)Replies the boolean value that corresponds to the specified attribute's path.static Class<?>getAttributeClass(Node document, boolean caseSensitive, String... path)Read an enumeration value.static Class<?>getAttributeClass(Node document, String... path)Read an enumeration value.static Class<?>getAttributeClassWithDefault(Node document, boolean caseSensitive, Class<?> defaultValue, String... path)Read a java class.static Class<?>getAttributeClassWithDefault(Node document, Class<?> defaultValue, String... path)Read an enumeration value.static intgetAttributeColor(Node document, boolean caseSensitive, String... path)Replies the color that corresponds to the specified attribute's path.static intgetAttributeColor(Node document, String... path)Replies the color that corresponds to the specified attribute's path.static IntegergetAttributeColorWithDefault(Node document, boolean caseSensitive, Integer defaultValue, String... path)Replies the color that corresponds to the specified attribute's path.static IntegergetAttributeColorWithDefault(Node document, Integer defaultValue, String... path)Replies the color that corresponds to the specified attribute's path.static DategetAttributeDate(Node document, boolean caseSensitive, String... path)Replies the date that corresponds to the specified attribute's path.static DategetAttributeDate(Node document, String... path)Replies the date that corresponds to the specified attribute's path.static DategetAttributeDateWithDefault(Node document, boolean caseSensitive, Date defaultValue, String... path)Replies the date that corresponds to the specified attribute's path.static DategetAttributeDateWithDefault(Node document, Date defaultValue, String... path)Replies the date that corresponds to the specified attribute's path.static doublegetAttributeDouble(Node document, boolean caseSensitive, String... path)Replies the double value that corresponds to the specified attribute's path.static doublegetAttributeDouble(Node document, String... path)Replies the double value that corresponds to the specified attribute's path.static DoublegetAttributeDoubleWithDefault(Node document, boolean caseSensitive, Double defaultValue, String... path)Replies the double value that corresponds to the specified attribute's path.static DoublegetAttributeDoubleWithDefault(Node document, Double defaultValue, String... path)Replies the double value that corresponds to the specified attribute's path.static <T extends Enum<T>>
TgetAttributeEnum(Node document, Class<T> type, boolean caseSensitive, String... path)Read an enumeration value.static <T extends Enum<T>>
TgetAttributeEnum(Node document, Class<T> type, String... path)Read an enumeration value.static <T extends Enum<T>>
TgetAttributeEnumWithDefault(Node document, Class<T> type, boolean caseSensitive, T defaultValue, String... path)Read an enumeration value.static <T extends Enum<T>>
TgetAttributeEnumWithDefault(Node document, Class<T> type, T defaultValue, String... path)Read an enumeration value.static floatgetAttributeFloat(Node document, boolean caseSensitive, String... path)Replies the float value that corresponds to the specified attribute's path.static floatgetAttributeFloat(Node document, String... path)Replies the float value that corresponds to the specified attribute's path.static FloatgetAttributeFloatWithDefault(Node document, boolean caseSensitive, Float defaultValue, String... path)Replies the float value that corresponds to the specified attribute's path.static FloatgetAttributeFloatWithDefault(Node document, Float defaultValue, String... path)Replies the float value that corresponds to the specified attribute's path.static intgetAttributeInt(Node document, boolean caseSensitive, String... path)Replies the integer value that corresponds to the specified attribute's path.static intgetAttributeInt(Node document, String... path)Replies the integer value that corresponds to the specified attribute's path.static IntegergetAttributeIntWithDefault(Node document, boolean caseSensitive, Integer defaultValue, String... path)Replies the integer value that corresponds to the specified attribute's path.static IntegergetAttributeIntWithDefault(Node document, Integer defaultValue, String... path)Replies the integer value that corresponds to the specified attribute's path.static longgetAttributeLong(Node document, boolean caseSensitive, String... path)Replies the long value that corresponds to the specified attribute's path.static longgetAttributeLong(Node document, String... path)Replies the long value that corresponds to the specified attribute's path.static LonggetAttributeLongWithDefault(Node document, boolean caseSensitive, Long defaultValue, String... path)Replies the long value that corresponds to the specified attribute's path.static LonggetAttributeLongWithDefault(Node document, Long defaultValue, String... path)Replies the long value that corresponds to the specified attribute's path.static URLgetAttributeURL(Node document, boolean caseSensitive, String... path)Replies the URL that corresponds to the specified attribute's path.static URLgetAttributeURL(Node document, String... path)Replies the URL that corresponds to the specified attribute's path.static URLgetAttributeURLWithDefault(Node document, boolean caseSensitive, URL defaultValue, String... path)Replies the URL that corresponds to the specified attribute's path.static URLgetAttributeURLWithDefault(Node document, URL defaultValue, String... path)Replies the URL that corresponds to the specified attribute's path.static UUIDgetAttributeUUID(Node document, boolean caseSensitive, String... path)Replies the UUID that corresponds to the specified attribute's path.static UUIDgetAttributeUUID(Node document, String... path)Replies the UUID that corresponds to the specified attribute's path.static List<UUID>getAttributeUUIDs(Node document, boolean caseSensitive, String... path)Replies the UUIDs that corresponds to the specified attribute's path.static List<UUID>getAttributeUUIDs(Node document, String... path)Replies the UUIDs that corresponds to the specified attribute's path.static UUIDgetAttributeUUIDWithDefault(Node document, boolean caseSensitive, UUID defaultValue, String... path)Replies the UUID that corresponds to the specified attribute's path.static UUIDgetAttributeUUIDWithDefault(Node document, UUID defaultValue, String... path)Replies the UUID that corresponds to the specified attribute's path.static StringgetAttributeValue(Node document, boolean casesSensitive, String... path)Replies the value that corresponds to the specified attribute's path.static StringgetAttributeValue(Node document, String... path)Replies the value that corresponds to the specified attribute's path.static StringgetAttributeValueWithDefault(Node document, boolean caseSensitive, String defaultValue, String... path)Replies the value that corresponds to the specified attribute's path.static StringgetAttributeValueWithDefault(Node document, String defaultValue, String... path)Replies the value that corresponds to the specified attribute's path.static <T extends Node>
TgetChild(Node parent, Class<T> type)Replies the first child node that has the specified type.static DocumentgetDocumentFor(Node node)Replies the XML Document that is containing the given node.static ElementgetElementFromPath(Node document, boolean caseSensitive, String... path)Replies the node that corresponds to the specified path.static ElementgetElementFromPath(Node document, String... path)Replies the node that corresponds to the specified path.static ElementgetElementMatching(Node document, XMLConstraint constraint, boolean caseSensitive, String... path)Replies the node that corresponds to the specified path.static ElementgetElementMatching(Node document, XMLConstraint constraint, String... path)Replies the node that corresponds to the specified path.static List<Element>getElementsFromPath(Node document, boolean caseSensitive, String... path)Replies the node that corresponds to the specified path.static List<Element>getElementsFromPath(Node document, String... path)Replies the node that corresponds to the specified path.static NodegetNodeFromPath(Node document, boolean caseSensitive, String... path)Replies the node that corresponds to the specified path.static NodegetNodeFromPath(Node document, String... path)Replies the node that corresponds to the specified path.static List<Node>getNodesFromPath(Node document, boolean caseSensitive, String... path)Replies the node that corresponds to the specified path.static List<Node>getNodesFromPath(Node document, String... path)Replies the node that corresponds to the specified path.static StringgetText(Node document, String... path)Replies the text inside the node at the specified path.static Iterator<Node>iterate(Node parent, String nodeName)Replies an iterator on nodes that have the specified node name.static intparseColor(String xmlColor)Parses an XML/HTML color.static DateparseDate(String xmlDate)Parses an XML/HTML date.static ObjectparseObject(String xmlSerializedObject)Deserialize an object from the given XML string.static byte[]parseString(String text)Parse a Base64 string with contains a set of bytes.static DocumentparseXML(String xmlString)Parse a string representation of an XML document.static intreadResources(Element node, XMLResources resources)Read the given resources from the given XML node.static URLreadResourceURL(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.static DocumentreadXML(File file)Read an XML file and replies the DOM document.static DocumentreadXML(InputStream stream)Read an XML file and replies the DOM document.static DocumentreadXML(Reader reader)Read an XML file and replies the DOM document.static DocumentreadXML(String file)Read an XML file and replies the DOM document.static DocumentreadXML(URL file)Read an XML file and replies the DOM document.static DocumentFragmentreadXMLFragment(File file)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(File file, boolean skipRoot)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(InputStream stream)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(InputStream stream, boolean skipRoot)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(Reader reader)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(Reader reader, boolean skipRoot)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(String file)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(String file, boolean skipRoot)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(URL file)Read an XML fragment from an XML file.static DocumentFragmentreadXMLFragment(URL file, boolean skipRoot)Read an XML fragment from an XML file.static <T extends Enum<T>>
booleansetAttributeEnum(Node document, Class<T> type, boolean caseSensitive, T value, String... path)Write an enumeration value.static <T extends Enum<T>>
booleansetAttributeEnum(Node document, Class<T> type, T value, String... path)Write an enumeration value.static StringtoColor(int rgba)Replies an XML/HTML color.static StringtoColor(int red, int green, int blue, int alpha)Replies an XML/HTML color.static StringtoString(byte[] array)Translate a set of bytes into an XML-compliant set of characters.static StringtoString(Serializable object)Serialize the given object and put it in a string which is compliant with XML format.static StringtoString(Date date)Replies an XML/HTML date.static StringtoString(Node node)Translate the XML tree into a string representation.static voidwriteResources(Element node, XMLResources resources, XMLBuilder builder)Write the given resources into the given XML node.static voidwriteXML(DocumentFragment fragment, File file)Write the given node tree into a XML file.static voidwriteXML(DocumentFragment fragment, OutputStream stream)Write the given node tree into a XML file.static voidwriteXML(DocumentFragment fragment, Writer writer)Write the given node tree into a XML file.static voidwriteXML(DocumentFragment fragment, String file)Write the given node tree into a XML file.static voidwriteXML(Document xmldocument, File file)Write the given node tree into a XML file.static voidwriteXML(Document xmldocument, OutputStream stream)Write the given node tree into a XML file.static voidwriteXML(Document xmldocument, Writer writer)Write the given node tree into a XML file.static voidwriteXML(Document xmldocument, String file)Write the given node tree into a XML file.static voidwriteXML(Node node, OutputStream stream)Write the given node tree into a XML file.static voidwriteXML(Node node, Writer writer)Write the given node tree into a XML file.
-
-
-
Field Detail
-
NODE_RESOURCE
public static final String NODE_RESOURCE
<resource />.- See Also:
- Constant Field Values
-
NODE_RESOURCES
public static final String NODE_RESOURCES
<resources />.- See Also:
- Constant Field Values
-
DATE_FORMAT
public static final String DATE_FORMAT
Format of the date in XML files. The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:- YYYY indicates the year
- MM indicates the month
- DD indicates the day
- T indicates the start of the required time section
- hh indicates the hour
- mm indicates the minute
- ss indicates the second
- See Also:
- Constant Field Values
-
ATTR_ID
public static final String ATTR_ID
id="".- See Also:
- Constant Field Values
-
ATTR_NAME
public static final String ATTR_NAME
name="".- See Also:
- Constant Field Values
-
ATTR_COLOR
public static final String ATTR_COLOR
color="".- See Also:
- Constant Field Values
-
ATTR_URL
public static final String ATTR_URL
url="".- See Also:
- Constant Field Values
-
ATTR_MIMETYPE
public static final String ATTR_MIMETYPE
mime="".- See Also:
- Constant Field Values
-
ATTR_FILE
public static final String ATTR_FILE
file="".- See Also:
- Constant Field Values
-
-
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 thepath'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
falseif 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 thepath'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
falseif 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
falseif 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 thepath's components are case sensitive.path- is the list of and ended by the attribute's name.- Returns:
- the java class or
nullif 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
nullif 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 thepath'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
defaultValueif 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
defaultValueif 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 thepath'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 thepath'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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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 thepath's components are case sensitive.path- is the list of and ended by the attribute's name.- Returns:
- the value of the enumeration or
nullif 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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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
nullif 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 thepath'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
nullif 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
nullif 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
nullif 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
nullif 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 thepath's components are case sensitive.path- is the list of names.- Returns:
- the node or
nullif 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
nullif 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 thepath's components are case sensitive.path- is the list of names.- Returns:
- the node or
nullif 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
nullif 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 thepath's components are case sensitive.path- is the list of names.- Returns:
- the node or
nullif 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
nullif 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 thepath's components are case sensitive.path- is the list of names.- Returns:
- the node or
nullif 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
nullif 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 thepath's components are case sensitive.path- is the list of names.- Returns:
- the node or
nullif 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
nullif 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
nullif 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:
#hexnamergb(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
-
parseDate
@Pure public static Date parseDate(String xmlDate) throws DateFormatException
Parses an XML/HTML date.- Parameters:
xmlDate- is the date to translate from a XML/HTML string.- Returns:
- the date.
- Throws:
DateFormatException- if the date has invalid format.- See Also:
toString(Date)
-
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
nullin case of error.
-
readXML
public static Document readXML(File file) throws IOException, SAXException, ParserConfigurationException
Read an XML file and replies the DOM document.- Parameters:
file- is the file to read- Returns:
- the DOM document red 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.
-
readXML
public static Document readXML(InputStream stream) throws IOException, SAXException, ParserConfigurationException
Read an XML file and replies the DOM document.- Parameters:
stream- is the stream to read- Returns:
- the DOM document red 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.
-
readXML
public static Document readXML(Reader reader) throws IOException, SAXException, ParserConfigurationException
Read an XML file and replies the DOM document.- Parameters:
reader- is the stream to read- Returns:
- the DOM document red 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.
-
readXML
public static Document readXML(String file) throws IOException, SAXException, ParserConfigurationException
Read an XML file and replies the DOM document.- Parameters:
file- is the file to read- Returns:
- the DOM document red 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.
-
readXML
public static Document readXML(URL file) throws IOException, SAXException, ParserConfigurationException
Read an XML file and replies the DOM document.- Parameters:
file- is the file to read- Returns:
- the DOM document red 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(File file) 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- 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(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 readskipRoot- iftruethe 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) 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- 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(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 readskipRoot- iftruethe 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) 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- 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(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 readskipRoot- iftruethe 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) 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- 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(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 readskipRoot- iftruethe 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) 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- 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 readskipRoot- iftruethe 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 thepath'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:
trueif written,falseif 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:
trueif written,falseif 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
nullin 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, File file) throws ParserConfigurationException, IOException
Write the given node tree into a XML file.- Parameters:
xmldocument- is the object that contains the node treefile- is the file name.- Throws:
IOException- if the stream cannot be read.ParserConfigurationException- if the parser cannot be configured.
-
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 treestream- is the target stream- Throws:
IOException- if the stream cannot be read.
-
writeXML
public static void writeXML(Document xmldocument, String file) throws ParserConfigurationException, IOException
Write the given node tree into a XML file.- Parameters:
xmldocument- is the object that contains the node treefile- is the file name.- Throws:
IOException- if the stream cannot be read.ParserConfigurationException- if the parser cannot be configured.
-
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 treewriter- is the target stream- Throws:
IOException- if the stream cannot be read.
-
writeXML
public static void writeXML(DocumentFragment fragment, File file) throws ParserConfigurationException, IOException
Write the given node tree into a XML file.- Parameters:
fragment- is the object that contains the node treefile- is the file name.- Throws:
IOException- if the stream cannot be read.ParserConfigurationException- if the parser cannot be configured.
-
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 treestream- is the target stream- Throws:
IOException- if the stream cannot be read.
-
writeXML
public static void writeXML(DocumentFragment fragment, String file) throws ParserConfigurationException, IOException
Write the given node tree into a XML file.- Parameters:
fragment- is the object that contains the node treefile- is the file name.- Throws:
IOException- if the stream cannot be read.ParserConfigurationException- if the parser cannot be configured.
-
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 treewriter- 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 treestream- 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 treewriter- 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
nullif it cannot be retrieved.
-
-