|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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(Object obj)
Add current comments to the given entity. |
protected void |
addResult(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. |
protected void |
clearDeferredMetaData()
|
void |
comment(char[] ch,
int start,
int length)
|
protected ClassLoader |
currentClassLoader()
Return the class loader to use when resolving resources and loading classes. |
protected String[] |
currentComments()
Array of comments for the current node, or empty array if none. |
protected int |
currentDepth()
Return the parse depth. |
protected String |
currentLocation()
Return the current location within the source file. |
protected String |
currentText()
Return the text value within the current node. |
void |
endCDATA()
|
void |
endDTD()
|
protected abstract void |
endElement(String name)
Override this method marking the end of some element. |
void |
endElement(String uri,
String name,
String qName)
|
void |
endEntity(String name)
|
void |
error(SAXParseException se)
|
void |
fatalError(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. |
ClassLoader |
getClassLoader()
Classloader to use for class name resolution. |
protected Reader |
getDocType()
Override this method to return any DOCTYPE declaration
that should be dynamically included in xml documents that will be
validated. |
protected SAXException |
getException(Localizer.Message msg)
Returns a SAXException with the source file name and the given error message. |
protected SAXException |
getException(Localizer.Message msg,
Throwable cause)
Returns a SAXException with the source file name and the given error message. |
protected SAXException |
getException(String msg)
Returns a SAXException with the source file name and the given error message. |
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. |
List |
getResults()
Return the results from the last parse. |
protected Object |
getSchemaSource()
Implement to return the XML schema source for the document. |
protected File |
getSourceFile()
Return the file of the source being parsed. |
boolean |
getSourceIsSystemId()
Whether to use the source name as the XML system id. |
protected String |
getSourceName()
Return the name of the source file being parsed. |
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 |
isParsing()
|
boolean |
isValidating()
Whether this is a validating parser. |
void |
parse(Class cls,
boolean topDown)
Parse all possible metadata locations for the given class, going top-down or bottom-up. |
void |
parse(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(Reader xml,
String sourceName)
Parse the metadata in the given reader. |
void |
parse(String rsrc)
Parse the given resource. |
void |
parse(URL url)
Parse the given resource. |
protected boolean |
parsed(String src)
Return true if the given source is parsed. |
protected void |
parseNewResource(Reader xml,
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(ClassLoader loader)
Classloader to use for class name resolution. |
void |
setDocumentLocator(Locator locator)
|
void |
setLexicalHandler(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 |
setParsing(boolean parsing)
|
void |
setSourceIsSystemId(boolean systemId)
Whether to use the source name as the XML system id. |
void |
setSuffix(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(String name,
String publicId,
String systemId)
|
protected abstract boolean |
startElement(String name,
Attributes attrs)
Override this method marking the start of some element. |
void |
startElement(String uri,
String name,
String qName,
Attributes attrs)
|
void |
startEntity(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 isParsing()
public void setParsing(boolean parsing)
public boolean getParseText()
public void setParseText(boolean text)
public boolean getParseComments()
public void setParseComments(boolean comments)
public Location getLocation()
public 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(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 String getSuffix()
public void setSuffix(String suffix)
public boolean isCaching()
public void setCaching(boolean caching)
public Log getLog()
public void setLog(Log log)
public ClassLoader getClassLoader()
public void setClassLoader(ClassLoader loader)
setClassLoader
in interface MetaDataParser
public List getResults()
MetaDataParser
getResults
in interface MetaDataParser
public void parse(String rsrc) throws IOException
MetaDataParser
parse
in interface MetaDataParser
IOException
public void parse(URL url) throws IOException
MetaDataParser
parse
in interface MetaDataParser
IOException
public void parse(File file) throws IOException
MetaDataParser
parse
in interface MetaDataParser
IOException
public void parse(Class cls, boolean topDown) throws IOException
MetaDataParser
parse
in interface MetaDataParser
IOException
public void parse(Reader xml, String sourceName) throws 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
IOException
public void parse(MetaDataIterator itr) throws IOException
MetaDataParser
parse
in interface MetaDataParser
IOException
protected void parseNewResource(Reader xml, String sourceName) throws IOException
IOException
protected boolean parsed(String src)
public void clear()
MetaDataParser
clear
in interface MetaDataParser
public void error(SAXParseException se) throws SAXException
error
in interface ErrorHandler
error
in class DefaultHandler
SAXException
public void fatalError(SAXParseException se) throws SAXException
fatalError
in interface ErrorHandler
fatalError
in class DefaultHandler
SAXException
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class DefaultHandler
public void startElement(String uri, String name, String qName, Attributes attrs) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void endElement(String uri, String name, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
SAXException
public void characters(char[] ch, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultHandler
public void comment(char[] ch, int start, int length) throws SAXException
comment
in interface LexicalHandler
SAXException
public void startCDATA() throws SAXException
startCDATA
in interface LexicalHandler
SAXException
public void endCDATA() throws SAXException
endCDATA
in interface LexicalHandler
SAXException
public void startDTD(String name, String publicId, String systemId) throws SAXException
startDTD
in interface LexicalHandler
SAXException
public void endDTD() throws SAXException
endDTD
in interface LexicalHandler
SAXException
public void startEntity(String name) throws SAXException
startEntity
in interface LexicalHandler
SAXException
public void endEntity(String name) throws SAXException
endEntity
in interface LexicalHandler
SAXException
protected abstract boolean startElement(String name, Attributes attrs) throws SAXException
SAXException
protected abstract void endElement(String name) throws SAXException
SAXException
protected void addResult(Object result)
protected void finish()
super.finish()
to resolve superclass state.
protected void reset()
super.reset()
to clear superclass state.
protected Object getSchemaSource() throws IOException
String
pointing to schema URI.InputStream
containing schema contents.InputSource
containing schema contents.File
containing schema contents.
IOException
protected Reader getDocType() throws IOException
DOCTYPE
declaration
that should be dynamically included in xml documents that will be
validated. Returns null by default.
IOException
protected String getSourceName()
protected File getSourceFile()
protected void addComments(Object obj)
Commentable
.
protected String[] currentComments()
protected String currentText()
protected String currentLocation()
protected int currentDepth()
protected ClassLoader currentClassLoader()
protected void ignoreContent(boolean ignoreEnd)
ignoreEnd
- whether to ignore the end element eventprotected SAXException getException(String msg)
protected SAXException getException(Localizer.Message msg)
protected SAXException getException(Localizer.Message msg, Throwable cause)
protected void clearDeferredMetaData()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |