Java Doc for Digester.java in  » XML » digester » org » apache » commons » digester » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » digester » org.apache.commons.digester 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.xml.sax.helpers.DefaultHandler
      org.apache.commons.digester.Digester

All known Subclasses:   org.apache.commons.digester.rss.RSSDigester,
Digester
public class Digester extends DefaultHandler (Code)

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



Field Summary
protected  StringJAXP_SCHEMA_LANGUAGE
    
final protected static  StringW3C_XML_SCHEMA
     The schema language supported.
protected  StringBufferbodyText
     The body text of the current element.
protected  ArrayStackbodyTexts
     The stack of body text string buffers for surrounding elements.
protected  ClassLoaderclassLoader
     The class loader to use for instantiating application objects.
protected  booleanconfigured
     Has this Digester been configured yet.
protected  EntityResolverentityResolver
     The EntityResolver used by the SAX parser.
protected  HashMapentityValidator
     The URLs of entityValidator that have been registered, keyed by the public identifier that corresponds.
protected  ErrorHandlererrorHandler
     The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur.
protected  SAXParserFactoryfactory
     The SAXParserFactory that is created the first time we need it.
protected  ListinputSources
    

List of InputSource instances created by a createInputSourceFromURL() method call.

protected  Locatorlocator
     The Locator associated with our parser.
protected  Loglog
     The Log to which most logging calls will be made.
protected  Stringmatch
     The current match pattern for nested element processing.
protected  ArrayStackmatches
     Stack whose elements are List objects, each containing a list of Rule objects as returned from Rules.getMatch().
protected  booleannamespaceAware
     Do we want a "namespace aware" parser.
protected  HashMapnamespaces
     Registered namespaces we are currently processing.
protected  ArrayStackparams
     The parameters stack being utilized by CallMethodRule and CallParamRule rules.
protected  SAXParserparser
     The SAXParser we will use to parse the input stream.
protected  StringpublicId
     The public identifier of the DTD we are currently parsing under (if any).
protected  XMLReaderreader
     The XMLReader used to parse digester rules.
protected  Objectroot
     The "root" element of the stack (in other words, the last object that was popped.
protected  Rulesrules
     The Rules implementation containing our collection of Rule instances and associated matching policy.
protected  LogsaxLog
     The Log to which all SAX event related logging calls will be made.
protected  StringschemaLanguage
     The XML schema language to use for validating an XML instance.
protected  StringschemaLocation
     The XML schema to use for validating an XML instance.
protected  ArrayStackstack
     The object stack being constructed.
protected  Substitutorsubstitutor
     An optional class that substitutes values in attributes and body text.
protected  booleanuseContextClassLoader
     Do we want to use the Context ClassLoader when loading classes for instantiating new objects.
protected  booleanvalidating
     Do we want to use a validating parser.

Constructor Summary
public  Digester()
     Construct a new Digester with default properties.
public  Digester(SAXParser parser)
     Construct a new Digester, allowing a SAXParser to be passed in.
public  Digester(XMLReader reader)
     Construct a new Digester, allowing an XMLReader to be passed in.

Method Summary
public  voidaddBeanPropertySetter(String pattern)
     Add a "bean property setter" rule for the specified parameters.
public  voidaddBeanPropertySetter(String pattern, String propertyName)
     Add a "bean property setter" rule for the specified parameters.
public  voidaddCallMethod(String pattern, String methodName)
     Add an "call method" rule for a method which accepts no arguments.
public  voidaddCallMethod(String pattern, String methodName, int paramCount)
     Add an "call method" rule for the specified parameters.
public  voidaddCallMethod(String pattern, String methodName, int paramCount, String paramTypes)
     Add an "call method" rule for the specified parameters.
public  voidaddCallMethod(String pattern, String methodName, int paramCount, Class paramTypes)
     Add an "call method" rule for the specified parameters.
public  voidaddCallParam(String pattern, int paramIndex)
     Add a "call parameter" rule for the specified parameters.
public  voidaddCallParam(String pattern, int paramIndex, String attributeName)
     Add a "call parameter" rule for the specified parameters.
public  voidaddCallParam(String pattern, int paramIndex, boolean fromStack)
     Add a "call parameter" rule. This will either take a parameter from the stack or from the current element body text.
public  voidaddCallParam(String pattern, int paramIndex, int stackIndex)
     Add a "call parameter" rule that sets a parameter from the stack.
public  voidaddCallParamPath(String pattern, int paramIndex)
     Add a "call parameter" rule that sets a parameter from the current Digester matching path.
public  voidaddFactoryCreate(String pattern, String className)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, Class clazz)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, String className, String attributeName)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, Class clazz, String attributeName)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, ObjectCreationFactory creationFactory)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, String className, boolean ignoreCreateExceptions)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, Class clazz, boolean ignoreCreateExceptions)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, String className, String attributeName, boolean ignoreCreateExceptions)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, Class clazz, String attributeName, boolean ignoreCreateExceptions)
     Add a "factory create" rule for the specified parameters.
public  voidaddFactoryCreate(String pattern, ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions)
     Add a "factory create" rule for the specified parameters.
public  voidaddObjectCreate(String pattern, String className)
     Add an "object create" rule for the specified parameters.
public  voidaddObjectCreate(String pattern, Class clazz)
     Add an "object create" rule for the specified parameters.
public  voidaddObjectCreate(String pattern, String className, String attributeName)
     Add an "object create" rule for the specified parameters.
public  voidaddObjectCreate(String pattern, String attributeName, Class clazz)
     Add an "object create" rule for the specified parameters.
public  voidaddObjectParam(String pattern, int paramIndex, Object paramObj)
     Add a "call parameter" rule that sets a parameter from a caller-provided object.
public  voidaddRule(String pattern, Rule rule)
    

Register a new Rule matching the specified pattern.

public  voidaddRuleSet(RuleSet ruleSet)
     Register a set of Rule instances defined in a RuleSet.
public  voidaddSetNestedProperties(String pattern)
     Adds an SetNestedPropertiesRule .
public  voidaddSetNestedProperties(String pattern, String elementName, String propertyName)
     Adds an SetNestedPropertiesRule .
public  voidaddSetNestedProperties(String pattern, String[] elementNames, String[] propertyNames)
     Adds an SetNestedPropertiesRule .
public  voidaddSetNext(String pattern, String methodName)
     Add a "set next" rule for the specified parameters.
public  voidaddSetNext(String pattern, String methodName, String paramType)
     Add a "set next" rule for the specified parameters.
public  voidaddSetProperties(String pattern)
     Add a "set properties" rule for the specified parameters.
public  voidaddSetProperties(String pattern, String attributeName, String propertyName)
     Add a "set properties" rule with a single overridden parameter.
public  voidaddSetProperties(String pattern, String[] attributeNames, String[] propertyNames)
     Add a "set properties" rule with overridden parameters.
public  voidaddSetProperty(String pattern, String name, String value)
     Add a "set property" rule for the specified parameters.
public  voidaddSetRoot(String pattern, String methodName)
     Add SetRootRule with the specified parameters.
public  voidaddSetRoot(String pattern, String methodName, String paramType)
     Add SetRootRule with the specified parameters.
public  voidaddSetTop(String pattern, String methodName)
     Add a "set top" rule for the specified parameters.
public  voidaddSetTop(String pattern, String methodName, String paramType)
     Add a "set top" rule for the specified parameters.
public  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.

public  voidclear()
     Clear the current contents of the default object stack, the param stack, all named stacks, and other internal variables.
protected  voidconfigure()
    

Provide a hook for lazy configuration of this Digester instance.

public  InputSourcecreateInputSourceFromURL(URL url)
     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).

public  InputSourcecreateInputSourceFromURL(String url)
    
public  SAXExceptioncreateSAXException(String message, Exception e)
    
public  SAXExceptioncreateSAXException(Exception e)
    
public  SAXExceptioncreateSAXException(String message)
    
public  voidendDocument()
     Process notification of the end of the document being reached.
public  voidendElement(String namespaceURI, String localName, String qName)
     Process notification of the end of an XML element being reached.
public  voidendPrefixMapping(String prefix)
     Process notification that a namespace prefix is going out of scope.
public  voiderror(SAXParseException exception)
     Forward notification of a parsing error to the application supplied error handler (if any).
public  voidfatalError(SAXParseException exception)
     Forward notification of a fatal parsing error to the application supplied error handler (if any).
public  StringfindNamespaceURI(String prefix)
     Return the currently mapped namespace URI for the specified prefix, if any; otherwise return null.
public  ClassLoadergetClassLoader()
     Return the class loader to be used for instantiating application objects when required.
public  intgetCount()
     Return the current depth of the element stack.
public  StringgetCurrentElementName()
     Return the name of the XML element that is currently being processed.
public  MapgetCurrentNamespaces()
     Get the most current namespaces for all prefixes.
public  ContentHandlergetCustomContentHandler()
    
public  intgetDebug()
     Return the debugging detail level of our currently enabled logger.
public  LocatorgetDocumentLocator()
     Gets the document locator associated with our parser.
public  EntityResolvergetEntityResolver()
     Return the Entity Resolver used by the SAX parser.
public  ErrorHandlergetErrorHandler()
     Return the error handler for this Digester.
public  SAXParserFactorygetFactory()
     Return the SAXParserFactory we will use, creating one if necessary.
public  booleangetFeature(String feature)
     Returns a flag indicating whether the requested feature is supported by the underlying implementation of org.xml.sax.XMLReader.
public  LoggetLogger()
    
public  StringgetMatch()
    
public  booleangetNamespaceAware()
     Return the "namespace aware" flag for parsers we create.
public  SAXParsergetParser()
     Return the SAXParser we will use to parse the input stream.
public  ObjectgetProperty(String property)
     Return the current value of the specified property for the underlying XMLReader implementation.
public  StringgetPublicId()
     Return the public identifier of the DTD we are currently parsing under, if any.
public  XMLReadergetReader()
     By setting the reader in the constructor, you can bypass JAXP and be able to use digester in Weblogic 6.0.
 MapgetRegistrations()
     Return the set of DTD URL registrations, keyed by public identifier.
public  ObjectgetRoot()
     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.

public  StringgetRuleNamespaceURI()
     Return the namespace URI that will be applied to all subsequently added Rule objects.
public  RulesgetRules()
     Return the Rules implementation object containing our rules collection and associated matching policy.
 ListgetRules(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.
public  LoggetSAXLogger()
     Gets the logger used for logging SAX-related information.
public  StringgetSchema()
     Return the XML Schema URI used for validating an XML instance.
public  StringgetSchemaLanguage()
     Return the XML Schema language used when parsing.
public  StackActiongetStackAction()
     See setStackAction.
public  SubstitutorgetSubstitutor()
     Gets the Substitutor used to convert attributes and body text.
public  booleangetUseContextClassLoader()
     Return the boolean as to whether the context classloader should be used.
public  booleangetValidating()
     Return the validating parser flag.
public  XMLReadergetXMLReader()
     Return the XMLReader to be used for parsing the input document.
public  voidignorableWhitespace(char buffer, int start, int len)
     Process notification of ignorable whitespace received from the body of an XML element.
protected  voidinitialize()
    

Provides a hook for lazy initialization of this Digester instance.

public  booleanisEmpty(String stackName)
    
public  voidlog(String message)
     Log a message to our associated logger.
public  voidlog(String message, Throwable exception)
     Log a message and exception to our associated logger.
public  voidnotationDecl(String name, String publicId, String systemId)
     Receive notification of a notation declaration event.
public  Objectparse(File file)
     Parse the content of the specified file using this Digester.
public  Objectparse(InputSource input)
     Parse the content of the specified input source using this Digester.
public  Objectparse(InputStream input)
     Parse the content of the specified input stream using this Digester.
public  Objectparse(Reader reader)
     Parse the content of the specified reader using this Digester.
public  Objectparse(String uri)
     Parse the content of the specified URI using this Digester.
public  Objectparse(URL url)
     Parse the content of the specified URL using this Digester.
public  Objectpeek()
     Return the top object on the stack without removing it.
public  Objectpeek(int n)
     Return the n'th object down the stack, where 0 is the top element and [getCount()-1] is the bottom element.
public  Objectpeek(String stackName)
    

Gets the top object from the stack with the given name.

public  Objectpeek(String stackName, int n)
    

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
Parameters:
  n - Index of the desired element, where 0 is the top of the stack,1 is the next element down, and so on.
public  ObjectpeekParams()
    

Return the top object on the parameters stack without removing it.

public  ObjectpeekParams(int n)
    

Return the n'th object down the parameters stack, where 0 is the top element and [getCount()-1] is the bottom element.

public  Objectpop()
     Pop the top object off of the stack, and return it.
public  Objectpop(String stackName)
    

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.
public  ObjectpopParams()
    

Pop the top object off of the parameters stack, and return it.

public  voidprocessingInstruction(String target, String data)
     Process notification of a processing instruction that was encountered.
public  voidpush(Object object)
     Push a new object onto the top of the object stack.
public  voidpush(String stackName, Object value)
     Pushes the given object onto the stack with the given name.
public  voidpushParams(Object object)
    

Push a new object onto the top of the parameters stack.

The parameters stack is used to store CallMethodRule parameters.

public  voidregister(String publicId, URL entityURL)
    

Register the specified DTD URL for the specified public identifier. This must be called before the first call to parse().

Digester contains an internal EntityResolver implementation.

public  voidregister(String publicId, String entityURL)
    
public  voidresetRoot()
     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.

public  InputSourceresolveEntity(String publicId, String systemId)
     Resolve the requested external entity.
public  voidsetClassLoader(ClassLoader classLoader)
     Set the class loader to be used for instantiating application objects when required.
public  voidsetCustomContentHandler(ContentHandler handler)
     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.

public  voidsetDebug(int debug)
     Set the debugging detail level of our currently enabled logger.
public  voidsetDocumentLocator(Locator locator)
     Sets the document locator associated with our parser.
public  voidsetEntityResolver(EntityResolver entityResolver)
     Set the EntityResolver used by SAX when resolving public id and system id.
public  voidsetErrorHandler(ErrorHandler errorHandler)
     Set the error handler for this Digester.
public  voidsetFeature(String feature, boolean value)
     Sets a flag indicating whether the requested feature is supported by the underlying implementation of org.xml.sax.XMLReader. See the saxproject website for information about the standard SAX2 feature flags.
public  voidsetLogger(Log log)
     Set the current logger for this Digester.
public  voidsetNamespaceAware(boolean namespaceAware)
     Set the "namespace aware" flag for parsers we create.
public  voidsetProperty(String property, Object value)
     Set the current value of the specified property for the underlying XMLReader implementation.
public  voidsetPublicId(String publicId)
     Set the publid id of the current file being parse.
public  voidsetRuleNamespaceURI(String ruleNamespaceURI)
     Set the namespace URI that will be applied to all subsequently added Rule objects.
public  voidsetRules(Rules rules)
     Set the Rules implementation object containing our rules collection and associated matching policy.
public  voidsetSAXLogger(Log saxLog)
     Sets the logger used for logging SAX-related information.
public  voidsetSchema(String schemaLocation)
     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.

public  voidsetSchemaLanguage(String schemaLanguage)
     Set the XML Schema language used when parsing.
public  voidsetStackAction(StackAction stackAction)
     Define a callback object which is invoked whever an object is pushed onto a digester object stack, or popped off one.
public  voidsetSubstitutor(Substitutor substitutor)
     Sets the Substitutor to be used to convert attributes and body text.
public  voidsetUseContextClassLoader(boolean use)
     Determine whether to use the Context ClassLoader (the one found by calling Thread.currentThread().getContextClassLoader()) to resolve/load classes that are defined in various rules.
public  voidsetValidating(boolean validating)
     Set the validating parser flag.
public  voidskippedEntity(String name)
     Process notification of a skipped entity.
public  voidstartDocument()
     Process notification of the beginning of the document being reached.
public  voidstartElement(String namespaceURI, String localName, String qName, Attributes list)
     Process notification of the start of an XML element being reached.
Parameters:
  namespaceURI - The Namespace URI, or the empty string if the elementhas no Namespace URI or if Namespace processing is not being performed.
Parameters:
  localName - The local name (without prefix), or the emptystring if Namespace processing is not being performed.
Parameters:
  qName - The qualified name (with prefix), or the emptystring if qualified names are not available.\
Parameters:
  list - The attributes attached to the element.
public  voidstartPrefixMapping(String prefix, String namespaceURI)
     Process notification that a namespace prefix is coming in to scope.
public  voidunparsedEntityDecl(String name, String publicId, String systemId, String notation)
     Receive notification of an unparsed entity declaration event.
public  voidwarning(SAXParseException exception)
     Forward notification of a parse warning to the application supplied error handler (if any).

Field Detail
JAXP_SCHEMA_LANGUAGE
protected String JAXP_SCHEMA_LANGUAGE(Code)
ParserFeatureSetterFactory



W3C_XML_SCHEMA
final protected static String W3C_XML_SCHEMA(Code)
The schema language supported. By default, we use this one.



bodyText
protected StringBuffer bodyText(Code)
The body text of the current element.



bodyTexts
protected ArrayStack bodyTexts(Code)
The stack of body text string buffers for surrounding elements.



classLoader
protected ClassLoader classLoader(Code)
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 the useContextClassLoader variable.



configured
protected boolean configured(Code)
Has this Digester been configured yet.



entityResolver
protected EntityResolver entityResolver(Code)
The EntityResolver used by the SAX parser. By default it use this class



entityValidator
protected HashMap entityValidator(Code)
The URLs of entityValidator that have been registered, keyed by the public identifier that corresponds.



errorHandler
protected ErrorHandler errorHandler(Code)
The application-supplied error handler that is notified when parsing warnings, errors, or fatal errors occur.



factory
protected SAXParserFactory factory(Code)
The SAXParserFactory that is created the first time we need it.



inputSources
protected List inputSources(Code)

List of InputSource instances created by a createInputSourceFromURL() 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.




locator
protected Locator locator(Code)
The Locator associated with our parser.



log
protected Log log(Code)
The Log to which most logging calls will be made.



match
protected String match(Code)
The current match pattern for nested element processing.



matches
protected ArrayStack matches(Code)
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



namespaceAware
protected boolean namespaceAware(Code)
Do we want a "namespace aware" parser.



namespaces
protected HashMap namespaces(Code)
Registered namespaces we are currently processing. The key is the namespace prefix that was declared in the document. The value is an ArrayStack 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).



params
protected ArrayStack params(Code)
The parameters stack being utilized by CallMethodRule and CallParamRule rules.



parser
protected SAXParser parser(Code)
The SAXParser we will use to parse the input stream.



publicId
protected String publicId(Code)
The public identifier of the DTD we are currently parsing under (if any).



reader
protected XMLReader reader(Code)
The XMLReader used to parse digester rules.



root
protected Object root(Code)
The "root" element of the stack (in other words, the last object that was popped.



rules
protected Rules rules(Code)
The Rules implementation containing our collection of Rule instances and associated matching policy. If not established before the first rule is added, a default implementation will be provided.



saxLog
protected Log saxLog(Code)
The Log to which all SAX event related logging calls will be made.



schemaLanguage
protected String schemaLanguage(Code)
The XML schema language to use for validating an XML instance. By default this value is set to W3C_XML_SCHEMA



schemaLocation
protected String schemaLocation(Code)
The XML schema to use for validating an XML instance.



stack
protected ArrayStack stack(Code)
The object stack being constructed.



substitutor
protected Substitutor substitutor(Code)
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.



useContextClassLoader
protected boolean useContextClassLoader(Code)
Do we want to use the Context ClassLoader when loading classes for instantiating new objects. Default is false.



validating
protected boolean validating(Code)
Do we want to use a validating parser.




Constructor Detail
Digester
public Digester()(Code)
Construct a new Digester with default properties.



Digester
public Digester(SAXParser parser)(Code)
Construct a new Digester, allowing a SAXParser to be passed in. This allows Digester to be used in environments which are unfriendly to JAXP1.1 (such as WebLogic 6.0). This may help in places where you are able to load JAXP 1.1 classes yourself.



Digester
public Digester(XMLReader reader)(Code)
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 Detail
addBeanPropertySetter
public void addBeanPropertySetter(String pattern)(Code)
Add a "bean property setter" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
See Also:   BeanPropertySetterRule



addBeanPropertySetter
public void addBeanPropertySetter(String pattern, String propertyName)(Code)
Add a "bean property setter" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  propertyName - Name of property to set
See Also:   BeanPropertySetterRule



addCallMethod
public void addCallMethod(String pattern, String methodName)(Code)
Add an "call method" rule for a method which accepts no arguments.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to be called
See Also:   CallMethodRule



addCallMethod
public void addCallMethod(String pattern, String methodName, int paramCount)(Code)
Add an "call method" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to be called
Parameters:
  paramCount - Number of expected parameters (or zerofor a single parameter from the body of this element)
See Also:   CallMethodRule



addCallMethod
public void addCallMethod(String pattern, String methodName, int paramCount, String paramTypes)(Code)
Add an "call method" rule for the specified parameters. If paramCount is set to zero the rule will use the body of the matched element as the single argument of the method, unless paramTypes is null or empty, in this case the rule will call the specified method with no arguments.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to be called
Parameters:
  paramCount - Number of expected parameters (or zerofor a single parameter from the body of this element)
Parameters:
  paramTypes - Set of Java class names for the typesof the expected parameters(if you wish to use a primitive type, specify the corresondingJava wrapper class instead, such as java.lang.Booleanfor a boolean parameter)
See Also:   CallMethodRule



addCallMethod
public void addCallMethod(String pattern, String methodName, int paramCount, Class paramTypes)(Code)
Add an "call method" rule for the specified parameters. If paramCount is set to zero the rule will use the body of the matched element as the single argument of the method, unless paramTypes is null or empty, in this case the rule will call the specified method with no arguments.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to be called
Parameters:
  paramCount - Number of expected parameters (or zerofor a single parameter from the body of this element)
Parameters:
  paramTypes - The Java class names of the arguments(if you wish to use a primitive type, specify the corresondingJava wrapper class instead, such as java.lang.Booleanfor a boolean parameter)
See Also:   CallMethodRule



addCallParam
public void addCallParam(String pattern, int paramIndex)(Code)
Add a "call parameter" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  paramIndex - Zero-relative parameter index to set(from the body of this element)
See Also:   CallParamRule



addCallParam
public void addCallParam(String pattern, int paramIndex, String attributeName)(Code)
Add a "call parameter" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  paramIndex - Zero-relative parameter index to set(from the specified attribute)
Parameters:
  attributeName - Attribute whose value is used as theparameter value
See Also:   CallParamRule



addCallParam
public void addCallParam(String pattern, int paramIndex, boolean fromStack)(Code)
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 number
Parameters:
  fromStack - Should the call parameter be taken from the top of the stack?
See Also:   CallParamRule



addCallParam
public void addCallParam(String pattern, int paramIndex, int stackIndex)(Code)
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 number
Parameters:
  stackIndex - 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:   CallMethodRule



addCallParamPath
public void addCallParamPath(String pattern, int paramIndex)(Code)
Add a "call parameter" rule that sets a parameter from the current Digester matching path. This is sometimes useful when using rules that support wildcards.
Parameters:
  pattern - the pattern that this rule should match
Parameters:
  paramIndex - The zero-relative parameter number
See Also:   CallMethodRule



addFactoryCreate
public void addFactoryCreate(String pattern, String className)(Code)
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.
Parameters:
  pattern - Element matching pattern
Parameters:
  className - Java class name of the object creation factory class
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, Class clazz)(Code)
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.
Parameters:
  pattern - Element matching pattern
Parameters:
  clazz - Java class of the object creation factory class
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, String className, String attributeName)(Code)
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.
Parameters:
  pattern - Element matching pattern
Parameters:
  className - Java class name of the object creation factory class
Parameters:
  attributeName - Attribute name which, if present, overrides thevalue specified by className
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, Class clazz, String attributeName)(Code)
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.
Parameters:
  pattern - Element matching pattern
Parameters:
  clazz - Java class of the object creation factory class
Parameters:
  attributeName - Attribute name which, if present, overrides thevalue specified by className
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, ObjectCreationFactory creationFactory)(Code)
Add a "factory create" rule for the specified parameters. Exceptions thrown during the object creation process will be propagated.
Parameters:
  pattern - Element matching pattern
Parameters:
  creationFactory - Previously instantiated ObjectCreationFactoryto be utilized
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, String className, boolean ignoreCreateExceptions)(Code)
Add a "factory create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  className - Java class name of the object creation factory class
Parameters:
  ignoreCreateExceptions - when true any exceptions thrown duringobject creation will be ignored.
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, Class clazz, boolean ignoreCreateExceptions)(Code)
Add a "factory create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  clazz - Java class of the object creation factory class
Parameters:
  ignoreCreateExceptions - when true any exceptions thrown duringobject creation will be ignored.
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, String className, String attributeName, boolean ignoreCreateExceptions)(Code)
Add a "factory create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  className - Java class name of the object creation factory class
Parameters:
  attributeName - Attribute name which, if present, overrides thevalue specified by className
Parameters:
  ignoreCreateExceptions - when true any exceptions thrown duringobject creation will be ignored.
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, Class clazz, String attributeName, boolean ignoreCreateExceptions)(Code)
Add a "factory create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  clazz - Java class of the object creation factory class
Parameters:
  attributeName - Attribute name which, if present, overrides thevalue specified by className
Parameters:
  ignoreCreateExceptions - when true any exceptions thrown duringobject creation will be ignored.
See Also:   FactoryCreateRule



addFactoryCreate
public void addFactoryCreate(String pattern, ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions)(Code)
Add a "factory create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  creationFactory - Previously instantiated ObjectCreationFactoryto be utilized
Parameters:
  ignoreCreateExceptions - when true any exceptions thrown duringobject creation will be ignored.
See Also:   FactoryCreateRule



addObjectCreate
public void addObjectCreate(String pattern, String className)(Code)
Add an "object create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  className - Java class name to be created
See Also:   ObjectCreateRule



addObjectCreate
public void addObjectCreate(String pattern, Class clazz)(Code)
Add an "object create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  clazz - Java class to be created
See Also:   ObjectCreateRule



addObjectCreate
public void addObjectCreate(String pattern, String className, String attributeName)(Code)
Add an "object create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  className - Default Java class name to be created
Parameters:
  attributeName - Attribute name that optionally overridesthe default Java class name to be created
See Also:   ObjectCreateRule



addObjectCreate
public void addObjectCreate(String pattern, String attributeName, Class clazz)(Code)
Add an "object create" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  attributeName - Attribute name that optionally overrides
Parameters:
  clazz - Default Java class to be createdthe default Java class name to be created
See Also:   ObjectCreateRule



addObjectParam
public void addObjectParam(String pattern, int paramIndex, Object paramObj)(Code)
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 number
Parameters:
  paramObj - Any arbitrary object to be passed to the targetmethod.
See Also:   CallMethodRule
since:
   1.6




addRule
public void addRule(String pattern, Rule rule)(Code)

Register a new Rule matching the specified pattern. This method sets the Digester property on the rule.


Parameters:
  pattern - Element matching pattern
Parameters:
  rule - Rule to be registered



addRuleSet
public void addRuleSet(RuleSet ruleSet)(Code)
Register a set of Rule instances defined in a RuleSet.
Parameters:
  ruleSet - The RuleSet instance to configure from



addSetNestedProperties
public void addSetNestedProperties(String pattern)(Code)
Adds an SetNestedPropertiesRule .
Parameters:
  pattern - register the rule with this pattern
since:
   1.6



addSetNestedProperties
public void addSetNestedProperties(String pattern, String elementName, String propertyName)(Code)
Adds an SetNestedPropertiesRule .
Parameters:
  pattern - register the rule with this pattern
Parameters:
  elementName - elment name that a property maps to
Parameters:
  propertyName - property name of the element mapped from
since:
   1.6



addSetNestedProperties
public void addSetNestedProperties(String pattern, String[] elementNames, String[] propertyNames)(Code)
Adds an SetNestedPropertiesRule .
Parameters:
  pattern - register the rule with this pattern
Parameters:
  elementNames - elment names that (in order) map to properties
Parameters:
  propertyNames - property names that (in order) elements are mapped to
since:
   1.6



addSetNext
public void addSetNext(String pattern, String methodName)(Code)
Add a "set next" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to call on the parent element
See Also:   SetNextRule



addSetNext
public void addSetNext(String pattern, String methodName, String paramType)(Code)
Add a "set next" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to call on the parent element
Parameters:
  paramType - Java class name of the expected parameter type(if you wish to use a primitive type, specify the corresondingJava wrapper class instead, such as java.lang.Booleanfor a boolean parameter)
See Also:   SetNextRule



addSetProperties
public void addSetProperties(String pattern)(Code)
Add a "set properties" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
See Also:   SetPropertiesRule



addSetProperties
public void addSetProperties(String pattern, String attributeName, String propertyName)(Code)
Add a "set properties" rule with a single overridden parameter. See SetPropertiesRule.SetPropertiesRule(String attributeNameString propertyName)
Parameters:
  pattern - Element matching pattern
Parameters:
  attributeName - map this attribute
Parameters:
  propertyName - to this property
See Also:   SetPropertiesRule



addSetProperties
public void addSetProperties(String pattern, String[] attributeNames, String[] propertyNames)(Code)
Add a "set properties" rule with overridden parameters. See SetPropertiesRule.SetPropertiesRule(String[] attributeNamesString[] propertyNames)
Parameters:
  pattern - Element matching pattern
Parameters:
  attributeNames - names of attributes with custom mappings
Parameters:
  propertyNames - property names these attributes map to
See Also:   SetPropertiesRule



addSetProperty
public void addSetProperty(String pattern, String name, String value)(Code)
Add a "set property" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  name - Attribute name containing the property name to be set
Parameters:
  value - Attribute name containing the property value to set
See Also:   SetPropertyRule



addSetRoot
public void addSetRoot(String pattern, String methodName)(Code)
Add SetRootRule with the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to call on the root object
See Also:   SetRootRule



addSetRoot
public void addSetRoot(String pattern, String methodName, String paramType)(Code)
Add SetRootRule with the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to call on the root object
Parameters:
  paramType - Java class name of the expected parameter type
See Also:   SetRootRule



addSetTop
public void addSetTop(String pattern, String methodName)(Code)
Add a "set top" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to call on the parent element
See Also:   SetTopRule



addSetTop
public void addSetTop(String pattern, String methodName, String paramType)(Code)
Add a "set top" rule for the specified parameters.
Parameters:
  pattern - Element matching pattern
Parameters:
  methodName - Method name to call on the parent element
Parameters:
  paramType - Java class name of the expected parameter type(if you wish to use a primitive type, specify the corresondingJava wrapper class instead, such as java.lang.Booleanfor a boolean parameter)
See Also:   SetTopRule



characters
public void characters(char buffer, int start, int length) throws SAXException(Code)
Process notification of character data received from the body of an XML element.
Parameters:
  buffer - The characters from the XML document
Parameters:
  start - Starting offset into the buffer
Parameters:
  length - Number of characters from the buffer
exception:
  SAXException - if a parsing error is to be reported



cleanup
protected void cleanup()(Code)

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



clear
public void clear()(Code)
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. In general, a separate Digester object should be created for each document to be parsed.




configure
protected void configure()(Code)

Provide a hook for lazy configuration of this Digester instance. 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 Digester.initialize or the code should take responsibility by checking and setting the Digester.configured flag.




createInputSourceFromURL
public InputSource createInputSourceFromURL(URL url) throws MalformedURLException, IOException(Code)
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.
since:
   1.8



createInputSourceFromURL
public InputSource createInputSourceFromURL(String url) throws MalformedURLException, IOException(Code)

Convenience method that creates an InputSource from the string version of a URL.


Parameters:
  url - URL for which to create an InputSource
since:
   1.8



createSAXException
public SAXException createSAXException(String message, Exception e)(Code)
Create a SAX exception which also understands about the location in the digester file where the exception occurs the new exception



createSAXException
public SAXException createSAXException(Exception e)(Code)
Create a SAX exception which also understands about the location in the digester file where the exception occurs the new exception



createSAXException
public SAXException createSAXException(String message)(Code)
Create a SAX exception which also understands about the location in the digester file where the exception occurs the new exception



endDocument
public void endDocument() throws SAXException(Code)
Process notification of the end of the document being reached.
exception:
  SAXException - if a parsing error is to be reported



endElement
public void endElement(String namespaceURI, String localName, String qName) throws SAXException(Code)
Process notification of the end of an XML element being reached.
Parameters:
  namespaceURI - - The Namespace URI, or the empty string if theelement has no Namespace URI or if Namespace processing is notbeing performed.
Parameters:
  localName - - The local name (without prefix), or the emptystring if Namespace processing is not being performed.
Parameters:
  qName - - The qualified XML 1.0 name (with prefix), or theempty string if qualified names are not available.
exception:
  SAXException - if a parsing error is to be reported



endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException(Code)
Process notification that a namespace prefix is going out of scope.
Parameters:
  prefix - Prefix that is going out of scope
exception:
  SAXException - if a parsing error is to be reported



error
public void error(SAXParseException exception) throws SAXException(Code)
Forward notification of a parsing error to the application supplied error handler (if any).
Parameters:
  exception - The error information
exception:
  SAXException - if a parsing exception occurs



fatalError
public void fatalError(SAXParseException exception) throws SAXException(Code)
Forward notification of a fatal parsing error to the application supplied error handler (if any).
Parameters:
  exception - The fatal error information
exception:
  SAXException - if a parsing exception occurs



findNamespaceURI
public String findNamespaceURI(String prefix)(Code)
Return the currently mapped namespace URI for the specified prefix, if any; otherwise return null. These mappings come and go dynamically as the document is parsed.
Parameters:
  prefix - Prefix to look up



getClassLoader
public ClassLoader getClassLoader()(Code)
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 useContextClassLoader property is set to true
  • The class loader used to load the Digester class itself.



getCount
public int getCount()(Code)
Return the current depth of the element stack.



getCurrentElementName
public String getCurrentElementName()(Code)
Return the name of the XML element that is currently being processed.



getCurrentNamespaces
public Map getCurrentNamespaces()(Code)
Get the most current namespaces for all prefixes. Map A map with namespace prefixes as keys and most currentnamespace URIs for the corresponding prefixes as values
since:
   1.8



getCustomContentHandler
public ContentHandler getCustomContentHandler()(Code)



getDebug
public int getDebug()(Code)
Return the debugging detail level of our currently enabled logger.



getDocumentLocator
public Locator getDocumentLocator()(Code)
Gets the document locator associated with our parser. the Locator supplied by the document parser



getEntityResolver
public EntityResolver getEntityResolver()(Code)
Return the Entity Resolver used by the SAX parser. Return the Entity Resolver used by the SAX parser.



getErrorHandler
public ErrorHandler getErrorHandler()(Code)
Return the error handler for this Digester.



getFactory
public SAXParserFactory getFactory()(Code)
Return the SAXParserFactory we will use, creating one if necessary.



getFeature
public boolean getFeature(String feature) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException(Code)
Returns a flag indicating whether the requested feature is supported by the underlying implementation of org.xml.sax.XMLReader. See the saxproject website for information about the standard SAX2 feature flags.
Parameters:
  feature - Name of the feature to inquire about
exception:
  ParserConfigurationException - if a parser configuration erroroccurs
exception:
  SAXNotRecognizedException - if the property name isnot recognized
exception:
  SAXNotSupportedException - if the property name isrecognized but not supported



getLogger
public Log getLogger()(Code)
Return the current Logger associated with this instance of the Digester



getMatch
public String getMatch()(Code)
Return the current rule match path



getNamespaceAware
public boolean getNamespaceAware()(Code)
Return the "namespace aware" flag for parsers we create.



getParser
public SAXParser getParser()(Code)
Return the SAXParser we will use to parse the input stream. If there is a problem creating the parser, return null.



getProperty
public Object getProperty(String property) throws SAXNotRecognizedException, SAXNotSupportedException(Code)
Return the current value of the specified property for the underlying XMLReader implementation. See the saxproject website for information about the standard SAX2 properties.
Parameters:
  property - Property name to be retrieved
exception:
  SAXNotRecognizedException - if the property name isnot recognized
exception:
  SAXNotSupportedException - if the property name isrecognized but not supported



getPublicId
public String getPublicId()(Code)
Return the public identifier of the DTD we are currently parsing under, if any.



getReader
public XMLReader getReader()(Code)
By setting the reader in the constructor, you can bypass JAXP and be able to use digester in Weblogic 6.0.



getRegistrations
Map getRegistrations()(Code)
Return the set of DTD URL registrations, keyed by public identifier.



getRoot
public Object getRoot()(Code)
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. the root object that has been created after parsingor null if the digester has not parsed any XML yet.




getRuleNamespaceURI
public String getRuleNamespaceURI()(Code)
Return the namespace URI that will be applied to all subsequently added Rule objects.



getRules
public Rules getRules()(Code)
Return the Rules implementation object containing our rules collection and associated matching policy. If none has been established, a default implementation will be created and returned.



getRules
List getRules(String match)(Code)
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.
Parameters:
  match - The current match position



getSAXLogger
public Log getSAXLogger()(Code)
Gets the logger used for logging SAX-related information. Note the output is finely grained.
since:
   1.6



getSchema
public String getSchema()(Code)
Return the XML Schema URI used for validating an XML instance.



getSchemaLanguage
public String getSchemaLanguage()(Code)
Return the XML Schema language used when parsing.



getStackAction
public StackAction getStackAction()(Code)
See setStackAction.
since:
   1.8



getSubstitutor
public Substitutor getSubstitutor()(Code)
Gets the Substitutor used to convert attributes and body text. Substitutor, null if not substitutions are to be performed.



getUseContextClassLoader
public boolean getUseContextClassLoader()(Code)
Return the boolean as to whether the context classloader should be used.



getValidating
public boolean getValidating()(Code)
Return the validating parser flag.



getXMLReader
public XMLReader getXMLReader() throws SAXException(Code)
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.
exception:
  SAXException - if no XMLReader can be instantiated



ignorableWhitespace
public void ignorableWhitespace(char buffer, int start, int len) throws SAXException(Code)
Process notification of ignorable whitespace received from the body of an XML element.
Parameters:
  buffer - The characters from the XML document
Parameters:
  start - Starting offset into the buffer
Parameters:
  len - Number of characters from the buffer
exception:
  SAXException - if a parsing error is to be reported



initialize
protected void initialize()(Code)

Provides a hook for lazy initialization of this Digester instance. 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 Digester.configure only when the Digester.configured flag is false. Subclasses that override configure or who set configured may find that this method may be called more than once.


since:
   1.6



isEmpty
public boolean isEmpty(String stackName)(Code)

Is the stack with the given name empty?

Note: a stack is considered empty if no objects have been pushed onto it yet.


Parameters:
  stackName - the name of the stack whose emptiness should be evaluated true if the given stack if empty
since:
   1.6



log
public void log(String message)(Code)
Log a message to our associated logger.
Parameters:
  message - The message to be logged



log
public void log(String message, Throwable exception)(Code)
Log a message and exception to our associated logger.
Parameters:
  message - The message to be logged



notationDecl
public void notationDecl(String name, String publicId, String systemId)(Code)
Receive notification of a notation declaration event.
Parameters:
  name - The notation name
Parameters:
  publicId - The public identifier (if any)
Parameters:
  systemId - The system identifier (if any)



parse
public Object parse(File file) throws IOException, SAXException(Code)
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
exception:
  IOException - if an input/output error occurs
exception:
  SAXException - if a parsing exception occurs



parse
public Object parse(InputSource input) throws IOException, SAXException(Code)
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
exception:
  IOException - if an input/output error occurs
exception:
  SAXException - if a parsing exception occurs



parse
public Object parse(InputStream input) throws IOException, SAXException(Code)
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
exception:
  IOException - if an input/output error occurs
exception:
  SAXException - if a parsing exception occurs



parse
public Object parse(Reader reader) throws IOException, SAXException(Code)
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
exception:
  IOException - if an input/output error occurs
exception:
  SAXException - if a parsing exception occurs



parse
public Object parse(String uri) throws IOException, SAXException(Code)
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
exception:
  IOException - if an input/output error occurs
exception:
  SAXException - if a parsing exception occurs



parse
public Object parse(URL url) throws IOException, SAXException(Code)
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
exception:
  IOException - if an input/output error occurs
exception:
  SAXException - if a parsing exception occurs
since:
   1.8



peek
public Object peek()(Code)
Return the top object on the stack without removing it. If there are no objects on the stack, return null.



peek
public Object peek(int n)(Code)
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.
Parameters:
  n - Index of the desired element, where 0 is the top of the stack,1 is the next element down, and so on.



peek
public Object peek(String stackName)(Code)

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 the top Object on 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
public Object peek(String stackName, int n)(Code)

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
Parameters:
  n - Index of the desired element, where 0 is the top of the stack,1 is the next element down, and so on. the specified Object on the stack.
throws:
  EmptyStackException - if the named stack is empty
since:
   1.6



peekParams
public Object peekParams()(Code)

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 CallMethodRule parameters. See Digester.params .




peekParams
public Object peekParams(int n)(Code)

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 CallMethodRule parameters. See Digester.params .


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
public Object pop()(Code)
Pop the top object off of the stack, and return it. If there are no objects on the stack, return null.



pop
public Object pop(String stackName)(Code)

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. the top Object on 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



popParams
public Object popParams()(Code)

Pop the top object off of the parameters stack, and return it. If there are no objects on the stack, return null.

The parameters stack is used to store CallMethodRule parameters. See Digester.params .




processingInstruction
public void processingInstruction(String target, String data) throws SAXException(Code)
Process notification of a processing instruction that was encountered.
Parameters:
  target - The processing instruction target
Parameters:
  data - The processing instruction data (if any)
exception:
  SAXException - if a parsing error is to be reported



push
public void push(Object object)(Code)
Push a new object onto the top of the object stack.
Parameters:
  object - The new object



push
public void push(String stackName, Object value)(Code)
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 pushed
Parameters:
  value - the Object to be pushed onto the named stack.
since:
   1.6



pushParams
public void pushParams(Object object)(Code)

Push a new object onto the top of the parameters stack.

The parameters stack is used to store CallMethodRule parameters. See Digester.params .


Parameters:
  object - The new object



register
public void register(String publicId, URL entityURL)(Code)

Register the specified DTD URL for the specified public identifier. This must be called before the first call to parse().

Digester contains an internal EntityResolver implementation. This maps PUBLICID'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 every SYSTEM URI on every processed xml document is local. This implementation provides only basic functionality. If more sophisticated features are required, using Digester.setEntityResolver to set a custom resolver is recommended.

Note: This method will have no effect when a custom EntityResolver has been set. (Setting a custom EntityResolver overrides the internal implementation.)


Parameters:
  publicId - Public identifier of the DTD to be resolved
Parameters:
  entityURL - The URL to use for reading this DTD
since:
   1.8



register
public void register(String publicId, String entityURL)(Code)

Convenience method that registers the string version of an entity URL instead of a URL version.


Parameters:
  publicId - Public identifier of the entity to be resolved
Parameters:
  entityURL - The URL to use for reading this entity



resetRoot
public void resetRoot()(Code)
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




resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws SAXException(Code)
Resolve the requested external entity.
Parameters:
  publicId - The public identifier of the entity being referenced
Parameters:
  systemId - The system identifier of the entity being referenced
exception:
  SAXException - if a parsing exception occurs



setClassLoader
public void setClassLoader(ClassLoader classLoader)(Code)
Set the class loader to be used for instantiating application objects when required.
Parameters:
  classLoader - The new class loader to use, or nullto revert to the standard rules



setCustomContentHandler
public void setCustomContentHandler(ContentHandler handler)(Code)
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



setDebug
public void setDebug(int debug)(Code)
Set the debugging detail level of our currently enabled logger.
Parameters:
  debug - New debugging detail level (0=off, increasing integersfor more detail)



setDocumentLocator
public void setDocumentLocator(Locator locator)(Code)
Sets the document locator associated with our parser.
Parameters:
  locator - The new locator



setEntityResolver
public void setEntityResolver(EntityResolver entityResolver)(Code)
Set the EntityResolver used by SAX when resolving public id and system id. This must be called before the first call to parse().
Parameters:
  entityResolver - a class that implement the EntityResolver interface.



setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)(Code)
Set the error handler for this Digester.
Parameters:
  errorHandler - The new error handler



setFeature
public void setFeature(String feature, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException(Code)
Sets a flag indicating whether the requested feature is supported by the underlying implementation of org.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 the getParser() method is called for the first time, either directly or indirectly.
Parameters:
  feature - Name of the feature to set the status for
Parameters:
  value - The new value for this feature
exception:
  ParserConfigurationException - if a parser configuration erroroccurs
exception:
  SAXNotRecognizedException - if the property name isnot recognized
exception:
  SAXNotSupportedException - if the property name isrecognized but not supported



setLogger
public void setLogger(Log log)(Code)
Set the current logger for this Digester.



setNamespaceAware
public void setNamespaceAware(boolean namespaceAware)(Code)
Set the "namespace aware" flag for parsers we create.
Parameters:
  namespaceAware - The new "namespace aware" flag



setProperty
public void setProperty(String property, Object value) throws SAXNotRecognizedException, SAXNotSupportedException(Code)
Set the current value of the specified property for the underlying XMLReader implementation. See the saxproject website for information about the standard SAX2 properties.
Parameters:
  property - Property name to be set
Parameters:
  value - Property value to be set
exception:
  SAXNotRecognizedException - if the property name isnot recognized
exception:
  SAXNotSupportedException - if the property name isrecognized but not supported



setPublicId
public void setPublicId(String publicId)(Code)
Set the publid id of the current file being parse.
Parameters:
  publicId - the DTD/Schema public's id.



setRuleNamespaceURI
public void setRuleNamespaceURI(String ruleNamespaceURI)(Code)
Set the namespace URI that will be applied to all subsequently added Rule objects.
Parameters:
  ruleNamespaceURI - Namespace URI that must match on allsubsequently added rules, or null for matchingregardless of the current namespace URI



setRules
public void setRules(Rules rules)(Code)
Set the Rules implementation object containing our rules collection and associated matching policy.
Parameters:
  rules - New Rules implementation



setSAXLogger
public void setSAXLogger(Log saxLog)(Code)
Sets the logger used for logging SAX-related information. Note the output is finely grained.
Parameters:
  saxLog - Log, not null
since:
   1.6



setSchema
public void setSchema(String schemaLocation)(Code)
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.




setSchemaLanguage
public void setSchemaLanguage(String schemaLanguage)(Code)
Set the XML Schema language used when parsing. By default, we use W3C.
Parameters:
  schemaLanguage - a URI to the schema language.



setStackAction
public void setStackAction(StackAction stackAction)(Code)
Define a callback object which is invoked whever an object is pushed onto a digester object stack, or popped off one.
since:
   1.8



setSubstitutor
public void setSubstitutor(Substitutor substitutor)(Code)
Sets the Substitutor to be used to convert attributes and body text.
Parameters:
  substitutor - the Substitutor to be used to convert attributes and body textor null if not substitution of these values is to be performed.



setUseContextClassLoader
public void setUseContextClassLoader(boolean use)(Code)
Determine whether to use the Context ClassLoader (the one found by calling Thread.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.



setValidating
public void setValidating(boolean validating)(Code)
Set the validating parser flag. This must be called before parse() is called the first time.
Parameters:
  validating - The new validating parser flag.



skippedEntity
public void skippedEntity(String name) throws SAXException(Code)
Process notification of a skipped entity.
Parameters:
  name - Name of the skipped entity
exception:
  SAXException - if a parsing error is to be reported



startDocument
public void startDocument() throws SAXException(Code)
Process notification of the beginning of the document being reached.
exception:
  SAXException - if a parsing error is to be reported



startElement
public void startElement(String namespaceURI, String localName, String qName, Attributes list) throws SAXException(Code)
Process notification of the start of an XML element being reached.
Parameters:
  namespaceURI - The Namespace URI, or the empty string if the elementhas no Namespace URI or if Namespace processing is not being performed.
Parameters:
  localName - The local name (without prefix), or the emptystring if Namespace processing is not being performed.
Parameters:
  qName - The qualified name (with prefix), or the emptystring if qualified names are not available.\
Parameters:
  list - The attributes attached to the element. If there areno attributes, it shall be an empty Attributes object.
exception:
  SAXException - if a parsing error is to be reported



startPrefixMapping
public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException(Code)
Process notification that a namespace prefix is coming in to scope.
Parameters:
  prefix - Prefix that is being declared
Parameters:
  namespaceURI - Corresponding namespace URI being mapped to
exception:
  SAXException - if a parsing error is to be reported



unparsedEntityDecl
public void unparsedEntityDecl(String name, String publicId, String systemId, String notation)(Code)
Receive notification of an unparsed entity declaration event.
Parameters:
  name - The unparsed entity name
Parameters:
  publicId - The public identifier (if any)
Parameters:
  systemId - The system identifier (if any)
Parameters:
  notation - The name of the associated notation



warning
public void warning(SAXParseException exception) throws SAXException(Code)
Forward notification of a parse warning to the application supplied error handler (if any).
Parameters:
  exception - The warning information
exception:
  SAXException - if a parsing exception occurs



Methods inherited from org.xml.sax.helpers.DefaultHandler
public void characters(char ch, int start, int length) throws SAXException(Code)(Java Doc)
public void endDocument() throws SAXException(Code)(Java Doc)
public void endElement(String uri, String localName, String qName) throws SAXException(Code)(Java Doc)
public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc)
public void error(SAXParseException e) throws SAXException(Code)(Java Doc)
public void fatalError(SAXParseException e) throws SAXException(Code)(Java Doc)
public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code)(Java Doc)
public void notationDecl(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc)
public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc)
public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException(Code)(Java Doc)
public void setDocumentLocator(Locator locator)(Code)(Java Doc)
public void skippedEntity(String name) throws SAXException(Code)(Java Doc)
public void startDocument() throws SAXException(Code)(Java Doc)
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException(Code)(Java Doc)
public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc)
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException(Code)(Java Doc)
public void warning(SAXParseException e) throws SAXException(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.