|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.apache.tapestry.util.xml.RuleDirectedParser
public class RuleDirectedParser
A simplified version of org.apache.commons.digester.Digester. This version is without as
many bells and whistles but has some key features needed when parsing a document (rather than a
configuration file):
Like Digester, there's an object stack and a rule stack. The rules are much simpler (more coding), in that there's a one-to-one relationship between an element and a rule.
Based on SAX2.
| Constructor Summary | |
|---|---|
RuleDirectedParser()
|
|
| Method Summary | |
|---|---|
void |
addRule(String localElementName,
IRule rule)
|
void |
characters(char[] ch,
int start,
int length)
Accumulates the content in a buffer; the concatinated content is provided to the top rule just before any start or end tag. |
protected void |
configureParserFactory(SAXParserFactory factory)
Configures a SAXParserFactorybefore SAXParserFactory.newSAXParser()is
invoked. |
protected SAXParser |
constructParser()
Uses SAXParserFactoryto create a instance of a validation SAX2
parser. |
void |
endElement(String uri,
String localName,
String qName)
Pops the top rule off the stack and invokes IRule.endElement(RuleDirectedParser). |
void |
error(SAXParseException ex)
Throws the exception. |
void |
fatalError(SAXParseException ex)
Throws the exception. |
org.apache.hivemind.Resource |
getDocumentLocation()
|
String |
getLocalName()
Returns the localName for the current element. |
org.apache.hivemind.Location |
getLocation()
Returns an Locationrepresenting the current position within the document (depending
on the parser, this may be accurate to column number level). |
String |
getQName()
Returns the qualified name for the current element. |
String |
getUri()
Returns the URI for the current element. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Ignorable content is ignored. |
Object |
parse(org.apache.hivemind.Resource documentLocation)
|
protected Object |
parse(URL url)
|
Object |
peek()
Returns the top object on the object stack. |
Object |
peek(int depth)
Returns an object within the object stack, at depth. |
protected IRule |
peekRule()
Returns the top rule on the stack. |
Object |
pop()
Removes and returns the top object on the object stack. |
protected IRule |
popRule()
|
void |
push(Object object)
Pushes an object onto the object stack. |
protected void |
pushRule(IRule rule)
Pushes a new rule onto the rule stack. |
void |
registerEntity(String publicId,
String entityPath)
Registers a public id and corresponding input source. |
InputSource |
resolveEntity(String publicId,
String systemId)
|
protected IRule |
selectRule(String localName,
Attributes attributes)
|
void |
setDocumentLocator(Locator locator)
Uses the Locatorto track the position in the document as a Location. |
void |
startElement(String uri,
String localName,
String qName,
Attributes attributes)
Invokes selectRule(String, Attributes)to choose a new rule, which is pushed onto
the rule stack, then invokes IRule.startElement(RuleDirectedParser, Attributes). |
void |
validate(String value,
String pattern,
String errorKey)
Validates that the input value matches against the specified Perl5 pattern. |
void |
warning(SAXParseException ex)
Throws the exception. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endDocument, endPrefixMapping, notationDecl, processingInstruction, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RuleDirectedParser()
| Method Detail |
|---|
public Object parse(org.apache.hivemind.Resource documentLocation)
protected Object parse(URL url)
public org.apache.hivemind.Location getLocation()
Locationrepresenting the current position within the document (depending
on the parser, this may be accurate to column number level).
public void push(Object object)
public Object peek()
public Object peek(int depth)
public Object pop()
protected void pushRule(IRule rule)
protected IRule peekRule()
protected IRule popRule()
public void addRule(String localElementName,
IRule rule)
public void registerEntity(String publicId,
String entityPath)
publicId - the public identifier to be registerred, generally the publicId of a DTD related
to the document being parsedentityPath - the resource path of the entity, typically a DTD file. Relative files names are
expected to be stored in the same package as the class file, otherwise a leading
slash is an absolute pathname within the classpath.
protected IRule selectRule(String localName,
Attributes attributes)
public void setDocumentLocator(Locator locator)
Locatorto track the position in the document as a Location. This
is invoked once (before the initial element is parsed) and the Locator is retained and
queried as to the current file location.
setDocumentLocator in interface ContentHandlersetDocumentLocator in class DefaultHandlergetLocation()
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class DefaultHandlerSAXException
public void endElement(String uri,
String localName,
String qName)
throws SAXException
IRule.endElement(RuleDirectedParser).
endElement in interface ContentHandlerendElement in class DefaultHandlerSAXException
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class DefaultHandlerSAXException
public void startElement(String uri,
String localName,
String qName,
Attributes attributes)
throws SAXException
selectRule(String, Attributes)to choose a new rule, which is pushed onto
the rule stack, then invokes IRule.startElement(RuleDirectedParser, Attributes).
startElement in interface ContentHandlerstartElement in class DefaultHandlerSAXExceptionprotected SAXParser constructParser()
SAXParserFactoryto create a instance of a validation SAX2
parser.
protected void configureParserFactory(SAXParserFactory factory)
SAXParserFactorybefore SAXParserFactory.newSAXParser()is
invoked. The default implementation sets validating to true and namespaceAware to false,
public void error(SAXParseException ex)
throws SAXException
error in interface ErrorHandlererror in class DefaultHandlerSAXException
public void fatalError(SAXParseException ex)
throws SAXException
fatalError in interface ErrorHandlerfatalError in class DefaultHandlerSAXException
public void warning(SAXParseException ex)
throws SAXException
warning in interface ErrorHandlerwarning in class DefaultHandlerSAXException
public InputSource resolveEntity(String publicId,
String systemId)
throws SAXException
resolveEntity in interface EntityResolverresolveEntity in class DefaultHandlerSAXException
public void validate(String value,
String pattern,
String errorKey)
InvalidStringExceptionis thrown.
public org.apache.hivemind.Resource getDocumentLocation()
public String getLocalName()
ContentHandler.startElement(java.lang.String, java.lang.String,
java.lang.String, org.xml.sax.Attributes)public String getQName()
ContentHandler.startElement(java.lang.String, java.lang.String,
java.lang.String, org.xml.sax.Attributes)public String getUri()
ContentHandler.startElement(java.lang.String, java.lang.String,
java.lang.String, org.xml.sax.Attributes)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||