org.apache.cocoon.transformation.helpers
Class InterpolatingConfigurationHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.avalon.framework.configuration.SAXConfigurationHandler
          extended by org.apache.cocoon.transformation.helpers.InterpolatingConfigurationHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class InterpolatingConfigurationHandler
extends SAXConfigurationHandler

A SAX ContentHandler that builds Avalon Configuration objects, but also replaces variables of the form {var} with values from a map.

Version:
CVS $Id: InterpolatingConfigurationHandler.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Jeff Turner
See Also:
VariableConfiguration

Constructor Summary
InterpolatingConfigurationHandler(Map vars)
          Constructor.
InterpolatingConfigurationHandler(Map vars, String location)
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int len)
          Replace {vars} in element bodies.
protected  String getLocationString()
           
 void startElement(String uri, String localName, String qName, Attributes attr)
          Replace {vars} in attributes.
 
Methods inherited from class org.apache.avalon.framework.configuration.SAXConfigurationHandler
clear, createConfiguration, endElement, error, fatalError, getConfiguration, setDocumentLocator, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterpolatingConfigurationHandler

public InterpolatingConfigurationHandler(Map vars)
Constructor.

Parameters:
vars - The mappings from variable name to value.

InterpolatingConfigurationHandler

public InterpolatingConfigurationHandler(Map vars,
                                         String location)
Constructor.

Parameters:
vars - The mappings from variable name to value.
location - The origin of this configuration info.
Method Detail

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attr)
                  throws SAXException
Replace {vars} in attributes.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class SAXConfigurationHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int len)
                throws SAXException
Replace {vars} in element bodies.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class SAXConfigurationHandler
Throws:
SAXException

getLocationString

protected String getLocationString()
Overrides:
getLocationString in class SAXConfigurationHandler


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.