|
|||||||||||
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
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(java.lang.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(javax.xml.parsers.SAXParserFactory factory)
Configures a SAXParserFactory before SAXParserFactory.newSAXParser() is
invoked. |
protected javax.xml.parsers.SAXParser |
constructParser()
Uses SAXParserFactory to create a instance of a validation SAX2
parser. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Pops the top rule off the stack and invokes IRule#endElementt(RuleDirectedParser) . |
void |
error(org.xml.sax.SAXParseException ex)
Throws the exception. |
void |
fatalError(org.xml.sax.SAXParseException ex)
Throws the exception. |
org.apache.hivemind.Resource |
getDocumentLocation()
|
java.lang.String |
getLocalName()
Returns the localName for the current element. |
org.apache.hivemind.Location |
getLocation()
Returns an ILocation representing the current position within the document (depending
on the parser, this may be accurate to column number level). |
java.lang.String |
getQName()
Returns the qualified name for the current element. |
java.lang.String |
getUri()
Returns the URI for the current element. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Ignorable content is ignored. |
java.lang.Object |
parse(org.apache.hivemind.Resource documentLocation)
|
protected java.lang.Object |
parse(java.net.URL url)
|
java.lang.Object |
peek()
Returns the top object on the object stack. |
java.lang.Object |
peek(int depth)
Returns an object within the object stack, at depth. |
protected IRule |
peekRule()
Returns the top rule on the stack. |
java.lang.Object |
pop()
Removes and returns the top object on the object stack. |
protected IRule |
popRule()
|
void |
push(java.lang.Object object)
Pushes an object onto the object stack. |
protected void |
pushRule(IRule rule)
Pushes a new rule onto the rule stack. |
void |
registerEntity(java.lang.String publicId,
java.lang.String entityPath)
Registers a public id and corresponding input source. |
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
|
protected IRule |
selectRule(java.lang.String localName,
org.xml.sax.Attributes attributes)
|
void |
setDocumentLocator(org.xml.sax.Locator locator)
Uses the Locator to track the position in the document as a ILocation . |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.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(java.lang.String value,
java.lang.String pattern,
java.lang.String errorKey)
Validates that the input value matches against the specified Perl5 pattern. |
void |
warning(org.xml.sax.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 java.lang.Object parse(org.apache.hivemind.Resource documentLocation)
protected java.lang.Object parse(java.net.URL url)
public org.apache.hivemind.Location getLocation()
ILocation
representing the current position within the document (depending
on the parser, this may be accurate to column number level).
public void push(java.lang.Object object)
public java.lang.Object peek()
public java.lang.Object peek(int depth)
public java.lang.Object pop()
protected void pushRule(IRule rule)
protected IRule peekRule()
protected IRule popRule()
public void addRule(java.lang.String localElementName, IRule rule)
public void registerEntity(java.lang.String publicId, java.lang.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(java.lang.String localName, org.xml.sax.Attributes attributes)
public void setDocumentLocator(org.xml.sax.Locator locator)
Locator
to track the position in the document as a ILocation
. This
is invoked once (before the initial element is parsed) and the Locator is retained and
queried as to the current file location.
getLocation()
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
IRule#endElementt(RuleDirectedParser)
.
org.xml.sax.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
selectRule(String, Attributes)
to choose a new rule, which is pushed onto
the rule stack, then invokes IRule.startElement(RuleDirectedParser, Attributes)
.
org.xml.sax.SAXException
protected javax.xml.parsers.SAXParser constructParser()
SAXParserFactory
to create a instance of a validation SAX2
parser.
protected void configureParserFactory(javax.xml.parsers.SAXParserFactory factory)
SAXParserFactory
before SAXParserFactory.newSAXParser()
is
invoked. The default implementation sets validating to true and namespaceAware to false,
public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void validate(java.lang.String value, java.lang.String pattern, java.lang.String errorKey) throws DocumentParseException
InvalidStringException
is thrown.
DocumentParseException
public org.apache.hivemind.Resource getDocumentLocation()
public java.lang.String getLocalName()
ContentHandler.startElement(java.lang.String, java.lang.String,
java.lang.String, org.xml.sax.Attributes)
public java.lang.String getQName()
ContentHandler.startElement(java.lang.String, java.lang.String,
java.lang.String, org.xml.sax.Attributes)
public java.lang.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 |