|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.microstar.xml.HandlerBase ptolemy.plot.plotml.PlotBoxMLParser
public class PlotBoxMLParser
This class constructs a plot from specifications in PlotML (Plot Markup Language), which is an XML language. This class supports only the subset that applies to the PlotBox base class. It ignores all other elements in the DTD. The class contains an instance of the Microstar Ælfred XML parser and implements callback methods to interpret the parsed XML. The way to use this class is to construct it with a reference to a PlotBox object and then call its parse() method.
Red (cxh) |
Red (eal) |
Field Summary | |
---|---|
protected java.util.Hashtable |
_attributes
Attributes associated with an entity. |
protected java.lang.StringBuffer |
_currentCharData
The current character data for the current element. |
private java.util.Stack |
_externalEntities
|
protected XmlParser |
_parser
The parser. |
protected PlotBox |
_plot
The plot object to which to apply commands. |
private boolean |
_xtick
|
static java.lang.String |
PlotML_DTD_1
The standard PlotML DTD, represented as a string. |
Constructor Summary | |
---|---|
protected |
PlotBoxMLParser()
Protected constructor allows derived classes to set _plot differently. |
|
PlotBoxMLParser(PlotBox plot)
Construct an parser to parse commands for the specified plot object. |
Method Summary | |
---|---|
protected void |
_checkForNull(java.lang.Object object,
java.lang.String message)
If the argument is null, throw an exception with the given message. |
protected java.lang.String |
_currentExternalEntity()
Get the the URI for the current external entity. |
void |
attribute(java.lang.String name,
java.lang.String value,
boolean specified)
Handle an attribute assignment that is part of an XML element. |
void |
charData(char[] chars,
int offset,
int length)
Handle character data. |
void |
endDocument()
End the document. |
void |
endElement(java.lang.String elementName)
End an element. |
void |
error(java.lang.String message,
java.lang.String systemID,
int line,
int column)
Indicate a fatal XML parsing error. |
void |
parse(java.net.URL base,
java.io.InputStream input)
Parse the given stream as a PlotML file. |
void |
parse(java.net.URL base,
java.io.Reader reader)
Parse the given stream as a PlotML file. |
void |
parse(java.net.URL base,
java.lang.String text)
Parse the given text as PlotML. |
java.lang.Object |
resolveEntity(java.lang.String publicID,
java.lang.String systemID)
Resolve an external entity. |
void |
startDocument()
Start a document. |
void |
startElement(java.lang.String elementName)
Start an element. |
void |
startExternalEntity(java.lang.String systemID)
Handle the start of an external entity. |
Methods inherited from class com.microstar.xml.HandlerBase |
---|
doctypeDecl, endExternalEntity, ignorableWhitespace, processingInstruction |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PlotML_DTD_1
protected java.util.Hashtable _attributes
protected java.lang.StringBuffer _currentCharData
protected XmlParser _parser
protected PlotBox _plot
private java.util.Stack _externalEntities
private boolean _xtick
Constructor Detail |
---|
public PlotBoxMLParser(PlotBox plot)
plot
- The plot object to which to apply the commands.protected PlotBoxMLParser()
Method Detail |
---|
public void attribute(java.lang.String name, java.lang.String value, boolean specified) throws XmlException
attribute
in interface XmlHandler
attribute
in class HandlerBase
name
- The name of the attribute.value
- The value of the attribute, or null if the attribute
is #IMPLIED
and not specified.specified
- True if the value is specified, false if the
value comes from the default value in the DTD rather than from
the XML file.
XmlException
- If the name or value is null.XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
public void charData(char[] chars, int offset, int length)
charData
in interface XmlHandler
charData
in class HandlerBase
chars
- The character data.offset
- The starting position in the array.length
- The number of characters available.XmlHandler.charData(char[], int, int)
public void endDocument() throws java.lang.Exception
endDocument
in interface XmlHandler
endDocument
in class HandlerBase
java.lang.Exception
- The handler may throw any exception.XmlHandler.endDocument()
public void endElement(java.lang.String elementName) throws java.lang.Exception
endElement
in interface XmlHandler
endElement
in class HandlerBase
elementName
- The element type name.
java.lang.Exception
- If thrown while invoking a method on the
Plot object.XmlHandler.endElement(java.lang.String)
public void error(java.lang.String message, java.lang.String systemID, int line, int column) throws XmlException
error
in interface XmlHandler
error
in class HandlerBase
message
- The error message.systemID
- The URI of the entity that caused the error.line
- The approximate line number of the error.column
- The approximate column number of the error.
XmlException
- If called.XmlHandler.error(java.lang.String, java.lang.String, int, int)
public void parse(java.net.URL base, java.io.InputStream input) throws java.lang.Exception
PlotBoxMLParser parser = new PlotBoxMLParser(); URL docBase = getDocumentBase(); URL xmlFile = new URL(docBase, modelURL); parser.parse(xmlFile.openStream());A variety of exceptions might be thrown if the parsed data does not represent a valid PlotML file.
base
- The base URL for relative references, or null if
there is none.input
- The stream from which to read XML.
java.lang.Exception
- If the parser fails.public void parse(java.net.URL base, java.io.Reader reader) throws java.lang.Exception
base
- The base URL for relative references, or null if
there is none.reader
- The stream from which to read XML.
java.lang.Exception
- If the parser fails.public void parse(java.net.URL base, java.lang.String text) throws java.lang.Exception
base
- The base URL for relative references, or null if
there is none.text
- The PlotML data.
java.lang.Exception
- If the parser fails.public java.lang.Object resolveEntity(java.lang.String publicID, java.lang.String systemID)
resolveEntity
in interface XmlHandler
resolveEntity
in class HandlerBase
publicID
- The public identifier, or null if none was supplied.systemID
- The system identifier.
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
public void startDocument()
startDocument
in interface XmlHandler
startDocument
in class HandlerBase
XmlHandler.startDocument()
public void startElement(java.lang.String elementName) throws XmlException
startElement
in interface XmlHandler
startElement
in class HandlerBase
elementName
- The element type name.
XmlException
- If the element produces an error
in constructing the model.XmlHandler.startElement(java.lang.String)
public void startExternalEntity(java.lang.String systemID)
startExternalEntity
in interface XmlHandler
startExternalEntity
in class HandlerBase
systemID
- The URI for the external entity.XmlHandler.startExternalEntity(java.lang.String)
protected void _checkForNull(java.lang.Object object, java.lang.String message) throws XmlException
object
- The reference to check for null.message
- The message to issue if the reference is null.
XmlException
- If the object argument is null.protected java.lang.String _currentExternalEntity()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |