org.apache.cocoon.configuration
Class ConfigurationBuilder

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.apache.cocoon.configuration.ConfigurationBuilder
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ConfigurationBuilder
extends DefaultHandler
implements ErrorHandler

A ConfigurationBuilder builds Configurations from XML, via a SAX2 compliant parser.

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:

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.

Version:
SVN $Id: ConfigurationBuilder.java 179045 2005-05-30 11:08:13Z cziegeler $

Constructor Summary
ConfigurationBuilder(Settings s)
          Create a Configuration Builder
 
Method Summary
 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(InputStream inputStream, String systemId)
          Build a configuration object using an InputStream; supplying a systemId to make messages about all kinds of errors more meaningfull.
 Configuration build(String uri)
          Build a configuration object using an URI
 void characters(char[] ch, int start, int end)
           
protected  void clear()
          Clears all data from this configuration handler.
protected  DefaultConfiguration createConfiguration(String localName, String namespaceURI, String location)
          Create a new DefaultConfiguration with the specified local name, namespace, and location.
 void endDocument()
           
 void endElement(String namespaceURI, String localName, String rawName)
           
 void error(SAXParseException exception)
           
 void fatalError(SAXParseException exception)
           
 void setDocumentLocator(Locator locator)
           
 void setEntityResolver(EntityResolver resolver)
          Sets the EntityResolver to be used by parser.
 void startDocument()
           
 void startElement(String namespaceURI, String localName, String rawName, Attributes attributes)
           
 void startPrefixMapping(String prefix, String uri)
           
 void warning(SAXParseException exception)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationBuilder

public ConfigurationBuilder(Settings s)
Create a Configuration Builder

Method Detail

build

public Configuration build(InputStream inputStream)
                    throws SAXException,
                           IOException
Build a configuration object using an InputStream.

Parameters:
inputStream - an InputStream value
Returns:
a Configuration object
Throws:
SAXException - if a parsing error occurs
IOException - if an I/O error occurs

build

public Configuration build(InputStream inputStream,
                           String systemId)
                    throws SAXException,
                           IOException
Build a configuration object using an InputStream; supplying a systemId to make messages about all kinds of errors more meaningfull.

Parameters:
inputStream - an InputStream value
systemId - the systemId to set on the intermediate sax inputSource
Returns:
a Configuration object
Throws:
SAXException - if a parsing error occurs
IOException - if an I/O error occurs

build

public Configuration build(String uri)
                    throws SAXException,
                           IOException
Build a configuration object using an URI

Parameters:
uri - a String value
Returns:
a Configuration object
Throws:
SAXException - if a parsing error occurs
IOException - if an I/O error occurs

build

public Configuration build(InputSource input)
                    throws SAXException,
                           IOException
Build a configuration object using an XML InputSource object

Parameters:
input - an InputSource value
Returns:
a Configuration object
Throws:
SAXException - if a parsing error occurs
IOException - if an I/O error occurs

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Sets the EntityResolver to be used by parser. Useful when dealing with xml files that reference external entities.

Parameters:
resolver - implementation of EntityResolver

clear

protected void clear()
Clears all data from this configuration handler.


setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int end)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String rawName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

createConfiguration

protected DefaultConfiguration createConfiguration(String localName,
                                                   String namespaceURI,
                                                   String location)
Create a new DefaultConfiguration with the specified local name, namespace, and location.

Parameters:
localName - a String value
namespaceURI - a String value
location - a String value
Returns:
a DefaultConfiguration value

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String rawName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

error

public void error(SAXParseException exception)
           throws SAXException
Specified by:
error in interface ErrorHandler
Throws:
SAXException

warning

public void warning(SAXParseException exception)
             throws SAXException
Specified by:
warning in interface ErrorHandler
Throws:
SAXException

fatalError

public void fatalError(SAXParseException exception)
                throws SAXException
Specified by:
fatalError in interface ErrorHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.