public class PlotBoxMLParser extends HandlerBase
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable |
_attributes
Attributes associated with an entity.
|
protected java.lang.StringBuffer |
_currentCharData
The current character data for the current element.
|
protected XmlParser |
_parser
The parser.
|
protected PlotBoxInterface |
_plot
The plot object to which to apply commands.
|
static java.lang.String |
PlotML_DTD_1
The standard PlotML DTD, represented as a string.
|
Modifier | Constructor and Description |
---|---|
protected |
PlotBoxMLParser()
Protected constructor allows derived classes to set _plot
differently.
|
|
PlotBoxMLParser(PlotBoxInterface plot)
Construct an parser to parse commands for the specified plot object.
|
Modifier and Type | Method and Description |
---|---|
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.
|
doctypeDecl, endExternalEntity, ignorableWhitespace, processingInstruction
public static final java.lang.String PlotML_DTD_1
protected java.util.Hashtable _attributes
protected java.lang.StringBuffer _currentCharData
protected XmlParser _parser
protected PlotBoxInterface _plot
public PlotBoxMLParser(PlotBoxInterface plot)
plot
- The plot object to which to apply the commands.protected PlotBoxMLParser()
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()