| Method from org.apache.tomcat.util.digester.Digester Detail: |
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 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 (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. |
public void clear() {
match = "";
bodyTexts.clear();
params.clear();
publicId = null;
stack.clear();
log = null;
saxLog = null;
configured = false;
}
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. |
protected void configure() {
// 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;
}
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 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 (" + 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);
}
}
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()");
}
}
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();
}
Process notification of the end of the document being reached. |
public void endElement(String namespaceURI,
String localName,
String qName) throws SAXException {
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 + "'.");
}
if (rulesValidation) {
log.warn(" 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 stack = (ArrayStack) namespaces.get(prefix);
if (stack == null) {
return (null);
}
try {
return ((String) stack.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 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 Map getFakeAttributes() {
return (this.fakeAttributes);
}
Return the fake attributes list. |
public boolean getFeature(String feature) throws SAXNotSupportedException, SAXNotRecognizedException, ParserConfigurationException {
return (getFactory().getFeature(feature));
}
|
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) {
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);
}
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));
}
|
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;
}
When the Digester is being used as a SAXContentHandler,
this method allows you to access the root object that has been
created after parsing. |
public 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 boolean getRulesValidation() {
return (this.rulesValidation);
}
Return the rules validation flag. |
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 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 boolean isFakeAttribute(Object object,
String name) {
if (fakeAttributes == null) {
return false;
}
List< String > result = fakeAttributes.get(object.getClass());
if (result == null) {
result = fakeAttributes.get(Object.class);
}
if (result == null) {
return false;
} else {
return result.contains(name);
}
}
Determine if an attribute is a fake attribute. |
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://" + file.getAbsolutePath());
getXMLReader().parse(input);
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);
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);
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);
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 = new InputSource(uri);
getXMLReader().parse(is);
return (root);
}
Parse the content of the specified URI 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) {
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;
}
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 {
return (stack.pop());
} 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();
} else {
result = namedStack.pop();
}
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 (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 (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) {
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,
String 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 reset() {
root = null;
setErrorHandler(null);
clear();
}
|
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?
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);
}
}
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 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 setFakeAttributes(Map fakeAttributes) {
this.fakeAttributes = fakeAttributes;
}
|
public void setFeature(String feature,
boolean value) throws SAXNotSupportedException, SAXNotRecognizedException, ParserConfigurationException {
getFactory().setFeature(feature, value);
}
|
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. |
public void setProperty(String property,
Object value) throws SAXNotSupportedException, SAXNotRecognizedException {
getParser().setProperty(property, value);
}
|
public void setPublicId(String publicId) {
this.publicId = publicId;
}
Set the publid id of the current file being parse. |
public void setRuleNamespaceURI(String ruleNamespaceURI) {
getRules().setNamespaceURI(ruleNamespaceURI);
}
Set the namespace URI that will be applied to all subsequently
added Rule objects. |
public void setRules(Rules rules) {
this.rules = rules;
this.rules.setDigester(this);
}
Set the Rules implementation object containing our
rules collection and associated matching policy. |
public void setRulesValidation(boolean rulesValidation) {
this.rulesValidation = rulesValidation;
}
Set the rules validation flag. This must be called before
parse() is called the first time. |
public void setSAXLogger(Log saxLog) {
this.saxLog = saxLog;
}
Sets the logger used for logging SAX-related information.
Note the output is finely grained. |
public void setSchema(String schemaLocation) {
this.schemaLocation = schemaLocation;
}
Set the XML Schema URI used for validating a XML Instance. |
public void setSchemaLanguage(String schemaLanguage) {
this.schemaLanguage = schemaLanguage;
}
Set the XML Schema language used when parsing. By default, we use W3C. |
public void setUseContextClassLoader(boolean use) {
useContextClassLoader = 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. |
public void setValidating(boolean validating) {
this.validating = validating;
}
Set the validating parser flag. This must be called before
parse() is called the first time. |
public void skippedEntity(String name) throws SAXException {
if (saxLog.isDebugEnabled()) {
saxLog.debug("skippedEntity(" + name + ")");
}
; // No processing required
}
Process notification of a skipped entity. |
public void startDocument() throws SAXException {
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();
}
Process notification of the beginning of the document being reached. |
public void startElement(String namespaceURI,
String localName,
String qName,
Attributes list) throws SAXException {
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 + "'.");
}
}
}
Process notification of the start of an XML element being reached. |
public void startPrefixMapping(String prefix,
String namespaceURI) throws SAXException {
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);
}
Process notification that a namespace prefix is coming in to scope. |
public void unparsedEntityDecl(String name,
String publicId,
String systemId,
String notation) {
if (saxLog.isDebugEnabled()) {
saxLog.debug("unparsedEntityDecl(" + name + "," + publicId + "," +
systemId + "," + notation + ")");
}
}
Receive notification of an unparsed entity declaration event. |
public void warning(SAXParseException exception) throws SAXException {
if (errorHandler != null) {
log.warn("Parse Warning Error at line " + exception.getLineNumber() +
" column " + exception.getColumnNumber() + ": " +
exception.getMessage(), exception);
errorHandler.warning(exception);
}
}
Forward notification of a parse warning to the application supplied
error handler (if any). |