Methods Summary |
---|
public void | addCallMethod(java.lang.String pattern, java.lang.String methodName)Add an "call method" rule for a method which accepts no arguments.
addRule(
pattern,
new CallMethodRule(methodName));
|
public void | addCallMethod(java.lang.String pattern, java.lang.String methodName, int paramCount)Add an "call method" rule for the specified parameters.
addRule(pattern,
new CallMethodRule(methodName, paramCount));
|
public void | addCallMethod(java.lang.String pattern, java.lang.String methodName, int paramCount, java.lang.String[] paramTypes)Add an "call method" rule for the specified parameters.
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.
addRule(pattern,
new CallMethodRule(
methodName,
paramCount,
paramTypes));
|
public void | addCallMethod(java.lang.String pattern, java.lang.String methodName, int paramCount, java.lang.Class[] paramTypes)Add an "call method" rule for the specified parameters.
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.
addRule(pattern,
new CallMethodRule(
methodName,
paramCount,
paramTypes));
|
public void | addCallParam(java.lang.String pattern, int paramIndex)Add a "call parameter" rule for the specified parameters.
addRule(pattern,
new CallParamRule(paramIndex));
|
public void | addCallParam(java.lang.String pattern, int paramIndex, java.lang.String attributeName)Add a "call parameter" rule for the specified parameters.
addRule(pattern,
new CallParamRule(paramIndex, attributeName));
|
public void | addCallParam(java.lang.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.
addRule(pattern,
new CallParamRule(paramIndex, fromStack));
|
public void | addCallParam(java.lang.String pattern, int paramIndex, int stackIndex)Add a "call parameter" rule that sets a parameter from the stack.
This takes a parameter from the given position on the stack.
addRule(pattern,
new CallParamRule(paramIndex, stackIndex));
|
public void | addCallParamPath(java.lang.String pattern, int 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.
addRule(pattern, new PathCallParamRule(paramIndex));
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.String className)Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated.
addFactoryCreate(pattern, className, false);
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.Class clazz)Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated.
addFactoryCreate(pattern, clazz, false);
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.String className, java.lang.String attributeName)Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated.
addFactoryCreate(pattern, className, attributeName, false);
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.Class clazz, java.lang.String attributeName)Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated.
addFactoryCreate(pattern, clazz, attributeName, false);
|
public void | addFactoryCreate(java.lang.String pattern, ObjectCreationFactory creationFactory)Add a "factory create" rule for the specified parameters.
Exceptions thrown during the object creation process will be propagated.
addFactoryCreate(pattern, creationFactory, false);
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.String className, boolean ignoreCreateExceptions)Add a "factory create" rule for the specified parameters.
addRule(
pattern,
new FactoryCreateRule(className, ignoreCreateExceptions));
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.Class clazz, boolean ignoreCreateExceptions)Add a "factory create" rule for the specified parameters.
addRule(
pattern,
new FactoryCreateRule(clazz, ignoreCreateExceptions));
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.String className, java.lang.String attributeName, boolean ignoreCreateExceptions)Add a "factory create" rule for the specified parameters.
addRule(
pattern,
new FactoryCreateRule(className, attributeName, ignoreCreateExceptions));
|
public void | addFactoryCreate(java.lang.String pattern, java.lang.Class clazz, java.lang.String attributeName, boolean ignoreCreateExceptions)Add a "factory create" rule for the specified parameters.
addRule(
pattern,
new FactoryCreateRule(clazz, attributeName, ignoreCreateExceptions));
|
public void | addFactoryCreate(java.lang.String pattern, ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions)Add a "factory create" rule for the specified parameters.
creationFactory.setDigester(this);
addRule(pattern,
new FactoryCreateRule(creationFactory, ignoreCreateExceptions));
|
public void | addObjectCreate(java.lang.String pattern, java.lang.String className)Add an "object create" rule for the specified parameters.
addRule(pattern,
new ObjectCreateRule(className));
|
public void | addObjectCreate(java.lang.String pattern, java.lang.Class clazz)Add an "object create" rule for the specified parameters.
addRule(pattern,
new ObjectCreateRule(clazz));
|
public void | addObjectCreate(java.lang.String pattern, java.lang.String className, java.lang.String attributeName)Add an "object create" rule for the specified parameters.
addRule(pattern,
new ObjectCreateRule(className, attributeName));
|
public void | addObjectCreate(java.lang.String pattern, java.lang.String attributeName, java.lang.Class clazz)Add an "object create" rule for the specified parameters.
addRule(pattern,
new ObjectCreateRule(attributeName, clazz));
|
public void | addObjectParam(java.lang.String pattern, int paramIndex, java.lang.Object 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).
addRule(pattern,
new ObjectParamRule(paramIndex, paramObj));
|
public void | addRule(java.lang.String pattern, Rule rule)Register a new Rule matching the specified pattern.
This method sets the Digester property on the rule.
rule.setDigester(this);
getRules().add(pattern, rule);
|
public void | addRuleSet(RuleSet ruleSet)Register a set of Rule instances defined in a 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);
|
public void | addSetNext(java.lang.String pattern, java.lang.String methodName)Add a "set next" rule for the specified parameters.
addRule(pattern,
new SetNextRule(methodName));
|
public void | addSetNext(java.lang.String pattern, java.lang.String methodName, java.lang.String paramType)Add a "set next" rule for the specified parameters.
addRule(pattern,
new SetNextRule(methodName, paramType));
|
public void | addSetProperties(java.lang.String pattern)Add a "set properties" rule for the specified parameters.
addRule(pattern,
new SetPropertiesRule());
|
public void | addSetProperties(java.lang.String pattern, java.lang.String attributeName, java.lang.String propertyName)Add a "set properties" rule with a single overridden parameter.
See {@link SetPropertiesRule#SetPropertiesRule(String attributeName, String propertyName)}
addRule(pattern,
new SetPropertiesRule(attributeName, propertyName));
|
public void | addSetProperties(java.lang.String pattern, java.lang.String[] attributeNames, java.lang.String[] propertyNames)Add a "set properties" rule with overridden parameters.
See {@link SetPropertiesRule#SetPropertiesRule(String [] attributeNames, String [] propertyNames)}
addRule(pattern,
new SetPropertiesRule(attributeNames, propertyNames));
|
public void | addSetProperty(java.lang.String pattern, java.lang.String name, java.lang.String value)Add a "set property" rule for the specified parameters.
addRule(pattern,
new SetPropertyRule(name, value));
|
public void | addSetRoot(java.lang.String pattern, java.lang.String methodName)Add {@link SetRootRule} with the specified parameters.
addRule(pattern,
new SetRootRule(methodName));
|
public void | addSetRoot(java.lang.String pattern, java.lang.String methodName, java.lang.String paramType)Add {@link SetRootRule} with the specified parameters.
addRule(pattern,
new SetRootRule(methodName, paramType));
|
public void | addSetTop(java.lang.String pattern, java.lang.String methodName)Add a "set top" rule for the specified parameters.
addRule(pattern,
new SetTopRule(methodName));
|
public void | addSetTop(java.lang.String pattern, java.lang.String methodName, java.lang.String paramType)Add a "set top" rule for the specified parameters.
addRule(pattern,
new SetTopRule(methodName, paramType));
|
public void | characters(char[] buffer, int start, int length)Process notification of character data received from the body of
an XML element.
if (saxLog.isDebugEnabled()) {
saxLog.debug("characters(" + new String(buffer, start, length) + ")");
}
bodyText.append(buffer, start, length);
|
public void | clear()Clear the current contents of the object stack.
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.
match = "";
bodyTexts.clear();
params.clear();
publicId = null;
stack.clear();
log = null;
saxLog = null;
configured = false;
|
protected void | configure()
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 {@link #initialize}
or the code should take responsibility by checking and setting the
{@link #configured} flag.
// Do not configure more than once
if (configured) {
return;
}
log = LogFactory.getLog("org.apache.commons.digester.Digester");
saxLog = LogFactory.getLog("org.apache.commons.digester.Digester.sax");
// 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;
|
public org.xml.sax.SAXException | createSAXException(java.lang.String message, java.lang.Exception e)Create a SAX exception which also understands about the location in
the digester file where the exception occurs
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 (" + locator.getLineNumber() + ", " +
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);
}
|
public org.xml.sax.SAXException | createSAXException(java.lang.Exception e)Create a SAX exception which also understands about the location in
the digester file where the exception occurs
if (e instanceof InvocationTargetException) {
Throwable t = ((InvocationTargetException) e).getTargetException();
if ((t != null) && (t instanceof Exception)) {
e = (Exception) t;
}
}
return createSAXException(e.getMessage(), e);
|
public org.xml.sax.SAXException | createSAXException(java.lang.String message)Create a SAX exception which also understands about the location in
the digester file where the exception occurs
return createSAXException(message, null);
|
public void | endDocument()Process notification of the end of the document being reached.
if (saxLog.isDebugEnabled()) {
if (getCount() > 1) {
saxLog.debug("endDocument(): " + getCount() +
" elements left");
} else {
saxLog.debug("endDocument()");
}
}
while (getCount() > 1) {
pop();
}
// 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();
|
public void | endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)Process notification of the end of an XML element being reached.
boolean debug = log.isDebugEnabled();
if (debug) {
if (saxLog.isDebugEnabled()) {
saxLog.debug("endElement(" + namespaceURI + "," + localName +
"," + qName + ")");
}
log.debug(" match='" + match + "'");
log.debug(" bodyText='" + bodyText + "'");
}
// Parse system properties
bodyText = updateBodyText(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();
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 = "";
}
|
public void | endPrefixMapping(java.lang.String prefix)Process notification that a namespace prefix is going out of scope.
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");
}
|
public void | error(org.xml.sax.SAXParseException exception)Forward notification of a parsing error to the application supplied
error handler (if any).
log.error("Parse Error at line " + exception.getLineNumber() +
" column " + exception.getColumnNumber() + ": " +
exception.getMessage(), exception);
if (errorHandler != null) {
errorHandler.error(exception);
}
|
public void | fatalError(org.xml.sax.SAXParseException exception)Forward notification of a fatal parsing error to the application
supplied error handler (if any).
log.error("Parse Fatal Error at line " + exception.getLineNumber() +
" column " + exception.getColumnNumber() + ": " +
exception.getMessage(), exception);
if (errorHandler != null) {
errorHandler.fatalError(exception);
}
|
public java.lang.String | findNamespaceURI(java.lang.String prefix)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.
// ------------------------------------------------------------- Properties
ArrayStack stack = (ArrayStack) namespaces.get(prefix);
if (stack == null) {
return (null);
}
try {
return ((String) stack.peek());
} catch (EmptyStackException e) {
return (null);
}
|
public java.lang.ClassLoader | 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.
if (this.classLoader != null) {
return (this.classLoader);
}
if (this.useContextClassLoader) {
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
if (classLoader != null) {
return (classLoader);
}
}
return (this.getClass().getClassLoader());
|
public int | getCount()Return the current depth of the element stack.
return (stack.size());
|
public java.lang.String | getCurrentElementName()Return the name of the XML element that is currently being processed.
String elementName = match;
int lastSlash = elementName.lastIndexOf('/");
if (lastSlash >= 0) {
elementName = elementName.substring(lastSlash + 1);
}
return (elementName);
|
public int | getDebug()Return the debugging detail level of our currently enabled logger.
return (0);
|
public org.xml.sax.Locator | getDocumentLocator()Gets the document locator associated with our parser.
return locator;
|
public org.xml.sax.EntityResolver | getEntityResolver()Return the Entity Resolver used by the SAX parser.
return entityResolver;
|
public org.xml.sax.ErrorHandler | getErrorHandler()Return the error handler for this Digester.
return (this.errorHandler);
|
public javax.xml.parsers.SAXParserFactory | getFactory()Return the SAXParserFactory we will use, creating one if necessary.
if (factory == null) {
factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(namespaceAware);
factory.setValidating(validating);
}
return (factory);
|
public boolean | getFeature(java.lang.String feature)Returns a flag indicating whether the requested feature is supported
by the underlying implementation of org.xml.sax.XMLReader .
See
for information about the standard SAX2 feature flags.
return (getFactory().getFeature(feature));
|
public org.apache.juli.logging.Log | getLogger()Return the current Logger associated with this instance of the Digester
return log;
|
public java.lang.String | getMatch()Return the current rule match path
return match;
|
public boolean | getNamespaceAware()Return the "namespace aware" flag for parsers we create.
return (this.namespaceAware);
|
public javax.xml.parsers.SAXParser | getParser()Return the SAXParser we will use to parse the input stream. If there
is a problem creating the parser, return null .
// Return the parser we already created (if any)
if (parser != null) {
return (parser);
}
// Create a new parser
try {
if (validating) {
Properties properties = new Properties();
properties.put("SAXParserFactory", getFactory());
if (schemaLocation != null) {
properties.put("schemaLocation", schemaLocation);
properties.put("schemaLanguage", schemaLanguage);
}
parser = ParserFeatureSetterFactory.newSAXParser(properties); } else {
parser = getFactory().newSAXParser();
}
} catch (Exception e) {
log.error("Digester.getParser: ", e);
return (null);
}
return (parser);
|
public java.lang.Object | getProperty(java.lang.String property)Return the current value of the specified property for the underlying
XMLReader implementation.
See
for information about the standard SAX2 properties.
return (getParser().getProperty(property));
|
public java.lang.String | getPublicId()Return the public identifier of the DTD we are currently
parsing under, if any.
return (this.publicId);
|
public org.xml.sax.XMLReader | getReader()By setting the reader in the constructor, you can bypass JAXP and
be able to use digester in Weblogic 6.0.
try {
return (getXMLReader());
} catch (SAXException e) {
log.error("Cannot get XMLReader", e);
return (null);
}
|
java.util.Map | getRegistrations()Return the set of DTD URL registrations, keyed by public identifier.
return (entityValidator);
|
public java.lang.Object | getRoot()When the Digester is being used as a SAXContentHandler,
this method allows you to access the root object that has been
created after parsing.
return root;
|
public java.lang.String | getRuleNamespaceURI()Return the namespace URI that will be applied to all subsequently
added Rule objects.
return (getRules().getNamespaceURI());
|
java.util.List | getRules(java.lang.String match)Return the set of rules that apply to the specified match position.
The selected rules are those that match exactly, or those rules
that specify a suffix match and the tail of the rule matches the
current match position. Exact matches have precedence over
suffix matches, then (among suffix matches) the longest match
is preferred.
return (getRules().match(match));
|
public Rules | getRules()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.
if (this.rules == null) {
this.rules = new RulesBase();
this.rules.setDigester(this);
}
return (this.rules);
|
public org.apache.juli.logging.Log | getSAXLogger()Gets the logger used for logging SAX-related information.
Note the output is finely grained.
return saxLog;
|
public java.lang.String | getSchema()Return the XML Schema URI used for validating an XML instance.
return (this.schemaLocation);
|
public java.lang.String | getSchemaLanguage()Return the XML Schema language used when parsing.
return (this.schemaLanguage);
|
public boolean | getUseContextClassLoader()Return the boolean as to whether the context classloader should be used.
return useContextClassLoader;
|
public boolean | getValidating()Return the validating parser flag.
return (this.validating);
|
public org.xml.sax.XMLReader | getXMLReader()Return the XMLReader to be used for parsing the input document.
FIX ME: there is a bug in JAXP/XERCES that prevent the use of a
parser that contains a schema with a DTD.
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;
|
public void | ignorableWhitespace(char[] buffer, int start, int len)Process notification of ignorable whitespace received from the body of
an XML element.
if (saxLog.isDebugEnabled()) {
saxLog.debug("ignorableWhitespace(" +
new String(buffer, start, len) + ")");
}
; // No processing required
|
protected void | initialize()
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 {@link #configure}
only when the {@link #configured} flag is false.
Subclasses that override configure or who set configured
may find that this method may be called more than once.
// Perform lazy initialization as needed
; // Nothing required by default
|
public boolean | isEmpty(java.lang.String stackName)Is the stack with the given name empty?
Note: a stack is considered empty
if no objects have been pushed onto it yet.
boolean result = true;
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack != null ) {
result = namedStack.isEmpty();
}
return result;
|
public void | log(java.lang.String message)Log a message to our associated logger.
log.info(message);
|
public void | log(java.lang.String message, java.lang.Throwable exception)Log a message and exception to our associated logger.
log.error(message, exception);
|
public void | notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Receive notification of a notation declaration event.
if (saxLog.isDebugEnabled()) {
saxLog.debug("notationDecl(" + name + "," + publicId + "," +
systemId + ")");
}
|
public java.lang.Object | parse(java.io.File file)Parse the content of the specified file using this Digester. Returns
the root element from the object stack (if any).
configure();
InputSource input = new InputSource(new FileInputStream(file));
input.setSystemId("file://" + file.getAbsolutePath());
getXMLReader().parse(input);
return (root);
|
public java.lang.Object | parse(org.xml.sax.InputSource input)Parse the content of the specified input source using this Digester.
Returns the root element from the object stack (if any).
configure();
getXMLReader().parse(input);
return (root);
|
public java.lang.Object | parse(java.io.InputStream input)Parse the content of the specified input stream using this Digester.
Returns the root element from the object stack (if any).
configure();
InputSource is = new InputSource(input);
getXMLReader().parse(is);
return (root);
|
public java.lang.Object | parse(java.io.Reader reader)Parse the content of the specified reader using this Digester.
Returns the root element from the object stack (if any).
configure();
InputSource is = new InputSource(reader);
getXMLReader().parse(is);
return (root);
|
public java.lang.Object | parse(java.lang.String uri)Parse the content of the specified URI using this Digester.
Returns the root element from the object stack (if any).
configure();
InputSource is = new InputSource(uri);
getXMLReader().parse(is);
return (root);
|
public java.lang.Object | peek()Return the top object on the stack without removing it. If there are
no objects on the stack, return null .
try {
return (stack.peek());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
|
public java.lang.Object | peek(int n)Return the n'th object down the stack, where 0 is the top element
and [getCount()-1] is the bottom element. If the specified index
is out of range, return null .
try {
return (stack.peek(n));
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
|
public java.lang.Object | peek(java.lang.String stackName)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.
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();
}
return result;
|
public java.lang.Object | peekParams()Return the top object on the parameters stack without removing it. If there are
no objects on the stack, return null .
The parameters stack is used to store CallMethodRule parameters.
See {@link #params}.
try {
return (params.peek());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
|
public java.lang.Object | peekParams(int n)Return the n'th object down the parameters stack, where 0 is the top element
and [getCount()-1] is the bottom element. If the specified index
is out of range, return null .
The parameters stack is used to store CallMethodRule parameters.
See {@link #params}.
try {
return (params.peek(n));
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
|
public java.lang.Object | pop()Pop the top object off of the stack, and return it. If there are
no objects on the stack, return null .
try {
return (stack.pop());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
|
public java.lang.Object | pop(java.lang.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.
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.pop();
}
return result;
|
public java.lang.Object | popParams()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 {@link #params}.
try {
if (log.isTraceEnabled()) {
log.trace("Popping params");
}
return (params.pop());
} catch (EmptyStackException e) {
log.warn("Empty stack (returning null)");
return (null);
}
|
public void | processingInstruction(java.lang.String target, java.lang.String data)Process notification of a processing instruction that was encountered.
if (saxLog.isDebugEnabled()) {
saxLog.debug("processingInstruction('" + target + "','" + data + "')");
}
; // No processing is required
|
public void | push(java.lang.Object object)Push a new object onto the top of the object stack.
if (stack.size() == 0) {
root = object;
}
stack.push(object);
|
public void | push(java.lang.String stackName, java.lang.Object 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.
ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
if (namedStack == null) {
namedStack = new ArrayStack();
stacksByName.put(stackName, namedStack);
}
namedStack.push(value);
|
public void | pushParams(java.lang.Object object)Push a new object onto the top of the parameters stack.
The parameters stack is used to store CallMethodRule parameters.
See {@link #params}.
if (log.isTraceEnabled()) {
log.trace("Pushing params");
}
params.push(object);
|
public void | register(java.lang.String publicId, java.lang.String 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 {@link #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.)
if (log.isDebugEnabled()) {
log.debug("register('" + publicId + "', '" + entityURL + "'");
}
entityValidator.put(publicId, entityURL);
|
public void | reset()
root = null;
setErrorHandler(null);
clear();
|
public org.xml.sax.InputSource | resolveEntity(java.lang.String publicId, java.lang.String systemId)Resolve the requested external entity.
if (saxLog.isDebugEnabled()) {
saxLog.debug("resolveEntity('" + publicId + "', '" + systemId + "')");
}
if (publicId != null)
this.publicId = publicId;
// Has this system identifier been registered?
String entityURL = null;
if (publicId != null) {
entityURL = (String) entityValidator.get(publicId);
}
// Redirect the schema location to a local destination
if (schemaLocation != null && entityURL == null && systemId != null){
entityURL = (String)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 + "'");
}
entityURL = systemId;
}
}
// Return an input source to our alternative URL
if (log.isDebugEnabled()) {
log.debug(" Resolving to alternate DTD '" + entityURL + "'");
}
try {
return (new InputSource(entityURL));
} catch (Exception e) {
throw createSAXException(e);
}
|
public void | setClassLoader(java.lang.ClassLoader classLoader)Set the class loader to be used for instantiating application objects
when required.
this.classLoader = classLoader;
|
public void | setDebug(int debug)Set the debugging detail level of our currently enabled logger.
; // No action is taken
|
public void | setDocumentLocator(org.xml.sax.Locator locator)Sets the document locator associated with our parser.
if (saxLog.isDebugEnabled()) {
saxLog.debug("setDocumentLocator(" + locator + ")");
}
this.locator = locator;
|
public void | setEntityResolver(org.xml.sax.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() .
this.entityResolver = entityResolver;
|
public void | setErrorHandler(org.xml.sax.ErrorHandler errorHandler)Set the error handler for this Digester.
this.errorHandler = errorHandler;
|
public void | setFeature(java.lang.String feature, boolean value)Sets a flag indicating whether the requested feature is supported
by the underlying implementation of org.xml.sax.XMLReader .
See
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.
getFactory().setFeature(feature, value);
|
public void | setLogger(org.apache.juli.logging.Log log)Set the current logger for this Digester.
this.log = log;
|
public void | setNamespaceAware(boolean namespaceAware)Set the "namespace aware" flag for parsers we create.
this.namespaceAware = namespaceAware;
|
public void | setProperty(java.lang.String property, java.lang.Object value)Set the current value of the specified property for the underlying
XMLReader implementation.
See
for information about the standard SAX2 properties.
getParser().setProperty(property, value);
|
public void | setPublicId(java.lang.String publicId)Set the publid id of the current file being parse.
this.publicId = publicId;
|
public void | setRuleNamespaceURI(java.lang.String ruleNamespaceURI)Set the namespace URI that will be applied to all subsequently
added Rule objects.
getRules().setNamespaceURI(ruleNamespaceURI);
|
public void | setRules(Rules rules)Set the Rules implementation object containing our
rules collection and associated matching policy.
this.rules = rules;
this.rules.setDigester(this);
|
public void | setSAXLogger(org.apache.juli.logging.Log saxLog)Sets the logger used for logging SAX-related information.
Note the output is finely grained.
this.saxLog = saxLog;
|
public void | setSchema(java.lang.String schemaLocation)Set the XML Schema URI used for validating a XML Instance.
this.schemaLocation = schemaLocation;
|
public void | setSchemaLanguage(java.lang.String schemaLanguage)Set the XML Schema language used when parsing. By default, we use W3C.
this.schemaLanguage = schemaLanguage;
|
public void | setUseContextClassLoader(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. If not
using Context ClassLoader, then the class-loading defaults to
using the calling-class' ClassLoader.
useContextClassLoader = use;
|
public void | setValidating(boolean validating)Set the validating parser flag. This must be called before
parse() is called the first time.
this.validating = validating;
|
public void | skippedEntity(java.lang.String name)Process notification of a skipped entity.
if (saxLog.isDebugEnabled()) {
saxLog.debug("skippedEntity(" + name + ")");
}
; // No processing required
|
public void | startDocument()Process notification of the beginning of the document being reached.
if (saxLog.isDebugEnabled()) {
saxLog.debug("startDocument()");
}
// ensure that the digester is properly configured, as
// the digester could be used as a SAX ContentHandler
// rather than via the parse() methods.
configure();
|
public void | startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes list)Process notification of the start of an XML element being reached.
boolean debug = log.isDebugEnabled();
if (saxLog.isDebugEnabled()) {
saxLog.debug("startElement(" + namespaceURI + "," + localName + "," +
qName + ")");
}
// Parse system properties
list = updateAttributes(list);
// Save the body text accumulated for our surrounding element
bodyTexts.push(bodyText);
if (debug) {
log.debug(" Pushing body text '" + bodyText.toString() + "'");
}
bodyText = new StringBuffer();
// 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;
}
// Compute the current matching rule
StringBuffer sb = new StringBuffer(match);
if (match.length() > 0) {
sb.append('/");
}
sb.append(name);
match = sb.toString();
if (debug) {
log.debug(" New match='" + match + "'");
}
// Fire "begin" events for all relevant rules
List rules = getRules().match(namespaceURI, match);
matches.push(rules);
if ((rules != null) && (rules.size() > 0)) {
for (int i = 0; i < rules.size(); i++) {
try {
Rule rule = (Rule) rules.get(i);
if (debug) {
log.debug(" Fire begin() for " + rule);
}
rule.begin(namespaceURI, name, list);
} catch (Exception e) {
log.error("Begin event threw exception", e);
throw createSAXException(e);
} catch (Error e) {
log.error("Begin event threw error", e);
throw e;
}
}
} else {
if (debug) {
log.debug(" No rules found matching '" + match + "'.");
}
}
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String namespaceURI)Process notification that a namespace prefix is coming in to scope.
if (saxLog.isDebugEnabled()) {
saxLog.debug("startPrefixMapping(" + prefix + "," + namespaceURI + ")");
}
// Register this prefix mapping
ArrayStack stack = (ArrayStack) namespaces.get(prefix);
if (stack == null) {
stack = new ArrayStack();
namespaces.put(prefix, stack);
}
stack.push(namespaceURI);
|
public void | unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notation)Receive notification of an unparsed entity declaration event.
if (saxLog.isDebugEnabled()) {
saxLog.debug("unparsedEntityDecl(" + name + "," + publicId + "," +
systemId + "," + notation + ")");
}
|
private org.xml.sax.Attributes | updateAttributes(org.xml.sax.Attributes list)Returns an attributes list which contains all the attributes
passed in, with any text of form "${xxx}" in an attribute value
replaced by the appropriate value from the system property.
if (list.getLength() == 0) {
return list;
}
AttributesImpl newAttrs = new AttributesImpl(list);
int nAttributes = newAttrs.getLength();
for (int i = 0; i < nAttributes; ++i) {
String value = newAttrs.getValue(i);
try {
String newValue =
IntrospectionUtils.replaceProperties(value, null, source);
if (value != newValue) {
newAttrs.setValue(i, newValue);
}
}
catch (Exception e) {
// ignore - let the attribute have its original value
}
}
return newAttrs;
|
private java.lang.StringBuffer | updateBodyText(java.lang.StringBuffer bodyText)Return a new StringBuffer containing the same contents as the
input buffer, except that data of form ${varname} have been
replaced by the value of that var as defined in the system property.
String in = bodyText.toString();
String out;
try {
out = IntrospectionUtils.replaceProperties(in, null, source);
} catch(Exception e) {
return bodyText; // return unchanged data
}
if (out == in) {
// No substitutions required. Don't waste memory creating
// a new buffer
return bodyText;
} else {
return new StringBuffer(out);
}
|
public void | warning(org.xml.sax.SAXParseException exception)Forward notification of a parse warning to the application supplied
error handler (if any).
if (errorHandler != null) {
log.warn("Parse Warning Error at line " + exception.getLineNumber() +
" column " + exception.getColumnNumber() + ": " +
exception.getMessage(), exception);
errorHandler.warning(exception);
}
|