XMLConfigurationUtil
@Deprecated public final class ConfigurationUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
assertWriteRead(IXMLConfigurable xmlConfiurable)
Deprecated.
Convenience class for testing that a
IXMLConfigurable instance
can be written, and read into an new instance that is equal as per
Object.equals(Object) . |
static void |
disableDelimiterParsing(XMLConfiguration xml)
Deprecated.
Disables delimiter parsing for both attributes and elements.
|
static XMLConfiguration |
getXmlAt(HierarchicalConfiguration node,
String key)
Deprecated.
This method is the same as
HierarchicalConfiguration.configurationAt(String) , except that
it first checks if the key exists before attempting to retrieve it,
and returns null on missing keys instead of an
IllegalArgumentException |
static <T> T |
newInstance(HierarchicalConfiguration node)
Deprecated.
Creates a new instance of the class represented by the "class" attribute
on the given node.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
boolean supportXMLConfigurable)
Deprecated.
Creates a new instance of the class represented by the "class" attribute
on the given node.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
String key)
Deprecated.
Creates a new instance of the class represented by the "class"
attribute
on the sub-node of the node argument, matching the key provided.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
String key,
boolean supportXMLConfigurable)
Deprecated.
Creates a new instance of the class represented by the "class"
attribute on the sub-node of the node argument, matching the key
provided.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
String key,
T defaultObject)
Deprecated.
Creates a new instance of the class represented by the "class"
attribute
on the sub-node of the node argument, matching the key provided.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
String key,
T defaultObject,
boolean supportXMLConfigurable)
Deprecated.
Creates a new instance of the class represented by the "class"
attribute
on the sub-node of the node argument, matching the key provided.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
T defaultObject)
Deprecated.
Creates a new instance of the class represented by the "class" attribute
on the given node.
|
static <T> T |
newInstance(HierarchicalConfiguration node,
T defaultObject,
boolean supportXMLConfigurable)
Deprecated.
Creates a new instance of the class represented by the "class" attribute
on the given node.
|
static Reader |
newReader(HierarchicalConfiguration node)
Deprecated.
Creates a new
Reader from a XMLConfiguration . |
static XMLConfiguration |
newXMLConfiguration(HierarchicalConfiguration c)
Deprecated.
This load method will return an Apache XML Configuration from
from a
HierarchicalConfiguration , with delimiter parsing
disabled. |
static XMLConfiguration |
newXMLConfiguration(Reader in)
Deprecated.
This load method will return an Apache XML Configuration from
from a reader, with delimiter parsing disabled.
|
public static void disableDelimiterParsing(XMLConfiguration xml)
xml
- XML configurationpublic static XMLConfiguration newXMLConfiguration(HierarchicalConfiguration c)
HierarchicalConfiguration
, with delimiter parsing
disabled.c
- hierarchical configurationpublic static XMLConfiguration newXMLConfiguration(Reader in)
This load method will return an Apache XML Configuration from from a reader, with delimiter parsing disabled.
Note: Leading and trailing white spaces are not preserved by
default.
To preserve them, add xml:space="preserve"
to your tag, like this:
<mytag xml:space="preserve"> </mytag>
The above example will preserve the white space in the tag's body.
in
- input streampublic static <T> T newInstance(HierarchicalConfiguration node)
IXMLConfigurable
, the object
created will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.T
- the type of the return valuenode
- the node representing the class to instantiate.ConfigurationException
- if instance cannot be created/populatedpublic static <T> T newInstance(HierarchicalConfiguration node, boolean supportXMLConfigurable)
IXMLConfigurable
and
supportXMLConfigurable
is true, the object created
will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.T
- the type of the return valuenode
- the node representing the class to instantiate.supportXMLConfigurable
- automatically populates the object from XML
if it is implementing IXMLConfigurable
.
Since 1.13.0, this flag is always considered true
.ConfigurationException
- if instance cannot be created/populatedpublic static <T> T newInstance(HierarchicalConfiguration node, T defaultObject)
IXMLConfigurable
, the object
created will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.T
- the type of the return valuenode
- the node representing the class to instantiate.defaultObject
- if returned object is null or undefined,
returns this default object.ConfigurationException
- if instance cannot be created/populatedpublic static <T> T newInstance(HierarchicalConfiguration node, T defaultObject, boolean supportXMLConfigurable)
IXMLConfigurable
and
supportXMLConfigurable
is true, the object created
will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.T
- the type of the return valuenode
- the node representing the class to instantiate.defaultObject
- if returned object is null or undefined,
returns this default object.supportXMLConfigurable
- automatically populates the object from XML
if it is implementing IXMLConfigurable
.
Since 1.13.0, this flag is always considered true
.ConfigurationException
- if instance cannot be created/populatedpublic static <T> T newInstance(HierarchicalConfiguration node, String key)
Creates a new instance of the class represented by the "class"
attribute
on the sub-node of the node argument, matching the key provided.
The class must have an empty constructor.
If the class is an instance of IXMLConfigurable
, the object
created will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.
Since 1.6.0, this method should throw a
ConfigurationException
upon error. Use a method
with a default value argument to avoid throwing exceptions.
T
- the type of the return valuenode
- the node representing the class to instantiate.key
- sub-node name/hierarchical pathConfigurationException
- if instance cannot be created/populatedpublic static <T> T newInstance(HierarchicalConfiguration node, String key, boolean supportXMLConfigurable)
Creates a new instance of the class represented by the "class"
attribute on the sub-node of the node argument, matching the key
provided.
The class must have an empty constructor.
If the class is an instance of IXMLConfigurable
and
supportXMLConfigurable
is true, the object created
will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.
Since 1.6.0, this method should throw a
ConfigurationException
upon error. Use a method
with a default value argument to avoid throwing exceptions.
T
- the type of the return valuenode
- the node representing the class to instantiate.key
- sub-node name/hierarchical pathsupportXMLConfigurable
- automatically populates the object from XML
if it is implementing IXMLConfigurable
.
Since 1.13.0, this flag is always considered true
.ConfigurationException
- if instance cannot be created/populatedpublic static <T> T newInstance(HierarchicalConfiguration node, String key, T defaultObject)
Creates a new instance of the class represented by the "class"
attribute
on the sub-node of the node argument, matching the key provided.
The class must have an empty constructor.
If the class is an instance of IXMLConfigurable
, the object
created will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.
This method should not throw exception upon errors, but will return the default value instead (even if null). Use a method without a default value argument to get exception on errors.
T
- the type of the return valuenode
- the node representing the class to instantiate.defaultObject
- if returned object is null or undefined,
returns this default object.key
- sub-node name/hierarchical pathpublic static <T> T newInstance(HierarchicalConfiguration node, String key, T defaultObject, boolean supportXMLConfigurable)
Creates a new instance of the class represented by the "class"
attribute
on the sub-node of the node argument, matching the key provided.
The class must have an empty constructor.
If the class is an instance of IXMLConfigurable
and
supportXMLConfigurable
is true, the object created
will be automatically populated by invoking the
IXMLConfigurable.loadFromXML(Reader)
method,
passing it the node XML automatically populated.
This method should not throw exception upon errors, but will return the default value instead (even if null). Use a method without a default value argument to get exception on errors.
T
- the type of the return valuenode
- the node representing the class to instantiate.defaultObject
- if returned object is null or undefined,
returns this default object.key
- sub-node name/hierarchical pathsupportXMLConfigurable
- automatically populates the object from XML
if it is implementing IXMLConfigurable
.
Since 1.13.0, this flag is always considered true
.public static Reader newReader(HierarchicalConfiguration node) throws IOException
Reader
from a XMLConfiguration
.
Do not forget to close the reader instance when you are done with it.node
- the xml configuration to convert to a reader instance.ConfigurationException
- cannot read configurationIOException
- cannot read configurationpublic static XMLConfiguration getXmlAt(HierarchicalConfiguration node, String key)
HierarchicalConfiguration.configurationAt(String)
, except that
it first checks if the key exists before attempting to retrieve it,
and returns null
on missing keys instead of an
IllegalArgumentException
node
- the tree to extract a sub tree fromkey
- the key that selects the sub treepublic static void assertWriteRead(IXMLConfigurable xmlConfiurable) throws IOException
IXMLConfigurable
instance
can be written, and read into an new instance that is equal as per
Object.equals(Object)
.xmlConfiurable
- the instance to test if it writes/read properlyIOException
- Cannot read/writeConfigurationException
- Cannot load configurationCopyright © 2008–2021 Norconex Inc.. All rights reserved.