|
||||||||||
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.openjpa.lib.meta.XMLMetaDataParser
public abstract class XMLMetaDataParser
Custom SAX parser used by the system to quickly parse metadata files. Subclasses should handle the processing of the content.
Constructor Summary | |
---|---|
XMLMetaDataParser()
|
Method Summary | |
---|---|
protected void |
addComments(java.lang.Object obj)
Add current comments to the given entity. |
protected void |
addResult(java.lang.Object result)
Add a result to be returned from the current parse. |
void |
characters(char[] ch,
int start,
int length)
|
void |
clear()
Clears the cache of parsed resource names. |
void |
comment(char[] ch,
int start,
int length)
|
protected java.lang.ClassLoader |
currentClassLoader()
Return the class loader to use when resolving resources and loading classes. |
protected java.lang.String[] |
currentComments()
Array of comments for the current node, or empty array if none. |
protected int |
currentDepth()
Return the parse depth. |
protected java.lang.String |
currentLocation()
Return the current location within the source file. |
protected java.lang.String |
currentText()
Return the text value within the current node. |
void |
endCDATA()
|
void |
endDTD()
|
protected abstract void |
endElement(java.lang.String name)
Override this method marking the end of some element. |
void |
endElement(java.lang.String uri,
java.lang.String name,
java.lang.String qName)
|
void |
endEntity(java.lang.String name)
|
void |
error(org.xml.sax.SAXParseException se)
|
void |
fatalError(org.xml.sax.SAXParseException se)
|
protected void |
finish()
Override this method to finish up after a parse; this is only called if no errors are encountered during parsing. |
java.lang.ClassLoader |
getClassLoader()
Classloader to use for class name resolution. |
protected java.io.Reader |
getDocType()
Override this method to return any DOCTYPE declaration
that should be dynamically included in xml documents that will be
validated. |
protected org.xml.sax.SAXException |
getException(Localizer.Message msg)
Returns a SAXException with the source file name and the given error message. |
protected org.xml.sax.SAXException |
getException(Localizer.Message msg,
java.lang.Throwable cause)
Returns a SAXException with the source file name and the given error message. |
protected org.xml.sax.SAXException |
getException(java.lang.String msg)
Returns a SAXException with the source file name and the given error message. |
org.xml.sax.ext.LexicalHandler |
getLexicalHandler()
The lexical handler that should be registered with the SAX parser used by this class. |
Location |
getLocation()
The XML document location. |
Log |
getLog()
The log to write to. |
boolean |
getParseComments()
Whether to parse element comments. |
boolean |
getParseText()
Whether to parse element text. |
java.util.List |
getResults()
Return the results from the last parse. |
protected java.lang.Object |
getSchemaSource()
Implement to return the XML schema source for the document. |
protected java.io.File |
getSourceFile()
Return the file of the source being parsed. |
boolean |
getSourceIsSystemId()
Whether to use the source name as the XML system id. |
protected java.lang.String |
getSourceName()
Return the name of the source file being parsed. |
java.lang.String |
getSuffix()
Expected suffix for metadata resources, or null if unknown. |
protected void |
ignoreContent(boolean ignoreEnd)
Ignore all content below the current element. |
boolean |
isCaching()
Whether parsed resource names are cached to avoid duplicate parsing. |
boolean |
isValidating()
Whether this is a validating parser. |
void |
parse(java.lang.Class cls,
boolean topDown)
Parse all possible metadata locations for the given class, going top-down or bottom-up. |
void |
parse(java.io.File file)
Parse the given file, which may be a directory, in which case it will be scanned recursively for metadata files. |
void |
parse(MetaDataIterator itr)
Parse the metadata supplied by the given iterator. |
void |
parse(java.io.Reader xml,
java.lang.String sourceName)
Parse the metadata in the given reader. |
void |
parse(java.lang.String rsrc)
Parse the given resource. |
void |
parse(java.net.URL url)
Parse the given resource. |
protected boolean |
parsed(java.lang.String src)
Return true if the given source is parsed. |
protected void |
parseNewResource(java.io.Reader xml,
java.lang.String sourceName)
Parse a previously-unseen source. |
protected void |
reset()
Override this method to clear any state and ready the parser for a new document. |
void |
setCaching(boolean caching)
Whether parsed resource names are cached to avoid duplicate parsing. |
void |
setClassLoader(java.lang.ClassLoader loader)
Classloader to use for class name resolution. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
|
void |
setLexicalHandler(org.xml.sax.ext.LexicalHandler lh)
The lexical handler that should be registered with the SAX parser used by this class. |
void |
setLocation(Location location)
The XML document location. |
void |
setLog(Log log)
The log to write to. |
void |
setParseComments(boolean comments)
Whether to parse element comments. |
void |
setParseText(boolean text)
Whether to parse element text. |
void |
setSourceIsSystemId(boolean systemId)
Whether to use the source name as the XML system id. |
void |
setSuffix(java.lang.String suffix)
Expected suffix for metadata resources, or null if unknown. |
void |
setValidating(boolean validating)
Whether this is a validating parser. |
void |
startCDATA()
|
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
|
protected abstract boolean |
startElement(java.lang.String name,
org.xml.sax.Attributes attrs)
Override this method marking the start of some element. |
void |
startElement(java.lang.String uri,
java.lang.String name,
java.lang.String qName,
org.xml.sax.Attributes attrs)
|
void |
startEntity(java.lang.String name)
|
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLMetaDataParser()
Method Detail |
---|
public boolean getParseText()
public void setParseText(boolean text)
public boolean getParseComments()
public void setParseComments(boolean comments)
public Location getLocation()
public org.xml.sax.ext.LexicalHandler getLexicalHandler()
org.xml.sax.ext
package is not
a required part of SAX2, this handler might not be used by the parser.
public void setLexicalHandler(org.xml.sax.ext.LexicalHandler lh)
org.xml.sax.ext
package is not
a required part of SAX2, this handler might not be used by the parser.
public void setLocation(Location location)
public boolean getSourceIsSystemId()
public void setSourceIsSystemId(boolean systemId)
public boolean isValidating()
public void setValidating(boolean validating)
public java.lang.String getSuffix()
public void setSuffix(java.lang.String suffix)
public boolean isCaching()
public void setCaching(boolean caching)
public Log getLog()
public void setLog(Log log)
public java.lang.ClassLoader getClassLoader()
public void setClassLoader(java.lang.ClassLoader loader)
setClassLoader
in interface MetaDataParser
public java.util.List getResults()
MetaDataParser
getResults
in interface MetaDataParser
public void parse(java.lang.String rsrc) throws java.io.IOException
MetaDataParser
parse
in interface MetaDataParser
java.io.IOException
public void parse(java.net.URL url) throws java.io.IOException
MetaDataParser
parse
in interface MetaDataParser
java.io.IOException
public void parse(java.io.File file) throws java.io.IOException
MetaDataParser
parse
in interface MetaDataParser
java.io.IOException
public void parse(java.lang.Class cls, boolean topDown) throws java.io.IOException
MetaDataParser
parse
in interface MetaDataParser
java.io.IOException
public void parse(java.io.Reader xml, java.lang.String sourceName) throws java.io.IOException
MetaDataParser
parse
in interface MetaDataParser
xml
- reader containing the metadata to parsesourceName
- the name of the source being parsed, for use
in error messages
java.io.IOException
public void parse(MetaDataIterator itr) throws java.io.IOException
MetaDataParser
parse
in interface MetaDataParser
java.io.IOException
protected void parseNewResource(java.io.Reader xml, java.lang.String sourceName) throws java.io.IOException
java.io.IOException
protected boolean parsed(java.lang.String src)
public void clear()
MetaDataParser
clear
in interface MetaDataParser
public void error(org.xml.sax.SAXParseException se) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException se) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
public void startElement(java.lang.String uri, java.lang.String name, java.lang.String qName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String name, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length)
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
comment
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startCDATA() throws org.xml.sax.SAXException
startCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endCDATA() throws org.xml.sax.SAXException
endCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
startDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endDTD() throws org.xml.sax.SAXException
endDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
startEntity
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
endEntity
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
protected abstract boolean startElement(java.lang.String name, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected abstract void endElement(java.lang.String name) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected void addResult(java.lang.Object result)
protected void finish()
super.finish()
to resolve superclass state.
protected void reset()
super.reset()
to clear superclass state.
protected java.lang.Object getSchemaSource() throws java.io.IOException
String
pointing to schema URI.InputStream
containing schema contents.InputSource
containing schema contents.File
containing schema contents.
java.io.IOException
protected java.io.Reader getDocType() throws java.io.IOException
DOCTYPE
declaration
that should be dynamically included in xml documents that will be
validated. Returns null by default.
java.io.IOException
protected java.lang.String getSourceName()
protected java.io.File getSourceFile()
protected void addComments(java.lang.Object obj)
Commentable
.
protected java.lang.String[] currentComments()
protected java.lang.String currentText()
protected java.lang.String currentLocation()
protected int currentDepth()
protected java.lang.ClassLoader currentClassLoader()
protected void ignoreContent(boolean ignoreEnd)
ignoreEnd
- whether to ignore the end element eventprotected org.xml.sax.SAXException getException(java.lang.String msg)
protected org.xml.sax.SAXException getException(Localizer.Message msg)
protected org.xml.sax.SAXException getException(Localizer.Message msg, java.lang.Throwable cause)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |