|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
org.jpox.metadata.MetaDataParser
Class to parse a MetaData file and return a FileMetaData object. This class is invoked by either of
MetaDataParser.parseMetaData(url,validate); MetaDataParser.parseMetaData(input_str,validate);returning the FileMetaData. This class simply constructs the MetaData representation mirroring what is in the MetaData file. It has no knowledge of the class(es) that it represents, simply the information in the MetaData file. The knowledge of the classes is imposed on the representation at a later stage where necessary.
Operates the parse process using a Stack. MetaData components are added to the stack as they are encountered and created. They are then popped off the stack when the end element is encountered.
Field Summary | |
protected java.lang.String |
latestElement
Latest element. |
protected static Localiser |
LOCALISER
|
protected FileMetaData |
metadata
The MetaData for the file. |
protected java.util.Stack |
stack
Stack of meta-data elements. |
Constructor Summary | |
protected |
MetaDataParser(MetaDataManager mdm,
java.lang.String filename)
Constructor. |
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Notification handler for the data inside an element. |
void |
endDocument()
Handler method called at the end of the XML document. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Handler method called at the end of an element. |
void |
error(org.xml.sax.SAXParseException e)
Parser error method. |
protected java.lang.String |
getAttr(org.xml.sax.Attributes attrs,
java.lang.String key)
Accessor for an attribute out of the attributes for an element. |
protected java.lang.String |
getAttr(org.xml.sax.Attributes attrs,
java.lang.String key,
java.lang.String defaultValue)
Accessor for an attribute out of the attributes for an element. |
protected FileMetaData |
getMetaData()
Accessor for the MetaData for this file. |
protected MetaData |
getStack()
Accessor for the current MetaData component. |
java.lang.String |
getString()
Accessor to the string form of this metadata |
protected ClassMetaData |
newClassObject(PackageMetaData pmd,
org.xml.sax.Attributes attrs)
Utility to create a new class component. |
protected FieldMetaData |
newFieldObject(MetaData md,
org.xml.sax.Attributes attrs)
Utility to create a new field component. |
protected PropertyMetaData |
newPropertyObject(MetaData md,
org.xml.sax.Attributes attrs)
Utility to create a new property component. |
static FileMetaData |
parseMetaData(java.net.URL url,
boolean validate,
MetaDataManager mdm)
Method to parse a JDO MetaData file given the URL of the file. |
static FileMetaData |
parseMetaDataStream(java.io.InputStream in,
boolean validate,
MetaDataManager mdm,
java.lang.String filename)
Method to parse a JDO MetaData file given an InputStream. |
protected MetaData |
popStack()
Method to remove the current MetaData component from the Stack. |
protected void |
pushStack(MetaData md)
Method to add a MetaData component to the Stack. |
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
Method to resolve XML entities. |
void |
startDocument()
Handler method called at the start of the XML document. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attrs)
Handler method called at the start of an element. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static Localiser LOCALISER
protected java.util.Stack stack
protected java.lang.String latestElement
protected final FileMetaData metadata
Constructor Detail |
protected MetaDataParser(MetaDataManager mdm, java.lang.String filename)
mdm
- the metadata managerfilename
- The name of the file to parseMethod Detail |
public static FileMetaData parseMetaData(java.net.URL url, boolean validate, MetaDataManager mdm)
url
- Url of the filevalidate
- Whether to validate against the DTD as wellmdm
- the metadata manager
javax.jdo.JDOException
- thrown if error occurredpublic static FileMetaData parseMetaDataStream(java.io.InputStream in, boolean validate, MetaDataManager mdm, java.lang.String filename)
in
- input streamvalidate
- Whether to validate the MetaDatamdm
- the metadata managerfilename
- Name of the file (if applicable)
javax.jdo.JDOException
- thrown if error occurredprotected FileMetaData getMetaData()
public void startDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
- in parsing errorspublic void endDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
- in parsing errorsprotected ClassMetaData newClassObject(PackageMetaData pmd, org.xml.sax.Attributes attrs)
pmd
- The parent PackageMetaDataattrs
- The attributes
protected FieldMetaData newFieldObject(MetaData md, org.xml.sax.Attributes attrs)
md
- The parent MetaDataattrs
- The attributes
protected PropertyMetaData newPropertyObject(MetaData md, org.xml.sax.Attributes attrs)
md
- The parent MetaDataattrs
- The attributes
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
uri
- URI of the taglocalName
- Local nameqName
- Element nameattrs
- Attributes for this element
org.xml.sax.SAXException
- in parsing errorspublic void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
uri
- URI of the taglocalName
- local nameqName
- Name of element just ending
org.xml.sax.SAXException
- in parsing errorspublic void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
e
- Parse Exception
org.xml.sax.SAXException
ErrorHandler.error(org.xml.sax.SAXParseException)
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
ch
- The charactersstart
- The start position in the character array.length
- The length of the string.
org.xml.sax.SAXException
- in parsing errorspublic java.lang.String getString()
protected MetaData getStack()
protected MetaData popStack()
protected void pushStack(MetaData md)
md
- The component to add.public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
publicId
- The public id.systemId
- The system id.
org.xml.sax.SAXException
EntityResolver.resolveEntity(java.lang.String,java.lang.String)
protected java.lang.String getAttr(org.xml.sax.Attributes attrs, java.lang.String key, java.lang.String defaultValue)
attrs
- The attributeskey
- Key for the attribute to returndefaultValue
- A default to impose if no value.
protected java.lang.String getAttr(org.xml.sax.Attributes attrs, java.lang.String key)
attrs
- The attributeskey
- Key for the attribute to return
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |