de.caff.io
and de.caff.io.xml
instead.@Deprecated
public class XmlTool
extends java.lang.Object
This provides methods for both SAX and DOM handling.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
RELEASE_DATE
Deprecated.
The current version of the library.
|
Modifier and Type | Method and Description |
---|---|
static java.util.List<org.w3c.dom.Element> |
getChildElements(org.w3c.dom.Element element,
java.lang.String tagName)
Deprecated.
Get the child elements with a given name.
|
static java.lang.String |
getContent(org.w3c.dom.Element element,
boolean forceNonEmpty)
Deprecated.
Get the text content of the given element.
|
static double |
getDoubleValue(org.w3c.dom.Element element,
java.lang.String attributeName)
Deprecated.
Get a double value from an attribute.
|
static double |
getDoubleValue(java.lang.String elementTag,
org.xml.sax.Attributes attributes,
java.lang.String attributeName)
Deprecated.
Get a double value from an attribute.
|
static <E extends java.lang.Enum<E>> |
getEnumValue(org.w3c.dom.Element element,
java.lang.String attributeName,
java.lang.Class<E> enumClass)
Deprecated.
Get an enum value from an attribute.
|
static <E extends java.lang.Enum<E>> |
getEnumValue(java.lang.String elementTag,
org.xml.sax.Attributes attributes,
java.lang.String attributeName,
java.lang.Class<E> enumClass)
Deprecated.
Get an enum value from an attribute.
|
static int |
getIntValue(org.w3c.dom.Element element,
java.lang.String attributeName)
Deprecated.
Get an integer value from an attribute.
|
static int |
getIntValue(java.lang.String elementTag,
org.xml.sax.Attributes attributes,
java.lang.String attributeName)
Deprecated.
Get an integer value from an attribute.
|
static org.w3c.dom.Element |
getOptionalSingleChild(org.w3c.dom.Element element,
java.lang.String subElementName)
Deprecated.
Get a optional singular sub element from a given element.
|
static <T> T |
getOptionalValue(org.xml.sax.Attributes attributes,
java.lang.String attributeName,
java.util.function.Function<java.lang.String,? extends T> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static java.lang.String |
getOptionalValue(org.w3c.dom.Element element,
java.lang.String attributeName)
Deprecated.
Get the value of an optional attribute of the given element.
|
static <T> T |
getOptionalValue(org.w3c.dom.Element element,
java.lang.String attributeName,
java.util.function.Function<java.lang.String,? extends T> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static <T,E extends java.lang.Exception> |
getOptionalValueF(org.xml.sax.Attributes attributes,
java.lang.String attributeName,
FragileFunction1<? extends T,E,java.lang.String> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static <T,E extends java.lang.Exception> |
getOptionalValueF(org.w3c.dom.Element element,
java.lang.String attributeName,
FragileFunction1<? extends T,E,java.lang.String> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static org.w3c.dom.Element |
getSingleChild(org.w3c.dom.Element element,
java.lang.String subElementName)
Deprecated.
Get a singular sub element from a given element.
|
static java.lang.String |
getValue(org.xml.sax.Attributes attributes,
java.lang.String attributeName,
java.lang.String defaultValue)
Deprecated.
Get the value of the attribute of the given element.
|
static java.lang.String |
getValue(org.w3c.dom.Element element,
java.lang.String attributeName)
Deprecated.
Get the value of the attribute of the given element.
|
static <T> T |
getValue(org.w3c.dom.Element element,
java.lang.String attributeName,
java.util.function.Function<java.lang.String,? extends T> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static java.lang.String |
getValue(org.w3c.dom.Element element,
java.lang.String attributeName,
java.lang.String defaultValue)
Deprecated.
Get the value of the attribute of the given element.
|
static java.lang.String |
getValue(java.lang.String elementTag,
org.xml.sax.Attributes attributes,
java.lang.String attributeName)
Deprecated.
Get the value from attributes.
|
static <T> T |
getValue(java.lang.String elementTag,
org.xml.sax.Attributes attributes,
java.lang.String attributeName,
java.util.function.Function<java.lang.String,? extends T> extractor)
Deprecated.
/**
Get a unwrapped value from an attribute.
|
static <T,E extends java.lang.Exception> |
getValueF(org.w3c.dom.Element element,
java.lang.String attributeName,
FragileFunction1<? extends T,E,java.lang.String> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static <T,E extends java.lang.Exception> |
getValueF(java.lang.String elementTag,
org.xml.sax.Attributes attributes,
java.lang.String attributeName,
FragileFunction1<? extends T,E,java.lang.String> extractor)
Deprecated.
Get a unwrapped value from an attribute.
|
static org.w3c.dom.Document |
loadFromFile(java.lang.String path)
Deprecated.
Load a document from a file or URL.
|
public static final java.lang.String RELEASE_DATE
@NotNull public static java.lang.String getValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName) throws org.xml.sax.SAXException
element
- element containing attributeattributeName
- name of attributeorg.xml.sax.SAXException
- if attribute is non-existent@Nullable public static java.lang.String getOptionalValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName)
element
- element containing attributeattributeName
- name of attributenull
if the attribute does not existpublic static <T> T getValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName, @NotNull java.util.function.Function<java.lang.String,? extends T> extractor) throws org.xml.sax.SAXException
T
- result type of this methodelement
- element containing attributeattributeName
- name of attributeextractor
- converter from the textual value to the expected value typeorg.xml.sax.SAXException
- when the attribute does not exist, or when the extractor throwspublic static <T,E extends java.lang.Exception> T getValueF(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName, @NotNull FragileFunction1<? extends T,E,java.lang.String> extractor) throws org.xml.sax.SAXException
T
- result type of this methodE
- exception type of extractorelement
- element containing attributeattributeName
- name of attributeextractor
- converter from the textual value to the expected value type which may throw an exceptionorg.xml.sax.SAXException
- when the attribute does not exist, or when the extractor throws an exception@Nullable public static <T> T getOptionalValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName, @NotNull java.util.function.Function<java.lang.String,? extends T> extractor)
T
- result type of this methodelement
- element containing attributeattributeName
- name of attributeextractor
- converter from the textual value to the expected value typenull
if the value does not exist@Nullable public static <T,E extends java.lang.Exception> T getOptionalValueF(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName, @NotNull FragileFunction1<? extends T,E,java.lang.String> extractor) throws E extends java.lang.Exception
T
- result type of this methodE
- exception type of extractorelement
- element containing attributeattributeName
- name of attributeextractor
- converter from the textual value to the expected value typenull
if the value does not existE
- when the extractor throws an exceptionE extends java.lang.Exception
@NotNull public static java.lang.String getValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName, @NotNull java.lang.String defaultValue)
element
- element containing attributeattributeName
- name of attributedefaultValue
- default valuepublic static int getIntValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName) throws org.xml.sax.SAXException
element
- element containing attributeattributeName
- name of attributeorg.xml.sax.SAXException
- if attribute is non-existent or not an integer valuepublic static double getDoubleValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName) throws org.xml.sax.SAXException
element
- element containing attributeattributeName
- name of attributeorg.xml.sax.SAXException
- if attribute is non-existent or not a double value@NotNull public static <E extends java.lang.Enum<E>> E getEnumValue(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String attributeName, @NotNull java.lang.Class<E> enumClass) throws org.xml.sax.SAXException
E
- enum typeelement
- element containing attributeattributeName
- name of attributeenumClass
- enum classorg.xml.sax.SAXException
- if attribute is non-existent or not an enum of the given type@NotNull public static java.lang.String getValue(@NotNull java.lang.String elementTag, @NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName) throws org.xml.sax.SAXException
elementTag
- element tag, used for errorsattributes
- attributes of XML elementattributeName
- name of attributeorg.xml.sax.SAXException
- if attribute is non-existent@NotNull public static java.lang.String getValue(@NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName, @NotNull java.lang.String defaultValue)
attributes
- attributes of XML elementattributeName
- name of attributedefaultValue
- default valuepublic static int getIntValue(@NotNull java.lang.String elementTag, @NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName) throws org.xml.sax.SAXException
elementTag
- element tag, used for errorsattributes
- attributes of XML elementattributeName
- name of attributeorg.xml.sax.SAXException
- if attribute is non-existent or not an integer valuepublic static double getDoubleValue(@NotNull java.lang.String elementTag, @NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName) throws org.xml.sax.SAXException
elementTag
- element tag, used for errorsattributes
- attributes of XML elementattributeName
- name of attributeorg.xml.sax.SAXException
- if attribute is non-existent or not a double value@NotNull public static <E extends java.lang.Enum<E>> E getEnumValue(@NotNull java.lang.String elementTag, @NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName, @NotNull java.lang.Class<E> enumClass) throws org.xml.sax.SAXException
E
- enum typeelementTag
- element tag, used for errorsattributes
- attributes of XML elementattributeName
- name of attributeenumClass
- enum classorg.xml.sax.SAXException
- if attribute is non-existent or not an enum of the given typepublic static <T> T getValue(@NotNull java.lang.String elementTag, @NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName, @NotNull java.util.function.Function<java.lang.String,? extends T> extractor) throws org.xml.sax.SAXException
T
- result type of this methodelementTag
- element tag, used for errorsattributes
- attributes of XML elementattributeName
- name of attributeextractor
- converter from the textual value to the expected value typeorg.xml.sax.SAXException
- when the attribute does not exist, or when the extractor throwspublic static <T,E extends java.lang.Exception> T getValueF(@NotNull java.lang.String elementTag, @NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName, @NotNull FragileFunction1<? extends T,E,java.lang.String> extractor) throws org.xml.sax.SAXException
T
- result type of this methodE
- exception type of extractorelementTag
- element tag, used for errorsattributes
- attributes of XML elementattributeName
- name of attributeextractor
- converter from the textual value to the expected value type which throws an exceptionorg.xml.sax.SAXException
- when the attribute does not exist, or when the extractor throws an exception@Nullable public static <T> T getOptionalValue(@NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName, @NotNull java.util.function.Function<java.lang.String,? extends T> extractor)
T
- result type of this methodattributes
- attributes of XML elementattributeName
- name of attributeextractor
- converter from the textual value to the expected value typenull
if the value does not exist@Nullable public static <T,E extends java.lang.Exception> T getOptionalValueF(@NotNull org.xml.sax.Attributes attributes, @NotNull java.lang.String attributeName, @NotNull FragileFunction1<? extends T,E,java.lang.String> extractor) throws E extends java.lang.Exception
T
- result type of this methodE
- exception type of extractorattributes
- attributes of XML elementattributeName
- name of attributeextractor
- converter from the textual value to the expected value typenull
if the value does not existE
- when the extractor throws an exceptionE extends java.lang.Exception
@NotNull public static org.w3c.dom.Element getSingleChild(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String subElementName) throws org.xml.sax.SAXException
element
- element containing sub elementsubElementName
- name of sub elementorg.xml.sax.SAXException
- if sub element is missing or appearing more than once@Nullable public static org.w3c.dom.Element getOptionalSingleChild(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String subElementName) throws org.xml.sax.SAXException
element
- element containing sub elementsubElementName
- name of sub elementnull
if there is noneorg.xml.sax.SAXException
- if sub element is missing or appearing more than once@NotNull public static java.lang.String getContent(@NotNull org.w3c.dom.Element element, boolean forceNonEmpty) throws org.xml.sax.SAXException
element
- element containing contentforceNonEmpty
- force that element tag is not empty, i.e. <tag/%gt;?org.xml.sax.SAXException
- if there are other nodes than text or attribute,
or if forceContent
is true
and
the element uses an empty element tag@NotNull public static java.util.List<org.w3c.dom.Element> getChildElements(@NotNull org.w3c.dom.Element element, @NotNull java.lang.String tagName)
element
- element for which child elements are requestedtagName
- tag name of requested children@NotNull public static org.w3c.dom.Document loadFromFile(@NotNull java.lang.String path) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException
path
- path of XML filejavax.xml.parsers.ParserConfigurationException
- on parser config errorsjava.io.IOException
- on read errorsorg.xml.sax.SAXException
- on format errors