public class DefaultConfigurationBuilder extends Object
Configurations from XML,
via a SAX2 compliant parser.
XML namespace support is optional, and disabled by default to preserve
backwards-compatibility. To enable it, pass the DefaultConfigurationBuilder(boolean) constructor the flag true, or pass
a namespace-enabled XMLReader to the DefaultConfigurationBuilder(XMLReader) constructor.
The mapping from XML namespaces to Configuration namespaces is pretty
straightforward, with one caveat: attribute namespaces are (deliberately) not
supported. Enabling namespace processing has the following effects:
xmlns: are interpreted as
declaring a prefix:namespaceURI mapping, and won't result in the creation of
xmlns-prefixed attributes in the Configuration.
Configuration with getName().equals("title") and getNamespace().equals("http://foo.com").
Whitespace handling. Since mixed content is not allowed in the
configurations, whitespace is completely discarded in non-leaf nodes.
For the leaf nodes the default behavior is to trim the space
surrounding the value. This can be changed by specifying
xml:space attribute with value of preserve
in that case the whitespace is left intact.
| Constructor and Description |
|---|
DefaultConfigurationBuilder()
Create a Configuration Builder with a default XMLReader that ignores
namespaces.
|
DefaultConfigurationBuilder(boolean enableNamespaces)
Create a Configuration Builder, specifying a flag that determines
namespace support.
|
DefaultConfigurationBuilder(XMLReader parser)
Create a Configuration Builder with your own XMLReader.
|
| Modifier and Type | Method and Description |
|---|---|
Configuration |
build(InputSource input)
Build a configuration object using an XML InputSource object
|
Configuration |
build(InputStream inputStream)
Build a configuration object using an InputStream.
|
Configuration |
build(String uri)
Build a configuration object using an URI
|
Configuration |
buildFromFile(File file)
Build a configuration object from a file using a File object.
|
Configuration |
buildFromFile(String filename)
Build a configuration object from a file using a filename.
|
protected SAXConfigurationHandler |
getHandler()
Get a SAXConfigurationHandler for your configuration reading.
|
public DefaultConfigurationBuilder()
public DefaultConfigurationBuilder(boolean enableNamespaces)
enableNamespaces - If true, a namespace-aware
SAXParser is used. If false, the default JAXP
SAXParser (without namespace support) is used.public DefaultConfigurationBuilder(XMLReader parser)
parser - an XMLReaderprotected SAXConfigurationHandler getHandler()
SAXConfigurationHandlerpublic Configuration buildFromFile(String filename) throws SAXException, IOException, ConfigurationException
filename - name of the fileConfiguration objectSAXException - if a parsing error occursIOException - if an I/O error occursConfigurationException - if an error occurspublic Configuration buildFromFile(File file) throws SAXException, IOException, ConfigurationException
file - a File objectConfiguration objectSAXException - if a parsing error occursIOException - if an I/O error occursConfigurationException - if an error occurspublic Configuration build(InputStream inputStream) throws SAXException, IOException, ConfigurationException
inputStream - an InputStream valueConfiguration objectSAXException - if a parsing error occursIOException - if an I/O error occursConfigurationException - if an error occurspublic Configuration build(String uri) throws SAXException, IOException, ConfigurationException
uri - a String valueConfiguration objectSAXException - if a parsing error occursIOException - if an I/O error occursConfigurationException - if an error occurspublic Configuration build(InputSource input) throws SAXException, IOException, ConfigurationException
input - an InputSource valueConfiguration objectSAXException - if a parsing error occursIOException - if an I/O error occursConfigurationException - if an error occursCopyright © 2004-2020 EPICS. All Rights Reserved.