org.jboss.seam.faces.projectstage
Class WebXmlContextParameterParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.jboss.seam.faces.projectstage.WebXmlContextParameterParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class WebXmlContextParameterParser
extends DefaultHandler

Simple SAX parser for reading "context-param" entries from web.xml

Author:
Christian Kaltepoth

Constructor Summary
WebXmlContextParameterParser()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
protected  boolean elements(String... name)
          Checks whether the element stack currently contains exactly the elements supplied by the caller.
 void endElement(String uri, String localName, String qName)
           
 String getContextParameter(String name)
          Returns the value of the supplied context parameter parsed from the web.xml file.
 void parse(InputStream stream)
          Parses the supplied web.xml InputStream.
 void startElement(String uri, String localName, String qName, Attributes attributes)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebXmlContextParameterParser

public WebXmlContextParameterParser()
Method Detail

parse

public final void parse(InputStream stream)
                 throws IOException
Parses the supplied web.xml InputStream.

Parameters:
stream - The stream to parse
Throws:
IOException - for any errors during the parsing process

getContextParameter

public String getContextParameter(String name)
Returns the value of the supplied context parameter parsed from the web.xml file. Returns null if the parser found no value for this parameter.

Parameters:
name - The name of the context parameter
Returns:
the value or null

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

characters

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

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

elements

protected boolean elements(String... name)
Checks whether the element stack currently contains exactly the elements supplied by the caller. This method can be used to find the current position in the document. The first argument is always the root element of the document, the second is a child of the root element, and so on. The method uses the local names of the elements only. Namespaces are ignored.

Parameters:
name - The names of the parent elements
Returns:
true if the parent element stack contains exactly these elements


Copyright © 2009-2011 Seam Framework. All Rights Reserved.