Package com.sun.msv.reader
Class State
- java.lang.Object
-
- com.sun.msv.reader.State
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler
- Direct Known Subclasses:
IgnoreState,NamespaceState,SimpleState
public abstract class State extends java.lang.Object implements org.xml.sax.ContentHandlerbase interface of 'parsing state'. parsing of XML representation of a grammar is done by using various states.Each State-derived class is responsible for a particular type of declaration of the grammar. For example, SequenceState is responsible for parsing <sequence> element of RELAX module.
State objects interact each other. There are two ways of interaction.
- from parent to child
- from child to parent
In this level of inheritance, contract is somewhat abstract.
- When a State object is created, its init method is called and various information is set. Particularly, start tag information (if any) and the parent state is set. This process should only be initiated by GrammarReader.
- After that, startSelf method is called. Usually, this is the place to do something useful.
- State object is registered as a ContentHandler, and therefore will receive SAX events from now on.
- Derived classes are expected to do something useful by receiving SAX events.
- When a State object finishes its own part, it should call GrammarReader.popState method. It will remove the current State object and registers the parent state as a ContentHandler again.
SimpleState.this class also provides:
- access to the parent state
- default implementations for all ContentHandler callbacks except startElement and endElement
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringbaseURIbase URI for this state.protected org.xml.sax.LocatorlocationLocation of the start tag.protected StateparentStateparent state of this state.GrammarReaderreaderreader object who is the owner of this object.protected StartTagInfostartTaginformation of the start tag.
-
Constructor Summary
Constructors Constructor Description State()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void_assert(boolean b)protected ExpressioncallInterceptExpression(Expression exp)voidcharacters(char[] buffer, int from, int len)voidendPrefixMapping(java.lang.String prefix)java.lang.StringgetBaseURI()org.xml.sax.LocatorgetLocation()StategetParentState()StartTagInfogetStartTag()voidignorableWhitespace(char[] buffer, int from, int len)protected voidinit(GrammarReader reader, State parentState, StartTagInfo startTag)voidprocessingInstruction(java.lang.String target, java.lang.String data)voidsetDocumentLocator(org.xml.sax.Locator loc)voidskippedEntity(java.lang.String name)voidstartDocument()voidstartPrefixMapping(java.lang.String prefix, java.lang.String uri)protected voidstartSelf()performs a task that should be done before reading any child elements.
-
-
-
Field Detail
-
parentState
protected State parentState
parent state of this state. In other words, the parent state is a state who is responsible for the parent element of the current element. For states responsible for the document element, the parent state is a state who is responsible for the entire document. For states responsible for the entire document, the parent state is always null.
-
reader
public GrammarReader reader
reader object who is the owner of this object. This information is avaiable after init method is called.
-
startTag
protected StartTagInfo startTag
information of the start tag. This information is avaiable after init method is called.
-
location
protected org.xml.sax.Locator location
Location of the start tag. This information is avaiable after init method is called.
-
baseURI
protected java.lang.String baseURI
base URI for this state. This information is avaiable after init method is called.
-
-
Method Detail
-
getParentState
public final State getParentState()
-
getStartTag
public StartTagInfo getStartTag()
-
getLocation
public org.xml.sax.Locator getLocation()
-
getBaseURI
public java.lang.String getBaseURI()
-
init
protected final void init(GrammarReader reader, State parentState, StartTagInfo startTag)
-
startSelf
protected void startSelf()
performs a task that should be done before reading any child elements. derived-class can safely read startTag and/or parentState values.
-
_assert
public static void _assert(boolean b)
-
characters
public void characters(char[] buffer, int from, int len) throws org.xml.sax.SAXException- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
callInterceptExpression
protected final Expression callInterceptExpression(Expression exp)
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] buffer, int from, int len) throws org.xml.sax.SAXException- Specified by:
ignorableWhitespacein interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
skippedEntity
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
skippedEntityin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
startDocument
public final void startDocument() throws org.xml.sax.SAXException- Specified by:
startDocumentin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator loc)
- Specified by:
setDocumentLocatorin interfaceorg.xml.sax.ContentHandler
-
startPrefixMapping
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException- Specified by:
startPrefixMappingin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
endPrefixMapping
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException- Specified by:
endPrefixMappingin interfaceorg.xml.sax.ContentHandler- Throws:
org.xml.sax.SAXException
-
-