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.
Implementation Note
- A bug in Xerces 2.0.2 prevents the support of XML schema. You need Xerces 2.1/2.3 and up to make this class working with XML schema
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| public static interface |
| Modifier and Type | Field and Description |
|---|---|
| protected StringBuilder | bodyText
The body text of the current element. |
| protected ArrayStack | bodyTexts
The stack of body text string buffers for surrounding elements. |
| protected ClassLoader | classLoader
The class loader to use for instantiating application objects. |
| protected StringBuilder | code
Generated code. |
| protected boolean | configured
Has this Digester been configured yet. |
| protected EntityResolver | entityResolver
The EntityResolver used by the SAX parser. |
| protected HashMap | entityValidator
The URLs of entityValidator that have been registered, keyed by the public identifier that corresponds. |
| protected ErrorHandler | errorHandler
The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur. |
| protected SAXParserFactory | factory
The SAXParserFactory that is created the first time we need it. |
| protected Map | fakeAttributes
Fake attributes map (attributes are often used for object creation). |
| private static final HashSet | |
| private static Digester. | |
| protected ArrayList | |
| protected Locator | locator
The Locator associated with our parser. |
| protected Log | log
The Log to which most logging calls will be made. |
| protected String | match
The current match pattern for nested element processing. |
| protected ArrayStack | matches
Stack whose elements are List objects, each containing a list of Rule objects as returned from Rules.getMatch(). |
| protected boolean | namespaceAware
Do we want a "namespace aware" parser. |
| protected HashMap | namespaces
Registered namespaces we are currently processing. |
| protected ArrayStack | params
The parameters stack being utilized by CallMethodRule and CallParamRule rules. |
| protected SAXParser | parser
The SAXParser we will use to parse the input stream. |
| protected static IntrospectionUtils. | |
| private static boolean | |
| protected String | publicId
The public identifier of the DTD we are currently parsing under (if any). |
| protected XMLReader | reader
The XMLReader used to parse digester rules. |
| protected Object | root
The "root" element of the stack (in other words, the last object that was popped. |
| protected Rules | rules
The |
| protected boolean | rulesValidation
Warn on missing attributes and elements. |
| protected Log | saxLog
The Log to which all SAX event related logging calls will be made. |
| protected static final StringManager | |
| protected IntrospectionUtils. | |
| protected ArrayStack | stack
The object stack being constructed. |
| protected boolean | useContextClassLoader
Do we want to use the Context ClassLoader when loading classes for instantiating new objects. |
| protected boolean | validating
Do we want to use a validating parser. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addCallMethod(String
Element matching pattern pattern, String Method name to be called methodName)Add an "call method" rule for a method which accepts no arguments. |
| public void | addCallMethod(String
Element matching pattern pattern, String Method name to be called methodName, int Number of expected parameters (or zero
for a single parameter from the body of this element) paramCount)Add an "call method" rule for the specified parameters. |
| public void | addCallParam(String
Element matching pattern pattern, int Zero-relative parameter index to set
(from the body of this element) paramIndex)Add a "call parameter" rule for the specified parameters. |
| public void | addFactoryCreate(String
Element matching pattern pattern, ObjectCreationFactory Previously instantiated ObjectCreationFactory
to be utilized creationFactory, boolean when ignoreCreateExceptions)true any exceptions thrown during
object creation will be ignored.Add a "factory create" rule for the specified parameters. |
| public static void | |
| public void | addObjectCreate(String
Element matching pattern pattern, String Java class name to be created className)Add an "object create" rule for the specified parameters. |
| public void | addObjectCreate(String
Element matching pattern pattern, String Default Java class name to be created className, String Attribute name that optionally overrides
the default Java class name to be created attributeName)Add an "object create" rule for the specified parameters. |
| public void | |
| public void | addRuleSet(RuleSet
The RuleSet instance to configure from ruleSet)Register a set of Rule instances defined in a RuleSet. |
| public void | addSetNext(String
Element matching pattern pattern, String Method name to call on the parent element methodName, String Java class name of the expected parameter type
(if you wish to use a primitive type, specify the corresponding
Java wrapper class instead, such as paramType)java.lang.Boolean
for a boolean parameter)Add a "set next" rule for the specified parameters. |
| public void | addSetProperties(String
Element matching pattern pattern)Add a "set properties" rule for the specified parameters. |
| public void | |
| public void | characters(char[]
The characters from the XML document buffer, int Starting offset into the buffer start, int Number of characters from the buffer length)Overrides org. Implements org. Process notification of character data received from the body of an XML element. |
| public void | |
| protected void | |
| public SAXException | Returns: the new exceptionThe error message message, Exception The root cause e)Create a SAX exception which also understands about the location in the digester file where the exception occurs |
| public SAXException | Returns: the new exceptionThe root cause e)Create a SAX exception which also understands about the location in the digester file where the exception occurs |
| public SAXException | Returns: the new exceptionThe error message message)Create a SAX exception which also understands about the location in the digester file where the exception occurs |
| public void | endDocument()
Overrides org. Implements org. Process notification of the end of the document being reached. |
| public void | endElement(String
- The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace processing is not
being performed. namespaceURI, String - The local name (without prefix), or the empty
string if Namespace processing is not being performed. localName, String - The qualified XML 1.0 name (with prefix), or the
empty string if qualified names are not available. qName)Overrides org. Implements org. Process notification of the end of an XML element being reached. |
| public void | |
| public void | endPrefixMapping(String
Prefix that is going out of scope prefix)Overrides org. Implements org. Process notification that a namespace prefix is going out of scope. |
| public void | error(SAXParseException
The error information exception)Overrides org. Implements org. Forward notification of a parsing error to the application supplied error handler (if any). |
| public void | fatalError(SAXParseException
The fatal error information exception)Overrides org. Implements org. Forward notification of a fatal parsing error to the application supplied error handler (if any). |
| public String | Returns: the namespace URIPrefix to look up prefix)Return the currently mapped namespace URI for the specified prefix,
if any; otherwise return |
| public ClassLoader | Returns: the classloaderReturn the class loader to be used for instantiating application objects when required. |
| public int | |
| public String | |
| public Locator | Returns: the Locator supplied by the document parserGets the document locator associated with our parser. |
| public EntityResolver | Returns: Return the Entity Resolver used by the SAX parser.Return the Entity Resolver used by the SAX parser. |
| public ErrorHandler | |
| public SAXParserFactory | Returns: the SAXParserFactory we will use, creating one if necessary.SAX parser factory method. |
| public Map | |
| public static String[] | |
| public StringBuilder | |
| public Log | |
| public String | |
| public boolean | |
| public SAXParser | Returns: the SAXParser we will use to parse the input stream. If there is a problem creating the parser, returnnull.
|
| public Object | Returns: the property valueProperty name to be retrieved property)Return the current value of the specified property for the underlying
|
| public String | |
| public Object | Returns: the root object that has been created after parsing or null if the digester has not parsed any XML yet.When the Digester is being used as a SAXContentHandler, this method allows you to access the root object that has been created after parsing. |
| public Rules | Returns: the rulesReturn the |
| public boolean | |
| public Log | Returns: the SAX loggerGets the logger used for logging SAX-related information Note the output is finely grained. |
| public boolean | Returns: the boolean as to whether the context classloader should be used.
|
| public boolean | |
| public XMLReader | Returns: the XML readerReturn the XMLReader to be used for parsing the input document. |
| public void | ignorableWhitespace(char[]
The characters from the XML document buffer, int Starting offset into the buffer start, int Number of characters from the buffer len)Overrides org. Implements org. Process notification of ignorable whitespace received from the body of an XML element. |
| public boolean | Returns: true if this is a fake attributeThe object object, String The attribute name name)Determine if an attribute is a fake attribute. |
| public static boolean | |
| public static Object | |
| public void | notationDecl(String
The notation name name, String The public identifier (if any) publicId, String The system identifier (if any) systemId)Overrides org. Implements org. Receive notification of a notation declaration event. |
| public Object | |
| public Object | Returns: the root objectInput source containing the XML data to be parsed input)Parse the content of the specified input source using this Digester. |
| public Object | Returns: the root objectInput stream containing the XML data to be parsed input)Parse the content of the specified input stream using this Digester. |
| public Object | |
| public Object | Returns: the specified objectIndex of the desired element, where 0 is the top of the stack,
1 is the next element down, and so on. n)Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the bottom element. |
| public Object | Returns: the top object on the parameters stackReturn the top object on the parameters stack without removing it. |
| public Object | |
| public Object | Returns: the top object on the parameters stackPop the top object off of the parameters stack, and return it. |
| public void | processingInstruction(String
The processing instruction target target, String The processing instruction data (if any) data)Overrides org. Implements org. Process notification of a processing instruction that was encountered. |
| public void | |
| public void | |
| public void | |
| public static void | |
| public void | |
| public InputSource | resolveEntity(String
Identifies the external entity being resolved.
Either "[dtd]" for the external subset, or a name starting
with "%" to indicate a parameter entity, or else the name of
a general entity. This is never null when invoked by a SAX2
parser. name, String The public identifier of the external entity being
referenced (normalized as required by the XML specification), or
null if none was supplied. publicId, String The URI with respect to which relative systemIDs
are interpreted. This is always an absolute URI, unless it is
null (likely because the XMLReader was given an InputSource without
one). This URI is defined by the XML specification to be the one
associated with the "<" starting the relevant declaration. baseURI, String The system identifier of the external entity
being referenced; either a relative or absolute URI.
This is never null when invoked by a SAX2 parser; only declared
entities, and any external subset, are resolved by such parsers. systemId)Overrides org. Implements org. Tells the parser to resolve the systemId against the baseURI and read the entity text from that resulting absolute URI. |
| public void | setClassLoader(ClassLoader
The new class loader to use, or classLoader)null
to revert to the standard rulesSet the class loader to be used for instantiating application objects when required. |
| public void | setDocumentLocator(Locator
The new locator locator)Overrides org. Implements org. Sets the document locator associated with our parser. |
| public void | setEntityResolver(EntityResolver
a class that implement the entityResolver)EntityResolver interface.Set the |
| public void | setErrorHandler(ErrorHandler
The new error handler errorHandler)Set the error handler for this Digester. |
| public void | setFakeAttributes(Map<Class<?>, List<String>>
The new fake attributes. fakeAttributes)Set the fake attributes. |
| public void | setFeature(String
Name of the feature to set the status for feature, boolean The new value for this feature value)Sets a flag indicating whether the requested feature is supported
by the underlying implementation of |
| public static void | |
| public void | |
| public void | |
| public void | setNamespaceAware(boolean
The new "namespace aware" flag namespaceAware)Set the "namespace aware" flag for parsers we create. |
| public static void | |
| public static void | |
| public void | setPublicId(String
the DTD/Schema public's id. publicId)Set the public id of the current file being parse. |
| public void | |
| public void | setRulesValidation(boolean
The new rules validation flag. rulesValidation)Set the rules validation flag. |
| public void | setSAXLogger(Log
Log, not null saxLog)Sets the logger used for logging SAX-related information Note the output is finely grained. |
| public void | setUseContextClassLoader(boolean
determines whether to use Context ClassLoader. use)Determine whether to use the Context ClassLoader (the one found by
calling |
| public void | |
| public void | skippedEntity(String
Name of the skipped entity name)Overrides org. Implements org. Process notification of a skipped entity. |
| public void | startDocument()
Overrides org. Implements org. Process notification of the beginning of the document being reached. |
| public void | startDTD(String
The document type name. name, String The declared public identifier for the
external DTD subset, or null if none was declared. publicId, String The declared system identifier for the
external DTD subset, or null if none was declared.
(Note that this is not resolved against the document
base URI.) systemId)Overrides org. Implements org. Report the start of DTD declarations, if any. |
| public void | startElement(String
The Namespace URI, or the empty string if the element
has no Namespace URI or if Namespace processing is not being performed. namespaceURI, String The local name (without prefix), or the empty
string if Namespace processing is not being performed. localName, String The qualified name (with prefix), or the empty
string if qualified names are not available.\ qName, Attributes The attributes attached to the element. If there are
no attributes, it shall be an empty Attributes object. list)Overrides org. Implements org. Process notification of the start of an XML element being reached. |
| public void | |
| public void | startPrefixMapping(String
Prefix that is being declared prefix, String Corresponding namespace URI being mapped to namespaceURI)Overrides org. Implements org. Process notification that a namespace prefix is coming in to scope. |
| public String | |
| public void | unparsedEntityDecl(String
The unparsed entity name name, String The public identifier (if any) publicId, String The system identifier (if any) systemId, String The name of the associated notation notation)Overrides org. Implements org. Receive notification of an unparsed entity declaration event. |
| private Attributes | updateAttributes(Attributes list)
Returns an attributes list which contains all the attributes passed in, with any text of form "${xxx}" in an attribute value replaced by the appropriate value from the system property. |
| private StringBuilder | updateBodyText(StringBuilder bodyText)
Return a new StringBuilder containing the same contents as the input buffer, except that data of form ${varname} have been replaced by the value of that var as defined in the system property. |
| public void | warning(SAXParseException
The warning information exception)Overrides org. Implements org. Forward notification of a parse warning to the application supplied error handler (if any). |