Package org.eclipse.birt.core.framework.parser

# Class AbstractParseState

java.lang.Object
org.eclipse.birt.core.framework.parser.AbstractParseState

Direct Known Subclasses:
  `ParseState`

public abstract class AbstractParseState extends Object
Abstract parse state for the `XMLParserHandler` class. Derived classes create parse states based on this class.

See Also:
  - `ParseState`
  - `AnyElementState`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected String`
`context`
SAX context string.
`protected String`
`elementName`
The name of the element being parsed.
`protected StringBuffer`
`text`
Accumulates any text that appears within the element tags.

## Constructor Summary

Constructors
Constructor
Description
`AbstractParseState()`

## Method Summary

Modifier and Type
Method
Description
`void`
`end()`
Called when the element for this state is ending.
`void`
`endElement(AbstractParseState state)`
Called when a child element is ending.
`protected String`
`getAttrib(Attributes attrs, String attrName)`
Parse a string value.
`abstract XMLParserHandler`
`getHandler()`
Returns the parser handler.
`AbstractParseState`
`jumpTo()`
Jumps to the specified state that the current state needs to go.
`void`
`parseAttrs(Attributes attrs)`
Called to parse attributes.
`void`
`setElementName(String name)`
Sets the element name.
`AbstractParseState`
`startElement(String tagName)`
Start a new tag.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### context

protected String context
SAX context string.

### elementName

protected String elementName
The name of the element being parsed.

### text

protected StringBuffer text
Accumulates any text that appears within the element tags.

## Constructor Details

### AbstractParseState

public AbstractParseState()

## Method Details

### setElementName

public void setElementName(String name)
Sets the element name.

Parameters:
  `name` - the name of the element.

### jumpTo

public AbstractParseState jumpTo()
Jumps to the specified state that the current state needs to go.

Returns:
  the other state.

### parseAttrs

public void parseAttrs(Attributes attrs) throws XMLParserException
Called to parse attributes. This is the first method called after the state is created.Returns the value of attribute name.

Parameters:
  `attrs` - the SAX attributes object
Throws:
  `XMLParserException` - if any parse exception
See Also:
  - `DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)`

### startElement

public AbstractParseState startElement(String tagName)
Start a new tag. Derived classes override this to create a state to handle the element. Call this method to issue an error for, and ignore, any unrecognized tags.

Parameters:
  `tagName` - the name of the starting element
Returns:
  the state to parse the given tag
See Also:
  - `DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)`

### getHandler

public abstract XMLParserHandler getHandler()
Returns the parser handler. Required to be implemented by derived states. States will implement this differently depending on whether the state is a normal or inner class.

Returns:
  the XML parser handler

### endElement

public void endElement(AbstractParseState state)
Called when a child element is ending.

Parameters:
  `state` - the child state that is ending

### end

public void end() throws SAXException
Called when the element for this state is ending.

Throws:
  `SAXException` - if the SAX exception is encountered.
See Also:
  - `DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)`

### getAttrib

protected String getAttrib(Attributes attrs, String attrName)
Parse a string value. Normalizes the string: blank strings are converted to a null string.

Parameters:
  `attrs` - the SAX attributes object
  `attrName` - the name of the attribute to parse
Returns:
  the parsed string