|
www.sdmetrics.com | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.xml.sax.helpers.DefaultHandler
|
+--sdmetrics.app.XMLPeeker
Peeks into an XML file to determine if it is an SDMetrics Project File, and if so, what type of file. For XMI files, the XMI header information (XMI version, XMI exporter name, XMI exporter version) is also retrieved.
To use this class, call peekIntoFile(java.lang.String) with the name of the file
to check. Afterwards, the type of the file can be queried using the
queries isXMIFile(), isMetaModelFile() etc.
| Constructor Summary | |
XMLPeeker(sdmetrics.util.MyXMLParser parser)
Initialize object, letting it use an existing XML parser. |
|
| Method Summary | |
void |
characters(char[] ch,
int start,
int length)
SAX parser handler: retrieve XMI exporter name and version from PCDATA. |
void |
endDocument()
SAX parser handler: end of the document. |
void |
endElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw)
SAX parser handler: detect end of XMI documentation. |
java.lang.String |
getErrorMsg()
Get an error message describing what error occurred parsing the XML file. |
java.lang.String |
getTopLevelXMLElementName()
Get the name of the top-level XML element of the XML file. |
java.lang.String |
getXMIExporter()
If the XML file checked was an XMI file, get the XMI exporter that created the file. |
java.lang.String |
getXMIExporterVersion()
If the XML file checked was an XMI file, get the version number of the XMI exporter that created the file. |
java.lang.String |
getXMIVersion()
If the XML file checked was an XMI file, get the XMI version of the file. |
boolean |
isMetaModelFile()
Check if the XML file is a metamodel definition file. |
boolean |
isMetricDefinitionFile()
Check if the XML file is a metric definition file. |
boolean |
isXMIFile()
Check if the XML file is an XMI file. |
boolean |
isXMITransformationFile()
Check if the XML file is an XMI transformation file. |
boolean |
peekIntoFile(java.lang.String file)
Parse the head of an XML file to determine its type (XMI, metamodel definition, etc). |
void |
startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs)
SAX parser handler: Scan XML elements for XMI header information and collect the relevant information for later retrieval. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, 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 XMLPeeker(sdmetrics.util.MyXMLParser parser)
parser - XML parser to use. If this is null, the XML peeker
will use an XML parser of its own.| Method Detail |
public boolean peekIntoFile(java.lang.String file)
file - URL of the file to parse.
true if the file type was recognized,
false if the file type could not be recognized or an IO error
occurred.public java.lang.String getErrorMsg()
public boolean isXMIFile()
true if file is an XMI file, else false.public boolean isMetaModelFile()
true if file is a metamodel definition file, else false.public boolean isXMITransformationFile()
true if file is an XMI transformation file, else false.public boolean isMetricDefinitionFile()
true if file is a metric definition file, else false.public java.lang.String getTopLevelXMLElementName()
public java.lang.String getXMIVersion()
public java.lang.String getXMIExporter()
public java.lang.String getXMIExporterVersion()
public void startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void endElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw)
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandler
public void characters(char[] ch,
int start,
int length)
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandler
public void endDocument()
throws org.xml.sax.SAXException
endDocument in interface org.xml.sax.ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
|
www.sdmetrics.com | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||