com.sun.msv.reader

Class State

public abstract class State extends Object implements ContentHandler

base 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.

The first type of communication occurs only when a child state object is created. The last type of communication occurs usually (but not limited to) when a child state sees its end tag.

In this level of inheritance, contract is somewhat abstract.

  1. 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.
  2. After that, startSelf method is called. Usually, this is the place to do something useful.
  3. State object is registered as a ContentHandler, and therefore will receive SAX events from now on.
  4. Derived classes are expected to do something useful by receiving SAX events.
  5. 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.
Of course some derived classes introduce more restricted contract. See SimpleState.

this class also provides:

Author: Kohsuke KAWAGUCHI

Field Summary
GrammarReaderreader
reader object who is the owner of this object.
Method Summary
voidcharacters(char[] buffer, int from, int len)
voidendPrefixMapping(String prefix)
StringgetBaseURI()
LocatorgetLocation()
StategetParentState()
StartTagInfogetStartTag()
voidignorableWhitespace(char[] buffer, int from, int len)
voidprocessingInstruction(String target, String data)
voidsetDocumentLocator(Locator loc)
voidskippedEntity(String name)
voidstartDocument()
voidstartPrefixMapping(String prefix, String uri)
static void_assert(boolean b)

Field Detail

reader

public GrammarReader reader
reader object who is the owner of this object. This information is avaiable after init method is called.

Method Detail

characters

public void characters(char[] buffer, int from, int len)

endPrefixMapping

public void endPrefixMapping(String prefix)

getBaseURI

public String getBaseURI()

getLocation

public Locator getLocation()

getParentState

public final State getParentState()

getStartTag

public StartTagInfo getStartTag()

ignorableWhitespace

public void ignorableWhitespace(char[] buffer, int from, int len)

processingInstruction

public void processingInstruction(String target, String data)

setDocumentLocator

public void setDocumentLocator(Locator loc)

skippedEntity

public void skippedEntity(String name)

startDocument

public final void startDocument()

startPrefixMapping

public void startPrefixMapping(String prefix, String uri)

_assert

public static void _assert(boolean b)