Class Digester
- All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
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.
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.
A Digester instance should not be used for parsing more than one input document. The problem is that the Digester class has quite a few member variables whose values "evolve" as SAX events are received during a parse. When reusing the Digester instance, all these members must be reset back to their initial states before the second parse begins. The "clear()" method makes a stab at resetting these, but it is actually rather a difficult problem. If you are determined to reuse Digester instances, then at the least you should call the clear() method before each parse, and must call it if the Digester parse terminates due to an exception during a parse.
LEGACY IMPLEMENTATION NOTE - When using the legacy XML
schema support (instead of using the Schema class), 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 work with the legacy XML schema support.
This package was inspired by the XmlMapper class that was
part of Tomcat 3.0 and 3.1, but is organized somewhat differently.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBufferThe body text of the current element.protected Stack<StringBuffer> The stack of body text string buffers for surrounding elements.protected ClassLoaderThe class loader to use for instantiating application objects.protected booleanHas this Digester been configured yet.protected EntityResolverThe EntityResolver used by the SAX parser.The URLs of entityValidator that have been registered, keyed by the public identifier that corresponds.protected ErrorHandlerThe application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur.protected SAXParserFactoryThe SAXParserFactory that is created the first time we need it.protected List<InputSource> ListofInputSourceinstances created by acreateInputSourceFromURL()method call.protected StringDeprecated.protected LocatorThe Locator associated with our parser.protected org.apache.commons.logging.LogThe Log to which most logging calls will be made.protected StringThe current match pattern for nested element processing.Stack whose elements are List objects, each containing a list of Rule objects as returned from Rules.getMatch().protected booleanDo we want a "namespace aware" parser.Registered namespaces we are currently processing.The parameters stack being utilized by CallMethodRule and CallParamRule rules.protected SAXParserThe SAXParser we will use to parse the input stream.protected StringThe public identifier of the DTD we are currently parsing under (if any).protected XMLReaderThe XMLReader used to parse digester rules.protected ObjectThe "root" element of the stack (in other words, the last object that was popped.protected RulesTheRulesimplementation containing our collection ofRuleinstances and associated matching policy.protected org.apache.commons.logging.LogThe Log to which all SAX event related logging calls will be made.protected SchemaThe XML schema to use for validating an XML instance.protected StringDeprecated.UseSchemasupport instead.protected StringDeprecated.UseSchemasupport instead.The object stack being constructed.protected SubstitutorAn optional class that substitutes values in attributes and body text.protected booleanDo we want to use the Context ClassLoader when loading classes for instantiating new objects.protected booleanDo we want to use a validating parser.protected static final StringThe schema language supported.protected booleanDo we want a "XInclude aware" parser. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBeanPropertySetter(String pattern) Add a "bean property setter" rule for the specified parameters.voidaddBeanPropertySetter(String pattern, String propertyName) Add a "bean property setter" rule for the specified parameters.voidaddCallMethod(String pattern, String methodName) Add an "call method" rule for a method which accepts no arguments.voidaddCallMethod(String pattern, String methodName, int paramCount) Add an "call method" rule for the specified parameters.voidaddCallMethod(String pattern, String methodName, int paramCount, Class<?>[] paramTypes) Add an "call method" rule for the specified parameters.voidaddCallMethod(String pattern, String methodName, int paramCount, String[] paramTypes) Add an "call method" rule for the specified parameters.voidaddCallParam(String pattern, int paramIndex) Add a "call parameter" rule for the specified parameters.voidaddCallParam(String pattern, int paramIndex, boolean fromStack) Add a "call parameter" rule.voidaddCallParam(String pattern, int paramIndex, int stackIndex) Add a "call parameter" rule that sets a parameter from the stack.voidaddCallParam(String pattern, int paramIndex, String attributeName) Add a "call parameter" rule for the specified parameters.voidaddCallParamPath(String pattern, int paramIndex) Add a "call parameter" rule that sets a parameter from the currentDigestermatching path.voidaddFactoryCreate(String pattern, Class<?> clazz) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, Class<?> clazz, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, Class<?> clazz, String attributeName) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, Class<?> clazz, String attributeName, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, String className) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, String className, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, String className, String attributeName) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, String className, String attributeName, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, ObjectCreationFactory creationFactory) Add a "factory create" rule for the specified parameters.voidaddFactoryCreate(String pattern, ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.voidaddObjectCreate(String pattern, Class<?> clazz) Add an "object create" rule for the specified parameters.voidaddObjectCreate(String pattern, String className) Add an "object create" rule for the specified parameters.voidaddObjectCreate(String pattern, String attributeName, Class<?> clazz) Add an "object create" rule for the specified parameters.voidaddObjectCreate(String pattern, String className, String attributeName) Add an "object create" rule for the specified parameters.voidaddObjectParam(String pattern, int paramIndex, Object paramObj) Add a "call parameter" rule that sets a parameter from a caller-provided object.voidRegister a new Rule matching the specified pattern.voidaddRuleSet(RuleSet ruleSet) Register a set of Rule instances defined in a RuleSet.voidaddSetNestedProperties(String pattern) Adds anSetNestedPropertiesRule.voidaddSetNestedProperties(String pattern, String[] elementNames, String[] propertyNames) Adds anSetNestedPropertiesRule.voidaddSetNestedProperties(String pattern, String elementName, String propertyName) Adds anSetNestedPropertiesRule.voidaddSetNext(String pattern, String methodName) Add a "set next" rule for the specified parameters.voidaddSetNext(String pattern, String methodName, String paramType) Add a "set next" rule for the specified parameters.voidaddSetProperties(String pattern) Add a "set properties" rule for the specified parameters.voidaddSetProperties(String pattern, String[] attributeNames, String[] propertyNames) Add a "set properties" rule with overridden parameters.voidaddSetProperties(String pattern, String attributeName, String propertyName) Add a "set properties" rule with a single overridden parameter.voidaddSetProperty(String pattern, String name, String value) Add a "set property" rule for the specified parameters.voidaddSetRoot(String pattern, String methodName) AddSetRootRulewith the specified parameters.voidaddSetRoot(String pattern, String methodName, String paramType) AddSetRootRulewith the specified parameters.voidAdd a "set top" rule for the specified parameters.voidAdd a "set top" rule for the specified parameters.voidcharacters(char[] buffer, int start, int length) Process notification of character data received from the body of an XML element.protected voidcleanup()Clean up allocated resources after parsing is complete.voidclear()Clear the current contents of the default object stack, the param stack, all named stacks, and other internal variables.protected voidProvide a hook for lazy configuration of thisDigesterinstance.Convenience method that creates anInputSourcefrom the string version of a URL.Given a URL, return an InputSource that reads from that URL.Create a SAX exception which also understands about the location in the digester file where the exception occurscreateSAXException(String message) Create a SAX exception which also understands about the location in the digester file where the exception occurscreateSAXException(String message, Exception e) Create a SAX exception which also understands about the location in the digester file where the exception occursvoidProcess notification of the end of the document being reached.voidendElement(String namespaceURI, String localName, String qName) Process notification of the end of an XML element being reached.voidendPrefixMapping(String prefix) Process notification that a namespace prefix is going out of scope.voiderror(SAXParseException exception) Forward notification of a parsing error to the application supplied error handler (if any).voidfatalError(SAXParseException exception) Forward notification of a fatal parsing error to the application supplied error handler (if any).findNamespaceURI(String prefix) Return the currently mapped namespace URI for the specified prefix, if any; otherwise returnnull.Return the class loader to be used for instantiating application objects when required.intgetCount()Return the current depth of the element stack.Return the name of the XML element that is currently being processed.Get the most current namespaces for all prefixes.intgetDebug()Deprecated.This method now always returns 0.Gets the document locator associated with our parser.Return the Entity Resolver used by the SAX parser.Return the error handler for this Digester.Return the SAXParserFactory we will use, creating one if necessary.booleangetFeature(String feature) Returns a flag indicating whether the requested feature is supported by the underlying implementation oforg.xml.sax.XMLReader.org.apache.commons.logging.LogReturn the current Logger associated with this instance of the DigestergetMatch()Return the current rule match pathbooleanReturn the "namespace aware" flag for parsers we create.Return the SAXParser we will use to parse the input stream.getProperty(String property) Return the current value of the specified property for the underlyingXMLReaderimplementation.Return the public identifier of the DTD we are currently parsing under, if any.Deprecated.Use getXMLReader() instead, which can throw a SAXException if the reader cannot be instantiatedgetRoot()Returns the root element of the tree of objects created as a result of applying the rule objects to the input XML.Return the namespace URI that will be applied to all subsequently addedRuleobjects.getRules()Return theRulesimplementation object containing our rules collection and associated matching policy.org.apache.commons.logging.LogGets the logger used for logging SAX-related information.Deprecated.UseSchemafor validation instead.Deprecated.UseSchemafor validation instead.See setStackAction.Gets theSubstitutorused to convert attributes and body text.booleanReturn the boolean as to whether the context classloader should be used.booleanReturn the validating parser flag.booleanReturn the XInclude-aware flag for parsers we create.Return the XMLReader to be used for parsing the input document.Return the XML Schema used when parsing.voidignorableWhitespace(char[] buffer, int start, int len) Process notification of ignorable whitespace received from the body of an XML element.protected voidProvides a hook for lazy initialization of thisDigesterinstance.booleanIs the stack with the given name empty?voidDeprecated.Call getLogger() and use it's logging methodsvoidDeprecated.Call getLogger() and use it's logging methodsvoidnotationDecl(String name, String publicId, String systemId) Receive notification of a notation declaration event.Parse the content of the specified file using this Digester.parse(InputStream input) Parse the content of the specified input stream using this Digester.Parse the content of the specified reader using this Digester.Parse the content of the specified URI using this Digester.Parse the content of the specified URL using this Digester.parse(InputSource input) Parse the content of the specified input source using this Digester.peek()Return the top object on the stack without removing it.peek(int n) Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the bottom element.Gets the top object from the stack with the given name.Gets the top object from the stack with the given name.Return the top object on the parameters stack without removing it.peekParams(int n) Return the n'th object down the parameters stack, where 0 is the top element and [getCount()-1] is the bottom element.pop()Pop the top object off of the stack, and return it.Pops (gets and removes) the top object from the stack with the given name.Pop the top object off of the parameters stack, and return it.voidprocessingInstruction(String target, String data) Process notification of a processing instruction that was encountered.voidPush a new object onto the top of the object stack.voidPushes the given object onto the stack with the given name.voidpushParams(Object object) Push a new object onto the top of the parameters stack.voidConvenience method that registers the string version of an entity URL instead of a URL version.voidRegister the specified DTD URL for the specified public identifier.voidThis method allows the "root" variable to be reset to null.resolveEntity(String publicId, String systemId) Resolve the requested external entity.voidsetClassLoader(ClassLoader classLoader) Set the class loader to be used for instantiating application objects when required.voidsetCustomContentHandler(ContentHandler handler) Redirects (or cancels redirecting) of SAX ContentHandler events to an external object.voidsetDebug(int debug) Deprecated.This method now has no effect at all.voidsetDocumentLocator(Locator locator) Sets the document locator associated with our parser.voidsetEntityResolver(EntityResolver entityResolver) Set theEntityResolverused by SAX when resolving public id and system id.voidsetErrorHandler(ErrorHandler errorHandler) Set the error handler for this Digester.voidsetFeature(String feature, boolean value) Sets a flag indicating whether the requested feature is supported by the underlying implementation oforg.xml.sax.XMLReader.voidsetLogger(org.apache.commons.logging.Log log) Set the current logger for this Digester.voidsetNamespaceAware(boolean namespaceAware) Set the "namespace aware" flag for parsers we create.voidsetProperty(String property, Object value) Set the current value of the specified property for the underlyingXMLReaderimplementation.voidsetPublicId(String publicId) Set the publid id of the current file being parse.voidsetRuleNamespaceURI(String ruleNamespaceURI) Set the namespace URI that will be applied to all subsequently addedRuleobjects.voidSet theRulesimplementation object containing our rules collection and associated matching policy.voidsetSAXLogger(org.apache.commons.logging.Log saxLog) Sets the logger used for logging SAX-related information.voidDeprecated.UseSchemafor validation instead.voidsetSchemaLanguage(String schemaLanguage) Deprecated.UseSchemafor validation instead.voidsetStackAction(StackAction stackAction) Define a callback object which is invoked whever an object is pushed onto a digester object stack, or popped off one.voidsetSubstitutor(Substitutor substitutor) Sets theSubstitutorto be used to convert attributes and body text.voidsetUseContextClassLoader(boolean use) Determine whether to use the Context ClassLoader (the one found by callingThread.currentThread().getContextClassLoader()) to resolve/load classes that are defined in various rules.voidsetValidating(boolean validating) Set the validating parser flag.voidsetXIncludeAware(boolean xincludeAware) Set the XInclude-aware flag for parsers we create.voidsetXMLSchema(Schema schema) Set the XML Schema to be used when parsing.voidskippedEntity(String name) Process notification of a skipped entity.voidProcess notification of the beginning of the document being reached.voidstartElement(String namespaceURI, String localName, String qName, Attributes list) Process notification of the start of an XML element being reached.voidstartPrefixMapping(String prefix, String namespaceURI) Process notification that a namespace prefix is coming in to scope.voidunparsedEntityDecl(String name, String publicId, String systemId, String notation) Receive notification of an unparsed entity declaration event.voidwarning(SAXParseException exception) Forward notification of a parse warning to the application supplied error handler (if any).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentHandler
declaration
-
Field Details
-
bodyText
The body text of the current element. -
bodyTexts
The stack of body text string buffers for surrounding elements. -
matches
Stack whose elements are List objects, each containing a list of Rule objects as returned from Rules.getMatch(). As each xml element in the input is entered, the matching rules are pushed onto this stack. After the end tag is reached, the matches are popped again. The depth of is stack is therefore exactly the same as the current "nesting" level of the input xml.- Since:
- 1.6
-
classLoader
The class loader to use for instantiating application objects. If not specified, the context class loader, or the class loader used to load Digester itself, is used, based on the value of theuseContextClassLoadervariable. -
configured
Has this Digester been configured yet. -
entityResolver
The EntityResolver used by the SAX parser. By default it use this class -
entityValidator
The URLs of entityValidator that have been registered, keyed by the public identifier that corresponds. -
errorHandler
The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur. -
factory
The SAXParserFactory that is created the first time we need it. -
JAXP_SCHEMA_LANGUAGE
Deprecated.This is now managed byParserFeatureSetterFactory -
locator
-
match
-
namespaceAware
Do we want a "namespace aware" parser. -
namespaces
Registered namespaces we are currently processing. The key is the namespace prefix that was declared in the document. The value is an Stack of the namespace URIs this prefix has been mapped to -- the top Stack element is the most current one. (This architecture is required because documents can declare nested uses of the same prefix for different Namespace URIs). -
xincludeAware
Do we want a "XInclude aware" parser. -
params
-
parser
-
publicId
-
reader
-
root
-
rules
-
schemaLanguage
Deprecated.UseSchemasupport instead.The XML schema language to use for validating an XML instance. By default this value is set toW3C_XML_SCHEMA -
schemaLocation
Deprecated.UseSchemasupport instead.The XML schema to use for validating an XML instance. -
schema
-
stack
-
useContextClassLoader
Do we want to use the Context ClassLoader when loading classes for instantiating new objects. Default isfalse. -
validating
Do we want to use a validating parser. -
log
The Log to which most logging calls will be made. -
saxLog
The Log to which all SAX event related logging calls will be made. -
W3C_XML_SCHEMA
The schema language supported. By default, we use this one.- See Also:
-
substitutor
An optional class that substitutes values in attributes and body text. This may be null and so a null check is always required before use. -
inputSources
ListofInputSourceinstances created by acreateInputSourceFromURL()method call. These represent open input streams that need to be closed to avoid resource leaks, as well as potentially locked JAR files on Windows.
-
-
Constructor Details
-
Digester
public Digester()Construct a new Digester with default properties. -
Digester
-
Digester
Construct a new Digester, allowing an XMLReader to be passed in. This allows Digester to be used in environments which are unfriendly to JAXP1.1 (such as WebLogic 6.0). Note that if you use this option you have to configure namespace and validation support yourself, as these properties only affect the SAXParser and emtpy constructor.
-
-
Method Details
-
findNamespaceURI
Return the currently mapped namespace URI for the specified prefix, if any; otherwise returnnull. These mappings come and go dynamically as the document is parsed.- Parameters:
prefix- Prefix to look up
-
getClassLoader
Return the class loader to be used for instantiating application objects when required. This is determined based upon the following rules:- The class loader set by
setClassLoader(), if any - The thread context class loader, if it exists and the
useContextClassLoaderproperty is set to true - The class loader used to load the Digester class itself.
- The class loader set by
-
setClassLoader
Set the class loader to be used for instantiating application objects when required.- Parameters:
classLoader- The new class loader to use, ornullto revert to the standard rules
-
getCount
Return the current depth of the element stack. -
getCurrentElementName
Return the name of the XML element that is currently being processed. -
getDebug
Deprecated.This method now always returns 0. Digester uses the apache jakarta commons-logging library; see the documentation for that library for more information.Return the debugging detail level of our currently enabled logger. -
setDebug
Deprecated.This method now has no effect at all. Digester uses the apache jakarta comons-logging library; see the documentation for that library for more information.Set the debugging detail level of our currently enabled logger.- Parameters:
debug- New debugging detail level (0=off, increasing integers for more detail)
-
getErrorHandler
Return the error handler for this Digester. -
setErrorHandler
Set the error handler for this Digester.- Parameters:
errorHandler- The new error handler
-
getFactory
Return the SAXParserFactory we will use, creating one if necessary. -
getFeature
public boolean getFeature(String feature) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException Returns a flag indicating whether the requested feature is supported by the underlying implementation oforg.xml.sax.XMLReader. See the saxproject website for information about the standard SAX2 feature flags.- Parameters:
feature- Name of the feature to inquire about- Throws:
ParserConfigurationException- if a parser configuration error occursSAXNotRecognizedException- if the property name is not recognizedSAXNotSupportedException- if the property name is recognized but not supported
-
setFeature
public void setFeature(String feature, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException Sets a flag indicating whether the requested feature is supported by the underlying implementation oforg.xml.sax.XMLReader. See the saxproject website for information about the standard SAX2 feature flags. In order to be effective, this method must be called before thegetParser()method is called for the first time, either directly or indirectly.- Parameters:
feature- Name of the feature to set the status forvalue- The new value for this feature- Throws:
ParserConfigurationException- if a parser configuration error occursSAXNotRecognizedException- if the property name is not recognizedSAXNotSupportedException- if the property name is recognized but not supported
-
getLogger
Return the current Logger associated with this instance of the Digester -
setLogger
Set the current logger for this Digester. -
getSAXLogger
Gets the logger used for logging SAX-related information. Note the output is finely grained.- Since:
- 1.6
-
setSAXLogger
Sets the logger used for logging SAX-related information. Note the output is finely grained.- Parameters:
saxLog- Log, not null- Since:
- 1.6
-
getMatch
-
getNamespaceAware
Return the "namespace aware" flag for parsers we create. -
setNamespaceAware
Set the "namespace aware" flag for parsers we create.- Parameters:
namespaceAware- The new "namespace aware" flag
-
getXIncludeAware
Return the XInclude-aware flag for parsers we create. XInclude functionality additionally requires namespace-awareness.- Returns:
- The XInclude-aware flag
- Since:
- 2.0
- See Also:
-
setXIncludeAware
Set the XInclude-aware flag for parsers we create. This additionally requires namespace-awareness.- Parameters:
xincludeAware- The new XInclude-aware flag- Since:
- 2.0
- See Also:
-
setPublicId
Set the publid id of the current file being parse.- Parameters:
publicId- the DTD/Schema public's id.
-
getPublicId
Return the public identifier of the DTD we are currently parsing under, if any. -
getRuleNamespaceURI
Return the namespace URI that will be applied to all subsequently addedRuleobjects. -
setRuleNamespaceURI
Set the namespace URI that will be applied to all subsequently addedRuleobjects.- Parameters:
ruleNamespaceURI- Namespace URI that must match on all subsequently added rules, ornullfor matching regardless of the current namespace URI
-
getParser
-
getProperty
public Object getProperty(String property) throws SAXNotRecognizedException, SAXNotSupportedException Return the current value of the specified property for the underlyingXMLReaderimplementation. See the saxproject website for information about the standard SAX2 properties.- Parameters:
property- Property name to be retrieved- Throws:
SAXNotRecognizedException- if the property name is not recognizedSAXNotSupportedException- if the property name is recognized but not supported
-
setProperty
public void setProperty(String property, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Set the current value of the specified property for the underlyingXMLReaderimplementation. See the saxproject website for information about the standard SAX2 properties.- Parameters:
property- Property name to be setvalue- Property value to be set- Throws:
SAXNotRecognizedException- if the property name is not recognizedSAXNotSupportedException- if the property name is recognized but not supported
-
getReader
Deprecated.Use getXMLReader() instead, which can throw a SAXException if the reader cannot be instantiatedBy setting the reader in the constructor, you can bypass JAXP and be able to use digester in Weblogic 6.0. -
getRules
-
setRules
-
getSchema
Deprecated.UseSchemafor validation instead.Return the XML Schema URI used for validating an XML instance.- See Also:
-
setSchema
Deprecated.UseSchemafor validation instead.Set the XML Schema URI used for validating the input XML.It is often desirable to force the input document to be validated against a particular schema regardless of what type the input document declares itself to be. This method allows that to be done.
Note, however, that there is no standard API for enabling this feature on the underlying SAX parser; this method therefore only works for those parsers explicitly supported by Digester's ParserFeatureSetterFactory class. If the underlying parser does not support the feature, or is not one of the supported parsers, then an exception will be thrown when getParser is called (explicitly, or implicitly via the parse method).
See also method setSchemaLanguage which allows the type of the schema specified here to be defined. By default, the schema is expected to be a W3C xml schema definition.
IMPORTANT NOTE: This functionality was never very reliable, and has been horribly broken since the 1.6 release of Digester. There are currently no plans to fix it, so you are strongly recommended to avoid using this method. Instead, create an XMLParser instance yourself, configure validation appropriately, and pass it as a parameter to the Digester constructor.
- Parameters:
schemaLocation- a URI to the schema.- See Also:
-
getSchemaLanguage
Deprecated.UseSchemafor validation instead.Return the XML Schema language used when parsing.- See Also:
-
setSchemaLanguage
Deprecated.UseSchemafor validation instead.Set the XML Schema language used when parsing. By default, we use W3C.- Parameters:
schemaLanguage- a URI to the schema language.- See Also:
-
getXMLSchema
Return the XML Schema used when parsing.- Returns:
- The
Schemainstance in use. - Since:
- 2.0
-
setXMLSchema
Set the XML Schema to be used when parsing.- Parameters:
schema- TheSchemainstance to use.- Since:
- 2.0
-
getUseContextClassLoader
Return the boolean as to whether the context classloader should be used. -
setUseContextClassLoader
Determine whether to use the Context ClassLoader (the one found by callingThread.currentThread().getContextClassLoader()) to resolve/load classes that are defined in various rules. If not using Context ClassLoader, then the class-loading defaults to using the calling-class' ClassLoader.- Parameters:
use- determines whether to use Context ClassLoader.
-
getValidating
Return the validating parser flag. -
setValidating
Set the validating parser flag. This must be called beforeparse()is called the first time.- Parameters:
validating- The new validating parser flag.
-
getXMLReader
Return the XMLReader to be used for parsing the input document. FIX ME: there is a bug in JAXP/XERCES that prevent the use of a parser that contains a schema with a DTD.- Throws:
SAXException- if no XMLReader can be instantiated
-
getSubstitutor
Gets theSubstitutorused to convert attributes and body text.- Returns:
- Substitutor, null if not substitutions are to be performed.
-
setSubstitutor
Sets theSubstitutorto be used to convert attributes and body text.- Parameters:
substitutor- the Substitutor to be used to convert attributes and body text or null if not substitution of these values is to be performed.
-
getCustomContentHandler
-
setCustomContentHandler
Redirects (or cancels redirecting) of SAX ContentHandler events to an external object.When this object's customContentHandler is non-null, any SAX events received from the parser will simply be passed on to the specified object instead of this object handling them. This allows Rule classes to take control of the SAX event stream for a while in order to do custom processing. Such a rule should save the old value before setting a new one, and restore the old value in order to resume normal digester processing.
An example of a Rule which needs this feature is NodeCreateRule.
Note that saving the old value is probably not needed as it should always be null; a custom rule that wants to take control could only have been called when there was no custom content handler. But it seems cleaner to properly save/restore the value and maybe some day this will come in useful.
Note also that this is not quite equivalent to
digester.getXMLReader().setContentHandler(handler)
for these reasons:- Some xml parsers don't like having setContentHandler called after parsing has started. The Aelfred parser is one example.
- Directing the events via the Digester object potentially allows us to log information about those SAX events at the digester level.
- Since:
- 1.7
-
setStackAction
Define a callback object which is invoked whever an object is pushed onto a digester object stack, or popped off one.- Since:
- 1.8
-
getStackAction
-
getCurrentNamespaces
Get the most current namespaces for all prefixes.- Returns:
- Map A map with namespace prefixes as keys and most current namespace URIs for the corresponding prefixes as values
- Since:
- 1.8
-
characters
Process notification of character data received from the body of an XML element.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
buffer- The characters from the XML documentstart- Starting offset into the bufferlength- Number of characters from the buffer- Throws:
SAXException- if a parsing error is to be reported
-
endDocument
Process notification of the end of the document being reached.- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classDefaultHandler- Throws:
SAXException- if a parsing error is to be reported
-
endElement
Process notification of the end of an XML element being reached.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
namespaceURI- - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- - The local name (without prefix), or the empty string if Namespace processing is not being performed.qName- - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.- Throws:
SAXException- if a parsing error is to be reported
-
endPrefixMapping
Process notification that a namespace prefix is going out of scope.- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classDefaultHandler- Parameters:
prefix- Prefix that is going out of scope- Throws:
SAXException- if a parsing error is to be reported
-
ignorableWhitespace
Process notification of ignorable whitespace received from the body of an XML element.- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Parameters:
buffer- The characters from the XML documentstart- Starting offset into the bufferlen- Number of characters from the buffer- Throws:
SAXException- if a parsing error is to be reported
-
processingInstruction
Process notification of a processing instruction that was encountered.- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Parameters:
target- The processing instruction targetdata- The processing instruction data (if any)- Throws:
SAXException- if a parsing error is to be reported
-
getDocumentLocator
Gets the document locator associated with our parser.- Returns:
- the Locator supplied by the document parser
-
setDocumentLocator
Sets the document locator associated with our parser.- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler- Parameters:
locator- The new locator
-
skippedEntity
Process notification of a skipped entity.- Specified by:
skippedEntityin interfaceContentHandler- Overrides:
skippedEntityin classDefaultHandler- Parameters:
name- Name of the skipped entity- Throws:
SAXException- if a parsing error is to be reported
-
startDocument
Process notification of the beginning of the document being reached.- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classDefaultHandler- Throws:
SAXException- if a parsing error is to be reported
-
startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes list) throws SAXException Process notification of the start of an XML element being reached.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
namespaceURI- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.qName- The qualified name (with prefix), or the empty string if qualified names are not available.\list- The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.- Throws:
SAXException- if a parsing error is to be reported
-
startPrefixMapping
Process notification that a namespace prefix is coming in to scope.- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classDefaultHandler- Parameters:
prefix- Prefix that is being declarednamespaceURI- Corresponding namespace URI being mapped to- Throws:
SAXException- if a parsing error is to be reported
-
notationDecl
Receive notification of a notation declaration event.- Specified by:
notationDeclin interfaceDTDHandler- Overrides:
notationDeclin classDefaultHandler- Parameters:
name- The notation namepublicId- The public identifier (if any)systemId- The system identifier (if any)
-
unparsedEntityDecl
Receive notification of an unparsed entity declaration event.- Specified by:
unparsedEntityDeclin interfaceDTDHandler- Overrides:
unparsedEntityDeclin classDefaultHandler- Parameters:
name- The unparsed entity namepublicId- The public identifier (if any)systemId- The system identifier (if any)notation- The name of the associated notation
-
setEntityResolver
Set theEntityResolverused by SAX when resolving public id and system id. This must be called before the first call toparse().- Parameters:
entityResolver- a class that implement theEntityResolverinterface.
-
getEntityResolver
Return the Entity Resolver used by the SAX parser.- Returns:
- Return the Entity Resolver used by the SAX parser.
-
resolveEntity
Resolve the requested external entity.- Specified by:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Parameters:
publicId- The public identifier of the entity being referencedsystemId- The system identifier of the entity being referenced- Throws:
SAXException- if a parsing exception occurs
-
error
Forward notification of a parsing error to the application supplied error handler (if any).- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Parameters:
exception- The error information- Throws:
SAXException- if a parsing exception occurs
-
fatalError
Forward notification of a fatal parsing error to the application supplied error handler (if any).- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Parameters:
exception- The fatal error information- Throws:
SAXException- if a parsing exception occurs
-
warning
Forward notification of a parse warning to the application supplied error handler (if any).- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Parameters:
exception- The warning information- Throws:
SAXException- if a parsing exception occurs
-
log
Deprecated.Call getLogger() and use it's logging methodsLog a message to our associated logger.- Parameters:
message- The message to be logged
-
log
Deprecated.Call getLogger() and use it's logging methodsLog a message and exception to our associated logger.- Parameters:
message- The message to be logged
-
parse
Parse the content of the specified file using this Digester. Returns the root element from the object stack (if any).- Parameters:
file- File containing the XML data to be parsed- Throws:
IOException- if an input/output error occursSAXException- if a parsing exception occurs
-
parse
Parse the content of the specified input source using this Digester. Returns the root element from the object stack (if any).- Parameters:
input- Input source containing the XML data to be parsed- Throws:
IOException- if an input/output error occursSAXException- if a parsing exception occurs
-
parse
Parse the content of the specified input stream using this Digester. Returns the root element from the object stack (if any).- Parameters:
input- Input stream containing the XML data to be parsed- Throws:
IOException- if an input/output error occursSAXException- if a parsing exception occurs
-
parse
Parse the content of the specified reader using this Digester. Returns the root element from the object stack (if any).- Parameters:
reader- Reader containing the XML data to be parsed- Throws:
IOException- if an input/output error occursSAXException- if a parsing exception occurs
-
parse
Parse the content of the specified URI using this Digester. Returns the root element from the object stack (if any).- Parameters:
uri- URI containing the XML data to be parsed- Throws:
IOException- if an input/output error occursSAXException- if a parsing exception occurs
-
parse
Parse the content of the specified URL using this Digester. Returns the root element from the object stack (if any).- Parameters:
url- URL containing the XML data to be parsed- Throws:
IOException- if an input/output error occursSAXException- if a parsing exception occurs- Since:
- 1.8
-
register
Register the specified DTD URL for the specified public identifier. This must be called before the first call to
parse().Digestercontains an internalEntityResolverimplementation. This mapsPUBLICID's to URLs (from which the resource will be loaded). A common use case for this method is to register local URLs (possibly computed at runtime by a classloader) for DTDs. This allows the performance advantage of using a local version without having to ensure everySYSTEMURI on every processed xml document is local. This implementation provides only basic functionality. If more sophisticated features are required, usingsetEntityResolver(EntityResolver)to set a custom resolver is recommended.Note: This method will have no effect when a custom
EntityResolverhas been set. (Setting a customEntityResolveroverrides the internal implementation.)- Parameters:
publicId- Public identifier of the DTD to be resolvedentityURL- The URL to use for reading this DTD- Since:
- 1.8
-
register
-
createInputSourceFromURL
Given a URL, return an InputSource that reads from that URL.Ideally this function would not be needed and code could just use
new InputSource(entityURL). Unfortunately it appears that when the entityURL points to a file within a jar archive a caching mechanism inside the InputSource implementation causes a file-handle to the jar file to remain open. On Windows systems this then causes the jar archive file to be locked on disk ("in use") which makes it impossible to delete the jar file - and that really stuffs up "undeploy" in webapps in particular.In JDK1.4 and later, Apache XercesJ is used as the xml parser. The InputSource object provided is converted into an XMLInputSource, and eventually passed to an instance of XMLDocumentScannerImpl to specify the source data to be converted into tokens for the rest of the XMLReader code to handle. XMLDocumentScannerImpl calls fEntityManager.startDocumentEntity(source), where fEntityManager is declared in ancestor class XMLScanner to be an XMLEntityManager. In that class, if the input source stream is null, then:
URL location = new URL(expandedSystemId); URLConnection connect = location.openConnection(); if (connect instanceof HttpURLConnection) { setHttpProperties(connect,xmlInputSource); } stream = connect.getInputStream();This method pretty much duplicates the standard behaviour, except that it calls URLConnection.setUseCaches(false) before opening the connection.- Throws:
MalformedURLExceptionIOException- Since:
- 1.8
-
createInputSourceFromURL
Convenience method that creates an
InputSourcefrom the string version of a URL.- Parameters:
url- URL for which to create anInputSource- Throws:
MalformedURLExceptionIOException- Since:
- 1.8
-
addRule
-
addRuleSet
Register a set of Rule instances defined in a RuleSet.- Parameters:
ruleSet- The RuleSet instance to configure from
-
addBeanPropertySetter
Add a "bean property setter" rule for the specified parameters.- Parameters:
pattern- Element matching pattern- See Also:
-
addBeanPropertySetter
Add a "bean property setter" rule for the specified parameters.- Parameters:
pattern- Element matching patternpropertyName- Name of property to set- See Also:
-
addCallMethod
Add an "call method" rule for a method which accepts no arguments.- Parameters:
pattern- Element matching patternmethodName- Method name to be called- See Also:
-
addCallMethod
Add an "call method" rule for the specified parameters.- Parameters:
pattern- Element matching patternmethodName- Method name to be calledparamCount- Number of expected parameters (or zero for a single parameter from the body of this element)- See Also:
-
addCallMethod
Add an "call method" rule for the specified parameters. IfparamCountis set to zero the rule will use the body of the matched element as the single argument of the method, unlessparamTypesis null or empty, in this case the rule will call the specified method with no arguments.- Parameters:
pattern- Element matching patternmethodName- Method name to be calledparamCount- Number of expected parameters (or zero for a single parameter from the body of this element)paramTypes- Set of Java class names for the types of the expected parameters (if you wish to use a primitive type, specify the corresonding Java wrapper class instead, such asjava.lang.Booleanfor abooleanparameter)- See Also:
-
addCallMethod
Add an "call method" rule for the specified parameters. IfparamCountis set to zero the rule will use the body of the matched element as the single argument of the method, unlessparamTypesis null or empty, in this case the rule will call the specified method with no arguments.- Parameters:
pattern- Element matching patternmethodName- Method name to be calledparamCount- Number of expected parameters (or zero for a single parameter from the body of this element)paramTypes- The Java class names of the arguments (if you wish to use a primitive type, specify the corresonding Java wrapper class instead, such asjava.lang.Booleanfor abooleanparameter)- See Also:
-
addCallParam
Add a "call parameter" rule for the specified parameters.- Parameters:
pattern- Element matching patternparamIndex- Zero-relative parameter index to set (from the body of this element)- See Also:
-
addCallParam
Add a "call parameter" rule for the specified parameters.- Parameters:
pattern- Element matching patternparamIndex- Zero-relative parameter index to set (from the specified attribute)attributeName- Attribute whose value is used as the parameter value- See Also:
-
addCallParam
Add a "call parameter" rule. This will either take a parameter from the stack or from the current element body text.- Parameters:
paramIndex- The zero-relative parameter numberfromStack- Should the call parameter be taken from the top of the stack?- See Also:
-
addCallParam
Add a "call parameter" rule that sets a parameter from the stack. This takes a parameter from the given position on the stack.- Parameters:
paramIndex- The zero-relative parameter numberstackIndex- set the call parameter to the stackIndex'th object down the stack, where 0 is the top of the stack, 1 the next element down and so on- See Also:
-
addCallParamPath
Add a "call parameter" rule that sets a parameter from the currentDigestermatching path. This is sometimes useful when using rules that support wildcards.- Parameters:
pattern- the pattern that this rule should matchparamIndex- The zero-relative parameter number- See Also:
-
addObjectParam
Add a "call parameter" rule that sets a parameter from a caller-provided object. This can be used to pass constants such as strings to methods; it can also be used to pass mutable objects, providing ways for objects to do things like "register" themselves with some shared object.Note that when attempting to locate a matching method to invoke, the true type of the paramObj is used, so that despite the paramObj being passed in here as type Object, the target method can declare its parameters as being the true type of the object (or some ancestor type, according to the usual type-conversion rules).
- Parameters:
paramIndex- The zero-relative parameter numberparamObj- Any arbitrary object to be passed to the target method.- Since:
- 1.6
- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.- Parameters:
pattern- Element matching patternclassName- Java class name of the object creation factory class- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.- Parameters:
pattern- Element matching patternclazz- Java class of the object creation factory class- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.- Parameters:
pattern- Element matching patternclassName- Java class name of the object creation factory classattributeName- Attribute name which, if present, overrides the value specified byclassName- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.- Parameters:
pattern- Element matching patternclazz- Java class of the object creation factory classattributeName- Attribute name which, if present, overrides the value specified byclassName- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.- Parameters:
pattern- Element matching patterncreationFactory- Previously instantiated ObjectCreationFactory to be utilized- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclassName- Java class name of the object creation factory classignoreCreateExceptions- whentrueany exceptions thrown during object creation will be ignored.- See Also:
-
addFactoryCreate
Add a "factory create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclazz- Java class of the object creation factory classignoreCreateExceptions- whentrueany exceptions thrown during object creation will be ignored.- See Also:
-
addFactoryCreate
public void addFactoryCreate(String pattern, String className, String attributeName, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclassName- Java class name of the object creation factory classattributeName- Attribute name which, if present, overrides the value specified byclassNameignoreCreateExceptions- whentrueany exceptions thrown during object creation will be ignored.- See Also:
-
addFactoryCreate
public void addFactoryCreate(String pattern, Class<?> clazz, String attributeName, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclazz- Java class of the object creation factory classattributeName- Attribute name which, if present, overrides the value specified byclassNameignoreCreateExceptions- whentrueany exceptions thrown during object creation will be ignored.- See Also:
-
addFactoryCreate
public void addFactoryCreate(String pattern, ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions) Add a "factory create" rule for the specified parameters.- Parameters:
pattern- Element matching patterncreationFactory- Previously instantiated ObjectCreationFactory to be utilizedignoreCreateExceptions- whentrueany exceptions thrown during object creation will be ignored.- See Also:
-
addObjectCreate
Add an "object create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclassName- Java class name to be created- See Also:
-
addObjectCreate
Add an "object create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclazz- Java class to be created- See Also:
-
addObjectCreate
Add an "object create" rule for the specified parameters.- Parameters:
pattern- Element matching patternclassName- Default Java class name to be createdattributeName- Attribute name that optionally overrides the default Java class name to be created- See Also:
-
addObjectCreate
Add an "object create" rule for the specified parameters.- Parameters:
pattern- Element matching patternattributeName- Attribute name that optionally overridesclazz- Default Java class to be created the default Java class name to be created- See Also:
-
addSetNestedProperties
Adds anSetNestedPropertiesRule.- Parameters:
pattern- register the rule with this pattern- Since:
- 1.6
-
addSetNestedProperties
Adds anSetNestedPropertiesRule.- Parameters:
pattern- register the rule with this patternelementName- elment name that a property maps topropertyName- property name of the element mapped from- Since:
- 1.6
-
addSetNestedProperties
Adds anSetNestedPropertiesRule.- Parameters:
pattern- register the rule with this patternelementNames- elment names that (in order) map to propertiespropertyNames- property names that (in order) elements are mapped to- Since:
- 1.6
-
addSetNext
Add a "set next" rule for the specified parameters.- Parameters:
pattern- Element matching patternmethodName- Method name to call on the parent element- See Also:
-
addSetNext
Add a "set next" rule for the specified parameters.- Parameters:
pattern- Element matching patternmethodName- Method name to call on the parent elementparamType- Java class name of the expected parameter type (if you wish to use a primitive type, specify the corresonding Java wrapper class instead, such asjava.lang.Booleanfor abooleanparameter)- See Also:
-
addSetRoot
AddSetRootRulewith the specified parameters.- Parameters:
pattern- Element matching patternmethodName- Method name to call on the root object- See Also:
-
addSetRoot
AddSetRootRulewith the specified parameters.- Parameters:
pattern- Element matching patternmethodName- Method name to call on the root objectparamType- Java class name of the expected parameter type- See Also:
-
addSetProperties
Add a "set properties" rule for the specified parameters.- Parameters:
pattern- Element matching pattern- See Also:
-
addSetProperties
Add a "set properties" rule with a single overridden parameter. SeeSetPropertiesRule(String attributeName, String propertyName)- Parameters:
pattern- Element matching patternattributeName- map this attributepropertyName- to this property- See Also:
-
addSetProperties
Add a "set properties" rule with overridden parameters. SeeSetPropertiesRule(String [] attributeNames, String [] propertyNames)- Parameters:
pattern- Element matching patternattributeNames- names of attributes with custom mappingspropertyNames- property names these attributes map to- See Also:
-
addSetProperty
Add a "set property" rule for the specified parameters.- Parameters:
pattern- Element matching patternname- Attribute name containing the property name to be setvalue- Attribute name containing the property value to set- See Also:
-
addSetTop
-
addSetTop
Add a "set top" rule for the specified parameters.- Parameters:
pattern- Element matching patternmethodName- Method name to call on the parent elementparamType- Java class name of the expected parameter type (if you wish to use a primitive type, specify the corresonding Java wrapper class instead, such asjava.lang.Booleanfor abooleanparameter)- See Also:
-
clear
Clear the current contents of the default object stack, the param stack, all named stacks, and other internal variables.Calling this method might allow another document of the same type to be correctly parsed. However this method was not intended for this purpose (just to tidy up memory usage). In general, a separate Digester object should be created for each document to be parsed.
Note that this method is called automatically after a document has been successfully parsed by a Digester instance. However it is not invoked automatically when a parse fails, so when reusing a Digester instance (which is not recommended) this method must be called manually after a parse failure.
-
peek
-
peek
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, returnnull.- Parameters:
n- Index of the desired element, where 0 is the top of the stack, 1 is the next element down, and so on.
-
pop
-
push
-
push
Pushes the given object onto the stack with the given name. If no stack already exists with the given name then one will be created.- Parameters:
stackName- the name of the stack onto which the object should be pushedvalue- the Object to be pushed onto the named stack.- Since:
- 1.6
-
pop
Pops (gets and removes) the top object from the stack with the given name.
Note: a stack is considered empty if no objects have been pushed onto it yet.
- Parameters:
stackName- the name of the stack from which the top value is to be popped.- Returns:
- the top
Objecton the stack or or null if the stack is either empty or has not been created yet - Throws:
EmptyStackException- if the named stack is empty- Since:
- 1.6
-
peek
Gets the top object from the stack with the given name. This method does not remove the object from the stack.
Note: a stack is considered empty if no objects have been pushed onto it yet.
- Parameters:
stackName- the name of the stack to be peeked- Returns:
- the top
Objecton the stack or null if the stack is either empty or has not been created yet - Throws:
EmptyStackException- if the named stack is empty- Since:
- 1.6
-
peek
Gets the top object from the stack with the given name. This method does not remove the object from the stack.
Note: a stack is considered empty if no objects have been pushed onto it yet.
- Parameters:
stackName- the name of the stack to be peekedn- Index of the desired element, where 0 is the top of the stack, 1 is the next element down, and so on.- Returns:
- the specified
Objecton the stack. - Throws:
EmptyStackException- if the named stack is empty- Since:
- 1.6
-
isEmpty
-
getRoot
Returns the root element of the tree of objects created as a result of applying the rule objects to the input XML.If the digester stack was "primed" by explicitly pushing a root object onto the stack before parsing started, then that root object is returned here.
Alternatively, if a Rule which creates an object (eg ObjectCreateRule) matched the root element of the xml, then the object created will be returned here.
In other cases, the object most recently pushed onto an empty digester stack is returned. This would be a most unusual use of digester, however; one of the previous configurations is much more likely.
Note that when using one of the Digester.parse methods, the return value from the parse method is exactly the same as the return value from this method. However when the Digester is being used as a SAXContentHandler, no such return value is available; in this case, this method allows you to access the root object that has been created after parsing has completed.
- Returns:
- the root object that has been created after parsing or null if the digester has not parsed any XML yet.
-
resetRoot
This method allows the "root" variable to be reset to null.It is not considered safe for a digester instance to be reused to parse multiple xml documents. However if you are determined to do so, then you should call both clear() and resetRoot() before each parse.
- Since:
- 1.7
-
cleanup
Clean up allocated resources after parsing is complete. The default method closes input streams that have been created by Digester itself. If you override this method in a subclass, be sure to call
super.cleanup()to invoke this logic.- Since:
- 1.8
-
configure
Provide a hook for lazy configuration of this
Digesterinstance. The default implementation does nothing, but subclasses can override as needed.Note This method may be called more than once. Once only initialization code should be placed in
initialize()or the code should take responsibility by checking and setting theconfiguredflag. -
initialize
Provides a hook for lazy initialization of this
Digesterinstance. The default implementation does nothing, but subclasses can override as needed. Digester (by default) only calls this method once.Note This method will be called by
configure()only when theconfiguredflag is false. Subclasses that overrideconfigureor who setconfiguredmay find that this method may be called more than once.- Since:
- 1.6
-
peekParams
Return the top object on the parameters stack without removing it. If there are no objects on the stack, return
null.The parameters stack is used to store
CallMethodRuleparameters. Seeparams. -
peekParams
Return the n'th object down the parameters stack, where 0 is the top element and [getCount()-1] is the bottom element. If the specified index is out of range, return
null.The parameters stack is used to store
CallMethodRuleparameters. Seeparams.- Parameters:
n- Index of the desired element, where 0 is the top of the stack, 1 is the next element down, and so on.
-
popParams
-
pushParams
Push a new object onto the top of the parameters stack.
The parameters stack is used to store
CallMethodRuleparameters. Seeparams.- Parameters:
object- The new object
-
createSAXException
Create a SAX exception which also understands about the location in the digester file where the exception occurs- Returns:
- the new exception
-
createSAXException
Create a SAX exception which also understands about the location in the digester file where the exception occurs- Returns:
- the new exception
-
createSAXException
Create a SAX exception which also understands about the location in the digester file where the exception occurs- Returns:
- the new exception
-
ParserFeatureSetterFactory