|
|||||||||
| Home >> All >> org >> cantaloop >> tools >> [ digester overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.cantaloop.tools.digester
Class Digester

java.lang.Objectorg.xml.sax.HandlerBase
org.cantaloop.tools.digester.Digester
- All Implemented Interfaces:
- org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
- public class Digester
- extends org.xml.sax.HandlerBase
A Digester processes an XML input stream by matching a series of element
nesting patterns to execute Rules that have been added prior to the start of parsing. This
package was inspired by the XmlMapper class that was part of Tomcat 3.0 and 3.1,
but is organized somewhat differently.
See the Digester Developer Guide for more information.
IMPLEMENTATION NOTE - A single Digester instance may only be used within the
context of a single thread at a time, and a call to parse() must be completed
before another can be initiated even from the same thread.
- Version:
- $Revision: 1.1 $ $Date: 2002/03/28 02:23:16 $
| Field Summary | |
protected java.lang.StringBuffer |
bodyText
The body text of the current element. |
protected ArrayStack |
bodyTexts
The stack of body text string buffers for surrounding elements. |
protected int |
debug
The debugging detail level of this component. |
protected java.util.HashMap |
dtds
The URLs of DTDs that have been registered, keyed by the public identifier that corresponds. |
protected org.xml.sax.ErrorHandler |
errorHandler
The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur. |
protected org.xml.sax.Locator |
locator
The Locator associated with our parser. |
protected java.lang.String |
match
The current match pattern for nested element processing. |
protected javax.xml.parsers.SAXParser |
parser
The SAXParser we will use to parse the input stream. |
protected java.lang.Object |
root
The "root" element of the stack (in other words, the last object that was popped. |
protected java.util.HashMap |
rules
The set of Rules that have been registered with this Digester. |
protected ArrayStack |
stack
The object stack being constructed. |
protected boolean |
validating
Do we want to use a validating parser? |
| Constructor Summary | |
Digester()
Construct a new Digester with default properties. |
|
| Method Summary | |
void |
addCallMethod(java.lang.String pattern,
java.lang.String methodName,
int paramCount)
Add an "call method" rule for the specified parameters. |
void |
addCallMethod(java.lang.String pattern,
java.lang.String methodName,
int paramCount,
java.lang.Class[] paramTypes)
Add an "call method" rule for the specified parameters. |
void |
addCallMethod(java.lang.String pattern,
java.lang.String methodName,
int paramCount,
java.lang.String[] paramTypes)
Add an "call method" rule for the specified parameters. |
void |
addCallParam(java.lang.String pattern,
int paramIndex)
Add a "call parameter" rule for the specified parameters. |
void |
addCallParam(java.lang.String pattern,
int paramIndex,
java.lang.String attributeName)
Add a "call parameter" rule for the specified parameters. |
void |
addObjectCreate(java.lang.String pattern,
java.lang.String className)
Add an "object create" rule for the specified parameters. |
void |
addObjectCreate(java.lang.String pattern,
java.lang.String className,
java.lang.String attributeName)
Add an "object create" rule for the specified parameters. |
void |
addRule(java.lang.String pattern,
Rule rule)
Register a new Rule matching the specified pattern. |
void |
addRuleForAllPrefixes(java.lang.String[] prefixes,
java.lang.String suffix,
Rule rule)
|
void |
addSetNext(java.lang.String pattern,
java.lang.String methodName)
Add a "set next" rule for the specified parameters. |
void |
addSetNext(java.lang.String pattern,
java.lang.String methodName,
java.lang.String paramType)
Add a "set next" rule for the specified parameters. |
void |
addSetProperties(java.lang.String pattern)
Add a "set properties" rule for the specified parameters. |
void |
addSetProperty(java.lang.String pattern,
java.lang.String name,
java.lang.String value)
Add a "set property" rule for the specified parameters. |
void |
addSetTop(java.lang.String pattern,
java.lang.String methodName)
Add a "set top" rule for the specified parameters. |
void |
addSetTop(java.lang.String pattern,
java.lang.String methodName,
java.lang.String paramType)
Add a "set top" rule for the specified parameters. |
void |
characters(char[] buffer,
int start,
int length)
Process notification of character data received from the body of an XML element. |
void |
clear()
Clear the current contents of the object stack. |
void |
endDocument()
Process notification of the end of the document being reached. |
void |
endElement(java.lang.String name)
Process notification of the end of an XML element being reached. |
void |
error(org.xml.sax.SAXParseException exception)
Forward notification of a parsing error to the application supplied error handler (if any). |
void |
fatalError(org.xml.sax.SAXParseException exception)
Forward notification of a fatal parsing error to the application supplied error handler (if any). |
int |
getCount()
Return the current depth of the element stack. |
int |
getDebug()
Return the debugging detail level of this Digester. |
org.xml.sax.ErrorHandler |
getErrorHandler()
Return the error handler for this Digester. |
javax.xml.parsers.SAXParser |
getParser()
Return the SAXParser we will use to parse the input stream. |
protected java.util.List |
getRules(java.lang.String match)
Return the set of rules that apply to the specified match position. |
boolean |
getValidating()
Return the validating parser flag. |
void |
ignorableWhitespace(char[] buffer,
int start,
int len)
Process notification of ignorable whitespace received from the body of an XML element. |
void |
log(java.lang.String message)
Log a message to the log writer associated with this context. |
void |
log(java.lang.String message,
java.lang.Throwable exception)
Log a message and associated exception to the log writer associated with this context. |
void |
notationDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Receive notification of a notation declaration event. |
java.lang.Object |
parse(java.io.File file)
Parse the content of the specified file using this Digester. |
java.lang.Object |
parse(org.xml.sax.InputSource input)
Parse the content of the specified input source using this Digester. |
java.lang.Object |
parse(java.io.InputStream input)
Parse the content of the specified input stream using this Digester. |
java.lang.Object |
parse(java.lang.String uri)
Parse the content of the specified URI using this Digester. |
java.lang.Object |
peek()
Return the top object on the stack without removing it. |
java.lang.Object |
peek(int n)
Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the bottom element. |
java.lang.Object |
pop()
Pop the top object off of the stack, and return it. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Process notification of a processing instruction that was encountered. |
void |
push(java.lang.Object object)
Push a new object onto the top of the object stack. |
void |
register(java.lang.String publicId,
java.lang.String dtdURL)
Register the specified DTD URL for the specified public identifier. |
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Resolve the requested external entity. |
void |
setDebug(int debug)
Set the debugging detail level of this Digester. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
Set the document locator associated with our parser. |
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Set the error handler for this Digester. |
void |
setValidating(boolean validating)
Set the validating parser flag. |
void |
startDocument()
Process notification of the beginning of the document being reached. |
void |
startElement(java.lang.String name,
org.xml.sax.AttributeList list)
Process notification of the start of an XML element being reached. |
void |
unparsedEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String notation)
Receive notification of an unparsed entity declaration event. |
void |
warning(org.xml.sax.SAXParseException exception)
Forward notification of a parse warning to the application supplied error handler (if any). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
bodyText
protected java.lang.StringBuffer bodyText
- The body text of the current element.
bodyTexts
protected ArrayStack bodyTexts
- The stack of body text string buffers for surrounding elements.
debug
protected int debug
- The debugging detail level of this component.
dtds
protected java.util.HashMap dtds
- The URLs of DTDs that have been registered, keyed by the public identifier that corresponds.
errorHandler
protected org.xml.sax.ErrorHandler errorHandler
- The application-supplied error handler that is notified when parsing warnings, errors, or
fatal errors occur.
locator
protected org.xml.sax.Locator locator
- The Locator associated with our parser.
match
protected java.lang.String match
- The current match pattern for nested element processing.
parser
protected javax.xml.parsers.SAXParser parser
- The SAXParser we will use to parse the input stream.
root
protected java.lang.Object root
- The "root" element of the stack (in other words, the last object that was popped.
rules
protected java.util.HashMap rules
- The set of Rules that have been registered with this Digester. The key is the matching pattern
against the current element stack, and the value is a List containing the Rules for that
pattern, in the order that they were registered.
stack
protected ArrayStack stack
- The object stack being constructed.
validating
protected boolean validating
- Do we want to use a validating parser?
| Constructor Detail |
Digester
public Digester()
- Construct a new Digester with default properties.
| Method Detail |
getCount
public int getCount()
- Return the current depth of the element stack.
getDebug
public int getDebug()
- Return the debugging detail level of this Digester.
setDebug
public void setDebug(int debug)
- Set the debugging detail level of this Digester.
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
- Return the error handler for this Digester.
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
- Set the error handler for this Digester.
getParser
public javax.xml.parsers.SAXParser getParser()
- Return the SAXParser we will use to parse the input stream. If there is a problem creating the
parser, return
null.
getValidating
public boolean getValidating()
- Return the validating parser flag.
setValidating
public void setValidating(boolean validating)
- Set the validating parser flag. This must be called before
parse()is called the first time.
characters
public void characters(char[] buffer,
int start,
int length)
throws org.xml.sax.SAXException
- Process notification of character data received from the body of an XML element.
endDocument
public void endDocument()
throws org.xml.sax.SAXException
- Process notification of the end of the document being reached.
endElement
public void endElement(java.lang.String name) throws org.xml.sax.SAXException
- Process notification of the end of an XML element being reached.
ignorableWhitespace
public void ignorableWhitespace(char[] buffer,
int start,
int len)
throws org.xml.sax.SAXException
- Process notification of ignorable whitespace received from the body of an XML element.
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
- Process notification of a processing instruction that was encountered.
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
- Set the document locator associated with our parser.
startDocument
public void startDocument()
throws org.xml.sax.SAXException
- Process notification of the beginning of the document being reached.
startElement
public void startElement(java.lang.String name, org.xml.sax.AttributeList list) throws org.xml.sax.SAXException
- Process notification of the start of an XML element being reached.
notationDecl
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
- Receive notification of a notation declaration event.
unparsedEntityDecl
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notation)
- Receive notification of an unparsed entity declaration event.
resolveEntity
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
- Resolve the requested external entity.
error
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
- Forward notification of a parsing error to the application supplied error handler (if any).
fatalError
public void fatalError(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
- Forward notification of a fatal parsing error to the application supplied error handler (if
any).
warning
public void warning(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
- Forward notification of a parse warning to the application supplied error handler (if any).
log
public void log(java.lang.String message)
- Log a message to the log writer associated with this context.
log
public void log(java.lang.String message, java.lang.Throwable exception)
- Log a message and associated exception to the log writer associated with this context.
parse
public java.lang.Object parse(java.io.File file) throws java.io.IOException, org.xml.sax.SAXException
- Parse the content of the specified file using this Digester. Returns the root element from the
object stack (if any).
parse
public java.lang.Object parse(org.xml.sax.InputSource input) throws java.io.IOException, org.xml.sax.SAXException
- Parse the content of the specified input source using this Digester. Returns the root element
from the object stack (if any).
parse
public java.lang.Object parse(java.io.InputStream input) throws java.io.IOException, org.xml.sax.SAXException
- Parse the content of the specified input stream using this Digester. Returns the root element
from the object stack (if any).
parse
public java.lang.Object parse(java.lang.String uri) throws java.io.IOException, org.xml.sax.SAXException
- Parse the content of the specified URI using this Digester. Returns the root element from the
object stack (if any).
register
public void register(java.lang.String publicId, java.lang.String dtdURL)
- Register the specified DTD URL for the specified public identifier. This must be called before
the first call to
parse().
addRule
public void addRule(java.lang.String pattern, Rule rule)
- Register a new Rule matching the specified pattern.
addRuleForAllPrefixes
public void addRuleForAllPrefixes(java.lang.String[] prefixes, java.lang.String suffix, Rule rule)
addCallMethod
public void addCallMethod(java.lang.String pattern, java.lang.String methodName, int paramCount)
- Add an "call method" rule for the specified parameters.
addCallMethod
public void addCallMethod(java.lang.String pattern, java.lang.String methodName, int paramCount, java.lang.String[] paramTypes)
- Add an "call method" rule for the specified parameters.
addCallMethod
public void addCallMethod(java.lang.String pattern, java.lang.String methodName, int paramCount, java.lang.Class[] paramTypes)
- Add an "call method" rule for the specified parameters.
addCallParam
public void addCallParam(java.lang.String pattern, int paramIndex)
- Add a "call parameter" rule for the specified parameters.
addCallParam
public void addCallParam(java.lang.String pattern, int paramIndex, java.lang.String attributeName)
- Add a "call parameter" rule for the specified parameters.
addObjectCreate
public void addObjectCreate(java.lang.String pattern, java.lang.String className)
- Add an "object create" rule for the specified parameters.
addObjectCreate
public void addObjectCreate(java.lang.String pattern, java.lang.String className, java.lang.String attributeName)
- Add an "object create" rule for the specified parameters.
addSetNext
public void addSetNext(java.lang.String pattern, java.lang.String methodName)
- Add a "set next" rule for the specified parameters.
addSetNext
public void addSetNext(java.lang.String pattern, java.lang.String methodName, java.lang.String paramType)
- Add a "set next" rule for the specified parameters.
addSetProperties
public void addSetProperties(java.lang.String pattern)
- Add a "set properties" rule for the specified parameters.
addSetProperty
public void addSetProperty(java.lang.String pattern, java.lang.String name, java.lang.String value)
- Add a "set property" rule for the specified parameters.
addSetTop
public void addSetTop(java.lang.String pattern, java.lang.String methodName)
- Add a "set top" rule for the specified parameters.
addSetTop
public void addSetTop(java.lang.String pattern, java.lang.String methodName, java.lang.String paramType)
- Add a "set top" rule for the specified parameters.
clear
public void clear()
- Clear the current contents of the object stack.
peek
public java.lang.Object peek()
- Return the top object on the stack without removing it. If there are no objects on the stack,
return
null.
peek
public java.lang.Object peek(int n)
- Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the
bottom element. If the specified index is out of range, return
null.
pop
public java.lang.Object pop()
- Pop the top object off of the stack, and return it. If there are no objects on the stack,
return
null.
push
public void push(java.lang.Object object)
- Push a new object onto the top of the object stack.
getRules
protected java.util.List getRules(java.lang.String match)
- Return the set of rules that apply to the specified match position. The selected rules are
those that match exactly, or those rules that specify a suffix match and the tail of the rule
matches the current match position. Exact matches have precedence over suffix matches, then
(among suffix matches) the longest match is preferred.
|
|||||||||
| Home >> All >> org >> cantaloop >> tools >> [ digester overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC