Package diva.gui
Class MultipageParser
- java.lang.Object
-
- com.microstar.xml.HandlerBase
-
- diva.gui.MultipageParser
-
- All Implemented Interfaces:
XmlHandler
public class MultipageParser extends HandlerBase
Parse all pages of a multi-page document from a file. The document parser must be provided with a model parser that is used to parse the app-specific model on a single page.- Version:
- $Id$
- Author:
- Heloise Hse, Michael Shilman
- Pt.AcceptedRating:
- Red
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDTD_1The DTD for multipage models.static java.lang.StringDTD_URLThe URL where the DTD is stored.static java.lang.StringMULTIPAGE_TAGThe string constant that specifies the start and end of a document.static java.lang.StringPAGE_NUM_TAGThe string constant that specifies the page number of a page.static java.lang.StringPAGE_TAGThe string constant that specifies the start and end of a sheet in a document.static java.lang.StringPAGE_TITLE_TAGThe string constant that specifies the title attribute of a page.static java.lang.StringPUBLIC_IDThe public identity of the sketch dtd file.static java.lang.StringTITLE_TAGThe string constant that specifies the title attribute of a document.
-
Constructor Summary
Constructors Constructor Description MultipageParser(ModelParser pageParser)Create a MultipageParser with the specified model parser which is used to parse the content of a page.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattribute(java.lang.String name, java.lang.String value, boolean isSpecified)Handle an attribute value assignment.voidcharData(char[] chars, int offset, int length)Handle character data.voidendElement(java.lang.String name)Handle the end of an element.voidparse(java.io.Reader reader, MultipageModel multi)Parse the file (from reader) into the given multipage data structure.java.lang.ObjectresolveEntity(java.lang.String publicID, java.lang.String systemID)Resolve an external entity.voidstartElement(java.lang.String name)Handle the start of an element.-
Methods inherited from class com.microstar.xml.HandlerBase
doctypeDecl, endDocument, endExternalEntity, error, ignorableWhitespace, processingInstruction, startDocument, startExternalEntity
-
-
-
-
Field Detail
-
PUBLIC_ID
public static final java.lang.String PUBLIC_ID
The public identity of the sketch dtd file.- See Also:
- Constant Field Values
-
DTD_URL
public static final java.lang.String DTD_URL
The URL where the DTD is stored.- See Also:
- Constant Field Values
-
DTD_1
public static final java.lang.String DTD_1
The DTD for multipage models.- See Also:
- Constant Field Values
-
TITLE_TAG
public static final java.lang.String TITLE_TAG
The string constant that specifies the title attribute of a document.- See Also:
- Constant Field Values
-
MULTIPAGE_TAG
public static final java.lang.String MULTIPAGE_TAG
The string constant that specifies the start and end of a document.- See Also:
- Constant Field Values
-
PAGE_TAG
public static final java.lang.String PAGE_TAG
The string constant that specifies the start and end of a sheet in a document.- See Also:
- Constant Field Values
-
PAGE_TITLE_TAG
public static final java.lang.String PAGE_TITLE_TAG
The string constant that specifies the title attribute of a page. This is an optional attribute.- See Also:
- Constant Field Values
-
PAGE_NUM_TAG
public static final java.lang.String PAGE_NUM_TAG
The string constant that specifies the page number of a page.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultipageParser
public MultipageParser(ModelParser pageParser)
Create a MultipageParser with the specified model parser which is used to parse the content of a page.
-
-
Method Detail
-
attribute
public void attribute(java.lang.String name, java.lang.String value, boolean isSpecified) throws java.lang.ExceptionHandle an attribute value assignment. The attribute and its value are temporary saved in a hash table. They are later retrieved in startElement or endElement.- Specified by:
attributein interfaceXmlHandler- Overrides:
attributein classHandlerBase- Parameters:
name- 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)
-
charData
public void charData(char[] chars, int offset, int length) throws java.lang.ExceptionHandle character data. The page content is buffered in a character array by XML parser which invokes this method. In this method, the model parser gets called to parse the data in the array.- Specified by:
charDatain interfaceXmlHandler- Overrides:
charDatain classHandlerBase- Parameters:
chars- The character data.offset- 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)
-
endElement
public void endElement(java.lang.String name) throws java.lang.ExceptionHandle the end of an element. If this is the end of a page, add the current page to the document.- Specified by:
endElementin interfaceXmlHandler- Overrides:
endElementin classHandlerBase- Parameters:
name- The element type name.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.endElement(java.lang.String)
-
startElement
public void startElement(java.lang.String name) throws java.lang.ExceptionHandle the start of an element. If this is the start of a page, create a Page object and set its label (retrieve from _currentAttributes table)- Specified by:
startElementin interfaceXmlHandler- Overrides:
startElementin classHandlerBase- Parameters:
name- The element type name.- Throws:
java.lang.Exception- Derived methods may throw exceptions.- See Also:
XmlHandler.startElement(java.lang.String)
-
resolveEntity
public java.lang.Object resolveEntity(java.lang.String publicID, java.lang.String systemID)Resolve an external entity. If the first argument is the name of the MoML PUBLIC DTD ("-//UC Berkeley//DTD multipage 1//EN"), then return a StringReader that will read the locally cached version of this DTD (the public variable DTD_1). Otherwise, return null, which has the effect of deferring to Aelfred for resolution of the URI. Derived classes may return a modified URI (a string), an InputStream, or a Reader. In the latter two cases, the input character stream is provided.- Specified by:
resolveEntityin interfaceXmlHandler- Overrides:
resolveEntityin classHandlerBase- Parameters:
publicID- The public identifier, or null if none was supplied.systemID- The system identifier.- Returns:
- Null, indicating to use the default system identifier.
- See Also:
XmlHandler.resolveEntity(java.lang.String, java.lang.String)
-
parse
public void parse(java.io.Reader reader, MultipageModel multi) throws java.lang.ExceptionParse the file (from reader) into the given multipage data structure.- Throws:
java.lang.Exception
-
-