|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.avalon.framework.configuration.DefaultConfigurationBuilder
A DefaultConfigurationBuilder builds 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.
| Field Summary | |
private SAXConfigurationHandler |
m_handler |
private org.xml.sax.XMLReader |
m_parser |
| Constructor Summary | |
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(org.xml.sax.XMLReader parser)Create a Configuration Builder with your own XMLReader. |
|
| Method Summary | |
Configuration |
build(org.xml.sax.InputSource input)Build a configuration object using an XML InputSource object |
Configuration |
build(java.io.InputStream inputStream)Build a configuration object using an InputStream. |
Configuration |
build(java.io.InputStream inputStream, java.lang.String systemId)Build a configuration object using an InputStream; supplying a systemId to make messages about all kinds of errors more meaningfull. |
Configuration |
build(java.lang.String uri)Build a configuration object using an URI |
Configuration |
buildFromFile(java.io.File file)Build a configuration object from a file using a File object. |
Configuration |
buildFromFile(java.lang.String filename)Build a configuration object from a file using a filename. |
protected SAXConfigurationHandler |
getHandler()Get a SAXConfigurationHandler for your configuration reading. |
private void |
setParser(org.xml.sax.XMLReader parser)Internally sets up the XMLReader |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private SAXConfigurationHandler m_handler
private org.xml.sax.XMLReader m_parser
| Constructor Detail |
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(org.xml.sax.XMLReader parser)
parser - an XMLReader| Method Detail |
private void setParser(org.xml.sax.XMLReader parser)
protected SAXConfigurationHandler getHandler()
SAXConfigurationHandler
public Configuration buildFromFile(java.lang.String filename)
throws org.xml.sax.SAXException,
java.io.IOException,
ConfigurationException
filename - name of the fileConfiguration objectorg.xml.sax.SAXException - if a parsing error occursjava.io.IOException - if an I/O error occursConfigurationException - if an error occurs
public Configuration buildFromFile(java.io.File file)
throws org.xml.sax.SAXException,
java.io.IOException,
ConfigurationException
file - a File objectConfiguration objectorg.xml.sax.SAXException - if a parsing error occursjava.io.IOException - if an I/O error occursConfigurationException - if an error occurs
public Configuration build(java.io.InputStream inputStream)
throws org.xml.sax.SAXException,
java.io.IOException,
ConfigurationException
inputStream - an InputStream valueConfiguration objectorg.xml.sax.SAXException - if a parsing error occursjava.io.IOException - if an I/O error occursConfigurationException - if an error occurs
public Configuration build(java.io.InputStream inputStream,
java.lang.String systemId)
throws org.xml.sax.SAXException,
java.io.IOException,
ConfigurationException
inputStream - an InputStream valuesystemId - the systemId to set on the intermediate sax inputSourceConfiguration objectorg.xml.sax.SAXException - if a parsing error occursjava.io.IOException - if an I/O error occursConfigurationException - if an error occurs
public Configuration build(java.lang.String uri)
throws org.xml.sax.SAXException,
java.io.IOException,
ConfigurationException
uri - a String valueConfiguration objectorg.xml.sax.SAXException - if a parsing error occursjava.io.IOException - if an I/O error occursConfigurationException - if an error occurs
public Configuration build(org.xml.sax.InputSource input)
throws org.xml.sax.SAXException,
java.io.IOException,
ConfigurationException
input - an InputSource valueConfiguration objectorg.xml.sax.SAXException - if a parsing error occursjava.io.IOException - if an I/O error occursConfigurationException - if an error occurs
|
Keel 2.1RC2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||