Class HandlerBase
- java.lang.Object
-
- com.microstar.xml.HandlerBase
-
- All Implemented Interfaces:
XmlHandler
- Direct Known Subclasses:
DocManager,MoMLParser,MultipageParser,PlotBoxMLParser,PtalonMLHandler
public class HandlerBase extends java.lang.Object implements XmlHandler
Convenience base class for AElfred handlers.This base class implements the XmlHandler interface with (mostly empty) default handlers. You are not required to use this, but if you need to handle only a few events, you might find it convenient to extend this class rather than implementing the entire interface. This example overrides only the
charDatamethod, using the defaults for the others:import com.microstar.xml.HandlerBase; public class MyHandler extends HandlerBase { public void charData (char ch[], int start, int length) { System.out.println("Data: " + new String (ch, start, length)); } }This class is optional, but if you use it, you must also include the
XmlExceptionclass.Do not extend this if you are using SAX; extend
org.xml.sax.HandlerBaseinstead.- Since:
- Ptolemy II 0.2
- Version:
- 1.1
- Author:
- Copyright (c) 1998 by Microstar Software Ltd., written by David Megginson <dmeggins@microstar.com>
- See Also:
XmlHandler,XmlException
-
-
Constructor Summary
Constructors Constructor Description HandlerBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattribute(java.lang.String aname, java.lang.String value, boolean isSpecified)Handle an attribute assignment.voidcharData(char[] ch, int start, int length)Handle character data.voiddoctypeDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)Handle a document type declaration.voidendDocument()Handle the end of the document.voidendElement(java.lang.String elname)Handle the end of an element.voidendExternalEntity(java.lang.String systemId)Handle the end of an external entity.voiderror(java.lang.String message, java.lang.String systemId, int line, int column)Throw an exception for a fatal error.voidignorableWhitespace(char[] ch, int start, int length)Handle ignorable whitespace.voidprocessingInstruction(java.lang.String target, java.lang.String data)Handle a processing instruction.java.lang.ObjectresolveEntity(java.lang.String publicId, java.lang.String systemId)Resolve an external entity.voidstartDocument()Handle the start of the document.voidstartElement(java.lang.String elname)Handle the start of an element.voidstartExternalEntity(java.lang.String systemId)Handle the start of an external entity.
-
-
-
Method Detail
-
startDocument
public void startDocument() throws java.lang.ExceptionHandle the start of the document.The default implementation does nothing.
- Specified by:
startDocumentin interfaceXmlHandler- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.startDocument()
-
endDocument
public void endDocument() throws java.lang.ExceptionHandle the end of the document.The default implementation does nothing.
- Specified by:
endDocumentin interfaceXmlHandler- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.endDocument()
-
resolveEntity
public java.lang.Object resolveEntity(java.lang.String publicId, java.lang.String systemId) throws java.lang.ExceptionResolve an external entity.The default implementation simply returns the supplied system identifier.
- Specified by:
resolveEntityin interfaceXmlHandler- Parameters:
publicId- The public identifier, or null if none was supplied.systemId- The system identifier.- Returns:
- The replacement system identifier, or null to use the default.
- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
-
startExternalEntity
public void startExternalEntity(java.lang.String systemId) throws java.lang.ExceptionHandle the start of an external entity.The default implementation does nothing.
- Specified by:
startExternalEntityin interfaceXmlHandler- Parameters:
systemId- The URI of the external entity that is starting.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.startExternalEntity(java.lang.String)
-
endExternalEntity
public void endExternalEntity(java.lang.String systemId) throws java.lang.ExceptionHandle the end of an external entity.The default implementation does nothing.
- Specified by:
endExternalEntityin interfaceXmlHandler- Parameters:
systemId- The URI of the external entity that is ending.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.endExternalEntity(java.lang.String)
-
doctypeDecl
public void doctypeDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws java.lang.ExceptionHandle a document type declaration.The default implementation does nothing.
- Specified by:
doctypeDeclin interfaceXmlHandler- Parameters:
name- The document type name.publicId- The public identifier, or null if unspecified.systemId- The system identifier, or null if unspecified.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.doctypeDecl(java.lang.String, java.lang.String, java.lang.String)
-
attribute
public void attribute(java.lang.String aname, java.lang.String value, boolean isSpecified) throws java.lang.ExceptionHandle an attribute assignment.The default implementation does nothing.
- Specified by:
attributein interfaceXmlHandler- Parameters:
aname- The name of the attribute.value- The value of the attribute, or null if the attribute is#IMPLIED.isSpecified- True if the value was specified, false if it was defaulted from the DTD.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.attribute(java.lang.String, java.lang.String, boolean)
-
startElement
public void startElement(java.lang.String elname) throws java.lang.ExceptionHandle the start of an element.The default implementation does nothing.
- Specified by:
startElementin interfaceXmlHandler- Parameters:
elname- The element type name.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.startElement(java.lang.String)
-
endElement
public void endElement(java.lang.String elname) throws java.lang.ExceptionHandle the end of an element.The default implementation does nothing.
- Specified by:
endElementin interfaceXmlHandler- Parameters:
elname- The element type name.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.endElement(java.lang.String)
-
charData
public void charData(char[] ch, int start, int length) throws java.lang.ExceptionHandle character data.The default implementation does nothing.
- Specified by:
charDatain interfaceXmlHandler- Parameters:
ch- The character data.start- The starting position in the array.length- The number of characters available.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.charData(char[], int, int)
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws java.lang.ExceptionHandle ignorable whitespace.The default implementation does nothing.
- Specified by:
ignorableWhitespacein interfaceXmlHandler- Parameters:
ch- The literal whitespace characters.start- The starting position in the array.length- The number of whitespace characters available.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.ignorableWhitespace(char[], int, int)
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws java.lang.ExceptionHandle a processing instruction.The default implementation does nothing.
- Specified by:
processingInstructionin interfaceXmlHandler- Parameters:
target- The target (the name at the start of the PI).data- The data, if any (the rest of the PI).- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.processingInstruction(java.lang.String, java.lang.String)
-
error
public void error(java.lang.String message, java.lang.String systemId, int line, int column) throws XmlException, java.lang.ExceptionThrow an exception for a fatal error.The default implementation throws
XmlException.- Specified by:
errorin interfaceXmlHandler- Parameters:
message- The error message.systemId- The system identifier of the entity that contains the error.line- The approximate line number of the error.column- The approximate column number of the error.- Throws:
XmlException- A specific parsing error.java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.error(java.lang.String, java.lang.String, int, int)
-
-