| Method from org.apache.commons.digester.Digester Detail: |
public void addBeanPropertySetter(String pattern) {
addRule(pattern,
new BeanPropertySetterRule());
}
Add a "bean property setter" rule for the specified parameters. |
public void addBeanPropertySetter(String pattern,
String propertyName) {
addRule(pattern,
new BeanPropertySetterRule(propertyName));
}
Add a "bean property setter" rule for the specified parameters. |
public void addCallMethod(String pattern,
String methodName) {
addRule(
pattern,
new CallMethodRule(methodName));
}
Add an "call method" rule for a method which accepts no arguments. |
public void addCallMethod(String pattern,
String methodName,
int paramCount) {
addRule(pattern,
new CallMethodRule(methodName, paramCount));
}
Add an "call method" rule for the specified parameters. |
public void addCallMethod(String pattern,
String methodName,
int paramCount,
String[] paramTypes) {
addRule(pattern,
new CallMethodRule(
methodName,
paramCount,
paramTypes));
}
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. |
public void addCallMethod(String pattern,
String methodName,
int paramCount,
Class[] paramTypes) {
addRule(pattern,
new CallMethodRule(
methodName,
paramCount,
paramTypes));
}
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. |
public void addCallParam(String pattern,
int paramIndex) {
addRule(pattern,
new CallParamRule(paramIndex));
}
Add a "call parameter" rule for the specified parameters. |
public void addCallParam(String pattern,
int paramIndex,
String attributeName) {
addRule(pattern,
new CallParamRule(paramIndex, attributeName));
}
Add a "call parameter" rule for the specified parameters. |
public void addCallParam(String pattern,
int paramIndex,
boolean fromStack) {
addRule(pattern,
new CallParamRule(paramIndex, fromStack));
}
Add a "call parameter" rule.
This will either take a parameter from the stack
or from the current element body text. |
public void addCallParam(String pattern,
int paramIndex,
int stackIndex) {
addRule(pattern,
new CallParamRule(paramIndex, stackIndex));
}
Add a "call parameter" rule that sets a parameter from the stack.
This takes a parameter from the given position on the stack. |
public void addCallParamPath(String pattern,
int paramIndex) {
addRule(pattern, new PathCallParamRule(paramIndex));
}
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. |
public void addFactoryCreate(String pattern,
String className) {
addFactoryCreate(pattern, className, false);
}
Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated. |
public void addFactoryCreate(String pattern,
Class clazz) {
addFactoryCreate(pattern, clazz, false);
}
Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated. |
public void addFactoryCreate(String pattern,
ObjectCreationFactory creationFactory) {
addFactoryCreate(pattern, creationFactory, false);
}
Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated. |
public void addFactoryCreate(String pattern,
String className,
String attributeName) {
addFactoryCreate(pattern, className, attributeName, false);
}
Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated. |
public void addFactoryCreate(String pattern,
Class clazz,
String attributeName) {
addFactoryCreate(pattern, clazz, attributeName, false);
}
Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated. |
public void addFactoryCreate(String pattern,
String className,
boolean ignoreCreateExceptions) {
addRule(
pattern,
new FactoryCreateRule(className, ignoreCreateExceptions));
}
Add a "factory create" rule for the specified parameters. |
public void addFactoryCreate(String pattern,
Class clazz,
boolean ignoreCreateExceptions) {
addRule(
pattern,
new FactoryCreateRule(clazz, ignoreCreateExceptions));
}
Add a "factory create" rule for the specified parameters. |
public void addFactoryCreate(String pattern,
ObjectCreationFactory creationFactory,
boolean ignoreCreateExceptions) {
creationFactory.setDigester(this);
addRule(pattern,
new FactoryCreateRule(creationFactory, ignoreCreateExceptions));
}
Add a "factory create" rule for the specified parameters. |
public void addFactoryCreate(String pattern,
String className,
String attributeName,
boolean ignoreCreateExceptions) {
addRule(
pattern,
new FactoryCreateRule(className, attributeName, ignoreCreateExceptions));
}
Add a "factory create" rule for the specified parameters. |
public void addFactoryCreate(String pattern,
Class clazz,
String attributeName,
boolean ignoreCreateExceptions) {
addRule(
pattern,
new FactoryCreateRule(clazz, attributeName, ignoreCreateExceptions));
}
Add a "factory create" rule for the specified parameters. |
public void addObjectCreate(String pattern,
String className) {
addRule(pattern,
new ObjectCreateRule(className));
}
Add an "object create" rule for the specified parameters. |
public void addObjectCreate(String pattern,
Class clazz) {
addRule(pattern,
new ObjectCreateRule(clazz));
}
Add an "object create" rule for the specified parameters. |
public void addObjectCreate(String pattern,
String className,
String attributeName) {
addRule(pattern,
new ObjectCreateRule(className, attributeName));
}
Add an "object create" rule for the specified parameters. |
public void addObjectCreate(String pattern,
String attributeName,
Class clazz) {
addRule(pattern,
new ObjectCreateRule(attributeName, clazz));
}
Add an "object create" rule for the specified parameters. |
public void addObjectParam(String pattern,
int paramIndex,
Object paramObj) {
addRule(pattern,
new ObjectParamRule(paramIndex, paramObj));
}
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). |
public void addRule(String pattern,
Rule rule) {
rule.setDigester(this);
getRules().add(pattern, rule);
}
Register a new Rule matching the specified pattern.
This method sets the Digester property on the rule.
|
public void addRuleSet(RuleSet ruleSet) {
String oldNamespaceURI = getRuleNamespaceURI();
String newNamespaceURI = ruleSet.getNamespaceURI();
if (log.isDebugEnabled()) {
if (newNamespaceURI == null) {
log.debug("addRuleSet() with no namespace URI");
} else {
log.debug("addRuleSet() with namespace URI " + newNamespaceURI);
}
}
setRuleNamespaceURI(newNamespaceURI);
ruleSet.addRuleInstances(this);
setRuleNamespaceURI(oldNamespaceURI);
}
Register a set of Rule instances defined in a RuleSet. |
public void addSetNestedProperties(String pattern) {
addRule(pattern, new SetNestedPropertiesRule());
}
|
public void addSetNestedProperties(String pattern,
String elementName,
String propertyName) {
addRule(pattern, new SetNestedPropertiesRule(elementName, propertyName));
}
|
public void addSetNestedProperties(String pattern,
String[] elementNames,
String[] propertyNames) {
addRule(pattern, new SetNestedPropertiesRule(elementNames, propertyNames));
}
|
public void addSetNext(String pattern,
String methodName) {
addRule(pattern,
new SetNextRule(methodName));
}
Add a "set next" rule for the specified parameters. |
public void addSetNext(String pattern,
String methodName,
String paramType) {
addRule(pattern,
new SetNextRule(methodName, paramType));
}
Add a "set next" rule for the specified parameters. |
public void addSetProperties(String pattern) {
addRule(pattern,
new SetPropertiesRule());
}
Add a "set properties" rule for the specified parameters. |
public void addSetProperties(String pattern,
String attributeName,
String propertyName) {
addRule(pattern,
new SetPropertiesRule(attributeName, propertyName));
}
|
public void addSetProperties(String pattern,
String[] attributeNames,
String[] propertyNames) {
addRule(pattern,
new SetPropertiesRule(attributeNames, propertyNames));
}
|
public void addSetProperty(String pattern,
String name,
String value) {
addRule(pattern,
new SetPropertyRule(name, value));
}
Add a "set property" rule for the specified parameters. |
public void addSetRoot(String pattern,
String methodName) {
addRule(pattern,
new SetRootRule(methodName));
}
|
public void addSetRoot(String pattern,
String methodName,
String paramType) {
addRule(pattern,
new SetRootRule(methodName, paramType));
}
|
public void addSetTop(String pattern,
String methodName) {
addRule(pattern,
new SetTopRule(methodName));
}
Add a "set top" rule for the specified parameters. |
public void addSetTop(String pattern,
String methodName,
String paramType) {
addRule(pattern,
new SetTopRule(methodName, paramType));
}
Add a "set top" rule for the specified parameters. |
public void characters(char[] buffer,
int start,
int length) throws SAXException {
if (customContentHandler != null) {
// forward calls instead of handling them here
customContentHandler.characters(buffer, start, length);
return;
}
if (saxLog.isDebugEnabled()) {
saxLog.debug("characters(" + new String(buffer, start, length) + ")");
}
bodyText.append(buffer, start, length);
}
Process notification of character data received from the body of
an XML element. |
protected void cleanup() {
// If we created any InputSource objects in this instance,
// they each have an input stream that should be closed
Iterator sources = inputSources.iterator();
while (sources.hasNext()) {
InputSource source = (InputSource) sources.next();
try {
source.getByteStream().close();
} catch (IOException e) {
; // Fall through so we get them all
}
}
}
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.
|
public void clear() {
match = "";
bodyTexts.clear();
params.clear();
publicId = null;
stack.clear();
stacksByName.clear();
customContentHandler = null;
}
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. |
protected void configure() {
// Do not configure more than once
if (configured) {
return;
}
// Perform lazy configuration as needed
initialize(); // call hook method for subclasses that want to be initialized once only
// Nothing else required by default
// Set the configuration flag to avoid repeating
configured = true;
}
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 #initialize
or the code should take responsibility by checking and setting the
#configured flag.
|
public InputSource createInputSourceFromURL(URL url) throws MalformedURLException, IOException {
URLConnection connection = url.openConnection();
connection.setUseCaches(false);
InputStream stream = connection.getInputStream();
InputSource source = new InputSource(stream);
source.setSystemId(url.toExternalForm());
inputSources.add(source);
return source;
}
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. |
public InputSource createInputSourceFromURL(String url) throws MalformedURLException, IOException {
return createInputSourceFromURL(new URL(url));
}
|
public SAXException createSAXException(Exception e) {
if (e instanceof InvocationTargetException) {
Throwable t = ((InvocationTargetException) e).getTargetException();
if ((t != null) && (t instanceof Exception)) {
e = (Exception) t;
}
}
return createSAXException(e.getMessage(), e);
}
Create a SAX exception which also understands about the location in
the digester file where the exception occurs |
public SAXException createSAXException(String message) {
return createSAXException(message, null);
}
Create a SAX exception which also understands about the location in
the digester file where the exception occurs |
public SAXException createSAXException(String message,
Exception e) {
if ((e != null) &&
(e instanceof InvocationTargetException)) {
Throwable t = ((InvocationTargetException) e).getTargetException();
if ((t != null) && (t instanceof Exception)) {
e = (Exception) t;
}
}
if (locator != null) {
String error = "Error at line " + locator.getLineNumber() + " char " +
locator.getColumnNumber() + ": " + message;
if (e != null) {
return new SAXParseException(error, locator, e);
} else {
return new SAXParseException(error, locator);
}
}
log.error("No Locator!");
if (e != null) {
return new SAXException(message, e);
} else {
return new SAXException(message);
}
}
Create a SAX exception which also understands about the location in
the digester file where the exception occurs |
public void endDocument() throws SAXException {
if (saxLog.isDebugEnabled()) {
if (getCount() > 1) {
saxLog.debug("endDocument(): " + getCount() +
" elements left");
} else {
saxLog.debug("endDocument()");
}
}
// Fire "finish" events for all defined rules
Iterator rules = getRules().rules().iterator();
while (rules.hasNext()) {
Rule rule = (Rule) rules.next();
try {
rule.finish();
} catch (Exception e) {
log.error("Finish event threw exception", e);
throw createSAXException(e);
} catch (Error e) {
log.error("Finish event threw error", e);
throw e;
}
}
// Perform final cleanup
clear();
}
Process notification of the end of the document being reached. |
public void endElement(String namespaceURI,
String localName,
String qName) throws SAXException {
if (customContentHandler != null) {
// forward calls instead of handling them here
customContentHandler.endElement(namespaceURI, localName, qName);
return;
}
boolean debug = log.isDebugEnabled();
if (debug) {
if (saxLog.isDebugEnabled()) {
saxLog.debug("endElement(" + namespaceURI + "," + localName +
"," + qName + ")");
}
log.debug(" match='" + match + "'");
log.debug(" bodyText='" + bodyText + "'");
}
// the actual element name is either in localName or qName, depending
// on whether the parser is namespace aware
String name = localName;
if ((name == null) || (name.length() < 1)) {
name = qName;
}
// Fire "body" events for all relevant rules
List rules = (List) matches.pop();
if ((rules != null) && (rules.size() > 0)) {
String bodyText = this.bodyText.toString();
Substitutor substitutor = getSubstitutor();
if (substitutor!= null) {
bodyText = substitutor.substitute(bodyText);
}
for (int i = 0; i < rules.size(); i++) {
try {
Rule rule = (Rule) rules.get(i);
if (debug) {
log.debug(" Fire body() for " + rule);
}
rule.body(namespaceURI, name, bodyText);
} catch (Exception e) {
log.error("Body event threw exception", e);
throw createSAXException(e);
} catch (Error e) {
log.error("Body event threw error", e);
throw e;
}
}
} else {
if (debug) {
log.debug(" No rules found matching '" + match + "'.");
}
}
// Recover the body text from the surrounding element
bodyText = (StringBuffer) bodyTexts.pop();
if (debug) {
log.debug(" Popping body text '" + bodyText.toString() + "'");
}
// Fire "end" events for all relevant rules in reverse order
if (rules != null) {
for (int i = 0; i < rules.size(); i++) {
int j = (rules.size() - i) - 1;
try {
Rule rule = (Rule) rules.get(j);
if (debug) {
log.debug(" Fire end() for " + rule);
}
rule.end(namespaceURI, name);
} catch (Exception e) {
log.error("End event threw exception", e);
throw createSAXException(e);
} catch (Error e) {
log.error("End event threw error", e);
throw e;
}
}
}
// Recover the previous match expression
int slash = match.lastIndexOf('/");
if (slash >= 0) {
match = match.substring(0, slash);
} else {
match = "";
}
}
Process notification of the end of an XML element being reached. |
public void endPrefixMapping(String prefix) throws SAXException {
if (saxLog.isDebugEnabled()) {
saxLog.debug("endPrefixMapping(" + prefix + ")");
}
// Deregister this prefix mapping
ArrayStack stack = (ArrayStack) namespaces.get(prefix);
if (stack == null) {
return;
}
try {
stack.pop();
if (stack.empty())
namespaces.remove(prefix);
} catch (EmptyStackException e) {
throw createSAXException("endPrefixMapping popped too many times");
}
}
Process notification that a namespace prefix is going out of scope. |
public void error(SAXParseException exception) throws SAXException {
log.error("Parse Error at line " + exception.getLineNumber() +
" column " + exception.getColumnNumber() + ": " +
exception.getMessage(), exception);
if (errorHandler != null) {
errorHandler.error(exception);
}
}
Forward notification of a parsing error to the application supplied
error handler (if any). |
public void fatalError(SAXParseException exception) throws SAXException {
log.error("Parse Fatal Error at line " + exception.getLineNumber() +
" column " + exception.getColumnNumber() + ": " +
exception.getMessage(), exception);
if (errorHandler != null) {
errorHandler.fatalError(exception);
}
}
Forward notification of a fatal parsing error to the application
supplied error handler (if any). |
public String findNamespaceURI(String prefix) {
// ------------------------------------------------------------- Properties
ArrayStack nsStack = (ArrayStack) namespaces.get(prefix);
if (nsStack == null) {
return null;
}
try {
return ((String) nsStack.peek());
} catch (EmptyStackException e) {
return null;
}
}
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. |
public ClassLoader getClassLoader() {
if (this.classLoader != null) {
return (this.classLoader);
}
if (this.useContextClassLoader) {
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
if (classLoader != null) {
return (classLoader);
}
}
return (this.getClass().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
useContextClassLoader property is set to true
- The class loader used to load the Digester class itself.
|
public int getCount() {
return (stack.size());
}
Return the current depth of the element stack. |
public String getCurrentElementName() {
String elementName = match;
int lastSlash = elementName.lastIndexOf('/");
if (lastSlash >= 0) {
elementName = elementName.substring(lastSlash + 1);
}
return (elementName);
}
Return the name of the XML element that is currently being processed. |
public Map getCurrentNamespaces() {
if (!namespaceAware) {
log.warn("Digester is not namespace aware");
}
Map currentNamespaces = new HashMap();
Iterator nsIterator = namespaces.entrySet().iterator();
while (nsIterator.hasNext()) {
Map.Entry nsEntry = (Map.Entry) nsIterator.next();
try {
currentNamespaces.put(nsEntry.getKey(),
((ArrayStack) nsEntry.getValue()).peek());
} catch (RuntimeException e) {
// rethrow, after logging
log.error(e.getMessage(), e);
throw e;
}
}
return currentNamespaces;
}
Get the most current namespaces for all prefixes. |
public ContentHandler getCustomContentHandler() {
return customContentHandler;
}
|
public int getDebug() {
return (0);
} 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. |
public Locator getDocumentLocator() {
return locator;
}
Gets the document locator associated with our parser. |
public EntityResolver getEntityResolver() {
return entityResolver;
}
Return the Entity Resolver used by the SAX parser. |
public ErrorHandler getErrorHandler() {
return (this.errorHandler);
}
Return the error handler for this Digester. |
public SAXParserFactory getFactory() {
if (factory == null) {
factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(namespaceAware);
factory.setValidating(validating);
}
return (factory);
}
Return the SAXParserFactory we will use, creating one if necessary. |
public boolean getFeature(String feature) throws SAXNotSupportedException, SAXNotRecognizedException, ParserConfigurationException {
return (getFactory().getFeature(feature));
}
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. |
public Log getLogger() {
return log;
}
Return the current Logger associated with this instance of the Digester |
public String getMatch() {
return match;
}
Return the current rule match path |
public boolean getNamespaceAware() {
return (this.namespaceAware);
}
Return the "namespace aware" flag for parsers we create. |
public SAXParser getParser() {
// Return the parser we already created (if any)
if (parser != null) {
return (parser);
}
// Create a new parser
try {
if (validating && (schemaLocation != null)) {
// There is no portable way to specify the location of
// an xml schema to be applied to the input document, so
// we have to use parser-specific code for this. That code
// is hidden behind the ParserFeatureSetterFactory class.
Properties properties = new Properties();
properties.put("SAXParserFactory", getFactory());
if (schemaLocation != null) {
properties.put("schemaLocation", schemaLocation);
properties.put("schemaLanguage", schemaLanguage);
}
parser = ParserFeatureSetterFactory.newSAXParser(properties);
} else {
// The user doesn't want to use any non-portable parsing features,
// so we can just use the portable API here. Note that method
// getFactory returns a factory already configured with the
// appropriate namespaceAware and validating properties.
parser = getFactory().newSAXParser();
}
} catch (Exception e) {
log.error("Digester.getParser: ", e);
return (null);
}
return (parser);
}
Return the SAXParser we will use to parse the input stream. If there
is a problem creating the parser, return null. |
public Object getProperty(String property) throws SAXNotSupportedException, SAXNotRecognizedException {
return (getParser().getProperty(property));
}
Return the current value of the specified property for the underlying
XMLReader implementation.
See the saxproject website
for information about the standard SAX2 properties. |
public String getPublicId() {
return (this.publicId);
}
Return the public identifier of the DTD we are currently
parsing under, if any. |
public XMLReader getReader() {
try {
return (getXMLReader());
} catch (SAXException e) {
log.error("Cannot get XMLReader", e);
return (null);
}
} Deprecated! Use - getXMLReader() instead, which can throw a
SAXException if the reader cannot be instantiated
By setting the reader in the constructor, you can bypass JAXP and
be able to use digester in Weblogic 6.0. |
Map getRegistrations() {
return (entityValidator);
}
Return the set of DTD URL registrations, keyed by public identifier. |
public Object getRoot() {
return root;
}
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. |
public String getRuleNamespaceURI() {
return (getRules().getNamespaceURI());
}
Return the namespace URI that will be applied to all subsequently
added Rule objects. |
public Rules getRules() {
if (this.rules == null) {
this.rules = new RulesBase();
this.rules.setDigester(this);
}
return (this.rules);
}
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. |
List getRules(String match) {
return (getRules().match(match));
} Deprecated! Call - match() on the Rules
implementation returned by getRules()
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. |
public Log getSAXLogger() {
return saxLog;
}
Gets the logger used for logging SAX-related information.
Note the output is finely grained. |
public String getSchema() {
return (this.schemaLocation);
}
Return the XML Schema URI used for validating an XML instance. |
public String getSchemaLanguage() {
return (this.schemaLanguage);
}
Return the XML Schema language used when parsing. |
public StackAction getStackAction() {
return stackAction;
}
|
public Substitutor getSubstitutor() {
return substitutor;
}
Gets the Substitutor used to convert attributes and body text. |
public boolean getUseContextClassLoader() {
return useContextClassLoader;
}
Return the boolean as to whether the context classloader should be used. |
public boolean getValidating() {
return (this.validating);
}
Return the validating parser flag. |
public XMLReader getXMLReader() throws SAXException {
if (reader == null){
reader = getParser().getXMLReader();
}
reader.setDTDHandler(this);
reader.setContentHandler(this);
if (entityResolver == null){
reader.setEntityResolver(this);
} else {
reader.setEntityResolver(entityResolver);
}
reader.setErrorHandler(this);
return reader;
}
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. |
public void ignorableWhitespace(char[] buffer,
int start,
int len) throws SAXException {
if (saxLog.isDebugEnabled()) {
saxLog.debug("ignorableWhitespace(" +
new String(buffer, start, len) + ")");
}
; // No processing required
}
Process notification of ignorable whitespace received from the body of
an XML element. |
protected void initialize() {
// Perform lazy initialization as needed
; // Nothing required by default
}
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 #configure
only when the #configured flag is false.
Subclasses that override configure or who set configured
may find that this method may be called more than once.
|
public boolean isEmpty(String stackName) {
boolean result = true;
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack != null ) {
result = namedStack.isEmpty();
}
return result;
}
Is the stack with the given name empty?
Note: a stack is considered empty
if no objects have been pushed onto it yet.
|
public void log(String message) {
log.info(message);
} Deprecated! Call - getLogger() and use it's logging methods
Log a message to our associated logger. |
public void log(String message,
Throwable exception) {
log.error(message, exception);
} Deprecated! Call - getLogger() and use it's logging methods
Log a message and exception to our associated logger. |
public void notationDecl(String name,
String publicId,
String systemId) {
if (saxLog.isDebugEnabled()) {
saxLog.debug("notationDecl(" + name + "," + publicId + "," +
systemId + ")");
}
}
Receive notification of a notation declaration event. |
public Object parse(File file) throws IOException, SAXException {
configure();
InputSource input = new InputSource(new FileInputStream(file));
input.setSystemId(file.toURL().toString());
getXMLReader().parse(input);
cleanup();
return (root);
}
Parse the content of the specified file using this Digester. Returns
the root element from the object stack (if any). |
public Object parse(InputSource input) throws IOException, SAXException {
configure();
getXMLReader().parse(input);
cleanup();
return (root);
}
Parse the content of the specified input source using this Digester.
Returns the root element from the object stack (if any). |
public Object parse(InputStream input) throws IOException, SAXException {
configure();
InputSource is = new InputSource(input);
getXMLReader().parse(is);
cleanup();
return (root);
}
Parse the content of the specified input stream using this Digester.
Returns the root element from the object stack (if any). |
public Object parse(Reader reader) throws IOException, SAXException {
configure();
InputSource is = new InputSource(reader);
getXMLReader().parse(is);
cleanup();
return (root);
}
Parse the content of the specified reader using this Digester.
Returns the root element from the object stack (if any). |
public Object parse(String uri) throws IOException, SAXException {
configure();
InputSource is = createInputSourceFromURL(uri);
getXMLReader().parse(is);
cleanup();
return (root);
}
Parse the content of the specified URI using this Digester.
Returns the root element from the object stack (if any). |
public Object parse(URL url) throws IOException, SAXException {
configure();
InputSource is = createInputSourceFromURL(url);
getXMLReader().parse(is);
cleanup();
return (root);
}
Parse the content of the specified URL using this Digester.
Returns the root element from the object stack (if any). |
public Object peek() {
try {
return (stack.peek());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
}
Return the top object on the stack without removing it. If there are
no objects on the stack, return null. |
public Object peek(int n) {
try {
return (stack.peek(n));
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
}
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. |
public Object peek(String stackName) {
return peek(stackName, 0);
}
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.
|
public Object peek(String stackName,
int n) {
Object result = null;
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack == null ) {
if (log.isDebugEnabled()) {
log.debug("Stack '" + stackName + "' is empty");
}
throw new EmptyStackException();
} else {
result = namedStack.peek(n);
}
return result;
}
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.
|
public Object peekParams() {
try {
return (params.peek());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
}
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 #params .
|
public Object peekParams(int n) {
try {
return (params.peek(n));
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
}
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 #params .
|
public Object pop() {
try {
Object popped = stack.pop();
if (stackAction != null) {
popped = stackAction.onPop(this, null, popped);
}
return popped;
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
}
Pop the top object off of the stack, and return it. If there are
no objects on the stack, return null. |
public Object pop(String stackName) {
Object result = null;
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack == null) {
if (log.isDebugEnabled()) {
log.debug("Stack '" + stackName + "' is empty");
}
throw new EmptyStackException();
}
result = namedStack.pop();
if (stackAction != null) {
result = stackAction.onPop(this, stackName, result);
}
return result;
}
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.
|
public Object popParams() {
try {
if (log.isTraceEnabled()) {
log.trace("Popping params");
}
return (params.pop());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
}
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 #params .
|
public void processingInstruction(String target,
String data) throws SAXException {
if (customContentHandler != null) {
// forward calls instead of handling them here
customContentHandler.processingInstruction(target, data);
return;
}
if (saxLog.isDebugEnabled()) {
saxLog.debug("processingInstruction('" + target + "','" + data + "')");
}
; // No processing is required
}
Process notification of a processing instruction that was encountered. |
public void push(Object object) {
if (stackAction != null) {
object = stackAction.onPush(this, null, object);
}
if (stack.size() == 0) {
root = object;
}
stack.push(object);
}
Push a new object onto the top of the object stack. |
public void push(String stackName,
Object value) {
if (stackAction != null) {
value = stackAction.onPush(this, stackName, value);
}
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack == null) {
namedStack = new ArrayStack();
stacksByName.put(stackName, namedStack);
}
namedStack.push(value);
}
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. |
public void pushParams(Object object) {
if (log.isTraceEnabled()) {
log.trace("Pushing params");
}
params.push(object);
}
Push a new object onto the top of the parameters stack.
The parameters stack is used to store CallMethodRule parameters.
See #params .
|
public void register(String publicId,
URL entityURL) {
if (log.isDebugEnabled()) {
log.debug("register('" + publicId + "', '" + entityURL + "'");
}
entityValidator.put(publicId, 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. 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 #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.)
|
public void register(String publicId,
String entityURL) {
if (log.isDebugEnabled()) {
log.debug("register('" + publicId + "', '" + entityURL + "'");
}
try {
entityValidator.put(publicId, new URL(entityURL));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Malformed URL '" + entityURL
+ "' : " + e.getMessage());
}
}
|
public void resetRoot() {
root = null;
}
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. |
public InputSource resolveEntity(String publicId,
String systemId) throws SAXException {
if (saxLog.isDebugEnabled()) {
saxLog.debug("resolveEntity('" + publicId + "', '" + systemId + "')");
}
if (publicId != null)
this.publicId = publicId;
// Has this system identifier been registered?
URL entityURL = null;
if (publicId != null) {
entityURL = (URL) entityValidator.get(publicId);
}
// Redirect the schema location to a local destination
if (schemaLocation != null && entityURL == null && systemId != null){
entityURL = (URL) entityValidator.get(systemId);
}
if (entityURL == null) {
if (systemId == null) {
// cannot resolve
if (log.isDebugEnabled()) {
log.debug(" Cannot resolve entity: '" + entityURL + "'");
}
return (null);
} else {
// try to resolve using system ID
if (log.isDebugEnabled()) {
log.debug(" Trying to resolve using system ID '" + systemId + "'");
}
try {
entityURL = new URL(systemId);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Malformed URL '" + systemId
+ "' : " + e.getMessage());
}
}
}
// Return an input source to our alternative URL
if (log.isDebugEnabled()) {
log.debug(" Resolving to alternate DTD '" + entityURL + "'");
}
try {
return createInputSourceFromURL(entityURL);
} catch (Exception e) {
throw createSAXException(e);
}
}
Resolve the requested external entity. |
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
Set the class loader to be used for instantiating application objects
when required. |
public void setCustomContentHandler(ContentHandler handler) {
customContentHandler = 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. 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.
|
public void setDebug(int debug) {
; // No action is taken
} 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. |
public void setDocumentLocator(Locator locator) {
if (saxLog.isDebugEnabled()) {
saxLog.debug("setDocumentLocator(" + locator + ")");
}
this.locator = locator;
}
Sets the document locator associated with our parser. |
public void setEntityResolver(EntityResolver entityResolver) {
this.entityResolver = entityResolver;
}
Set the EntityResolver used by SAX when resolving
public id and system id.
This must be called before the first call to parse(). |
public void setErrorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
Set the error handler for this Digester. |
public void setFeature(String feature,
boolean value) throws SAXNotSupportedException, SAXNotRecognizedException, ParserConfigurationException {
getFactory().setFeature(feature, 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. In order to be
effective, this method must be called before the
getParser() method is called for the first time, either
directly or indirectly. |
public void setLogger(Log log) {
this.log = log;
}
Set the current logger for this Digester. |
public void setNamespaceAware(boolean namespaceAware) {
this.namespaceAware = namespaceAware;
}
Set the "namespace aware" flag for parsers we create. |
< |