org.eclipse.ercp.xml.parser
Class AbstractSAXParserImpl

java.lang.Object
  extended by javax.xml.parsers.SAXParser
      extended by org.eclipse.ercp.xml.parser.AbstractSAXParserImpl
All Implemented Interfaces:
Locator
Direct Known Subclasses:
SAXParserImpl

public abstract class AbstractSAXParserImpl
extends SAXParser
implements Locator

This class implements the default behavior for a non-validating XML parser using SAX 2.0 APIs Subset for JSR 172 This class is abstract to supports several concrete subclesses: - SAXParserImpl for CLDC (JSR 172) - SAXParserImpl for Core and bigger - XMLStateMachineParser Grammar: - - The assumptions of this parser is: - The XML file is lexicaly and syntaxy correct - There is not twice the same Namespace prefix declared - The prefix 'xml' is never used to declare a namespace (this namespace is always associated to - The XML file prolog doesn't contain any: - declaration - The characters used as element, attribute or CData respect the XML specs defined in


Field Summary
static int ATTEQUAL_STATE
           
static int ATTLIST_STATE
           
static int ATTNAME_STATE
           
static int ATTVALUE_STATE
           
static int CDATA_END_STATE
           
static int CDATA_END2_STATE
           
static int CDATA_STATE
           
static int CDATA_VALUE_STATE
           
static int CMT2_STATE
           
static int CMT3_STATE
           
static int CMT4_STATE
           
static int CMT5_STATE
           
protected  NSDeclaration currentNSDecl
           
static int DOC_STATE
           
static int DOCTYPE_STATE
           
static int DOCTYPE_VALUE_STATE
           
static int DT_DECL_STATE
           
static int END_ELEMENT_NAME_STATE
           
static int END_ELEMENT_STATE
           
static int END_ELEMENT2_STATE
           
static int ENDTAG_STATE
           
protected  boolean fStringInterning
           
protected  boolean fXmlNSUris
           
static java.lang.String LexicalHandlerID
           
static int MISC_STATE
           
static int MISC2_STATE
           
static java.lang.String NamespacePrefixesFeature
           
static java.lang.String NamespacesFeature
           
static int PROLOG_STATE
           
static int REF_STATE
           
static int REF2_STATE
           
static int REF2NAME_STATE
           
static int REFNAME_STATE
           
static int START_ELEMENT_STATE
           
static java.lang.String StringInterningFeature
           
static int VALUE_STATE
           
static int WriteBufferSize
           
static java.lang.String XmlNSUris
           
static java.lang.String XmlOrgFeaturesPrefix
           
static java.lang.String XmlOrgPropertiesPrefix
           
static int XPI_ATTEQUAL_STATE
           
static int XPI_ATTNAME_STATE
           
static int XPI_ATTVALUE_STATE
           
static int XPI_DATA_END_STATE
           
static int XPI_DATA_STATE
           
static int XPI_DATA_VALUE_STATE
           
static int XPI_STATE
           
static int XPI_TARGET_NAME_STATE
           
static int XPI_VALUE_STATE
           
static int XPI_XML_END_STATE
           
static int XPI_XML_TARGET_STATE
           
 
Constructor Summary
AbstractSAXParserImpl()
           
 
Method Summary
protected  void addAttribute(java.lang.String namespace, java.lang.String qName, java.lang.String localName, java.lang.String attvalue)
           
protected abstract  boolean canDoStringInterning()
           
protected abstract  void characters(char[] ch, int start, int length)
          Match the SAX API
protected abstract  void endCDATA()
          Match the SAX2 API: Fire endCDATA event
protected abstract  void endDocument()
          End the parsing
protected abstract  void endElement(java.lang.String qName, java.lang.String namespace, java.lang.String localName)
          Match the SAX API
protected abstract  void endPrefixMapping(NSDeclaration nsDecl)
          Ending prefix Mapping
protected static java.lang.String errorMsg(java.lang.String errorMsg, java.lang.String parameter)
          Return a String describing the parsing error.
protected abstract  void fatalError(java.lang.String errorMsg, java.lang.String parameter)
          A fatal error was encountered.
 CharDecoder getCharDecoder()
          Returns the XML character decoder.
 int getColumnNumber()
          Return the column number where the current document event ends.
 int getCurrentState()
          Returns the current parser state (state machine)
 java.lang.String getElementLocalName()
          Returns the current element local name The element is not already anlyzed
 boolean getFeature(java.lang.String name)
           
 int getLineNumber()
          Return the line number where the current document event ends.
 java.lang.Object getProperty(java.lang.String name)
          Returns the particular property requested for in the underlying implementation of XMLReader.
 java.lang.String getPublicId()
          Return the public identifier for the current document event.
protected  java.lang.Object getRecognizedXmlOrgProperty(java.lang.String name)
          By default, we don't support the default properties...
 java.lang.String getSystemId()
          Return the system identifier for the current document event.
 java.lang.String getWriteBufferAsString()
          Returns the current parsed (but not analyzed) token
 boolean isNamespaceAware()
          Indicates whether or not this parser is configured to understand namespaces.
 boolean isValidating()
          Indicates whether or not this parser is configured to validate XML documents.
 void parse(InputSource inputSource)
          Internal call
 void parse(java.lang.String systemId)
           
 boolean parseNextCharacter(int c)
           
protected abstract  void processingInstruction(java.lang.String target, java.lang.String data)
          Match the SAX API
 void resetParser()
           
 void setCharDecoder(CharDecoder charDecoder)
          Sets the XML character decoder.
 void setFeature(java.lang.String name, boolean value)
           
 void setNamespaceAware(boolean awareness)
          Specifies that the parser produced by this code will provide support for XML namespaces.
 void setProperty(java.lang.String name, java.lang.Object value)
          Sets the particular property in the underlying implementation of XMLReader.
protected  void setRecognizedXmlOrgProperty(java.lang.String name, java.lang.Object value)
          By default, we don't support the default properties...
protected abstract  void startCDATA()
          Match the SAX2 API: Fire startCDATA event
protected abstract  void startDocument()
          Start parsing
protected abstract  void startElement(java.lang.String qName, java.lang.String namespace, java.lang.String localName, AttributesImpl attributes)
          Match the SAX API
protected abstract  void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Starting prefix mapping
protected abstract  void warning(java.lang.String errorMsg, java.lang.String parameter)
          A warning case was encountered.
 
Methods inherited from class javax.xml.parsers.SAXParser
getParser, getXMLReader, parse, parse, parse, parse, parse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentNSDecl

protected NSDeclaration currentNSDecl

fStringInterning

protected boolean fStringInterning

fXmlNSUris

protected boolean fXmlNSUris

WriteBufferSize

public static int WriteBufferSize

XmlOrgFeaturesPrefix

public static final java.lang.String XmlOrgFeaturesPrefix
See Also:
Constant Field Values

NamespacesFeature

public static final java.lang.String NamespacesFeature
See Also:
Constant Field Values

NamespacePrefixesFeature

public static final java.lang.String NamespacePrefixesFeature
See Also:
Constant Field Values

StringInterningFeature

public static final java.lang.String StringInterningFeature
See Also:
Constant Field Values

XmlNSUris

public static final java.lang.String XmlNSUris
See Also:
Constant Field Values

XmlOrgPropertiesPrefix

public static final java.lang.String XmlOrgPropertiesPrefix
See Also:
Constant Field Values

LexicalHandlerID

public static final java.lang.String LexicalHandlerID
See Also:
Constant Field Values

DOC_STATE

public static final int DOC_STATE
See Also:
Constant Field Values

PROLOG_STATE

public static final int PROLOG_STATE
See Also:
Constant Field Values

XPI_STATE

public static final int XPI_STATE
See Also:
Constant Field Values

MISC_STATE

public static final int MISC_STATE
See Also:
Constant Field Values

MISC2_STATE

public static final int MISC2_STATE
See Also:
Constant Field Values

DT_DECL_STATE

public static final int DT_DECL_STATE
See Also:
Constant Field Values

CMT2_STATE

public static final int CMT2_STATE
See Also:
Constant Field Values

CMT3_STATE

public static final int CMT3_STATE
See Also:
Constant Field Values

CMT4_STATE

public static final int CMT4_STATE
See Also:
Constant Field Values

CMT5_STATE

public static final int CMT5_STATE
See Also:
Constant Field Values

START_ELEMENT_STATE

public static final int START_ELEMENT_STATE
See Also:
Constant Field Values

END_ELEMENT_STATE

public static final int END_ELEMENT_STATE
See Also:
Constant Field Values

END_ELEMENT_NAME_STATE

public static final int END_ELEMENT_NAME_STATE
See Also:
Constant Field Values

END_ELEMENT2_STATE

public static final int END_ELEMENT2_STATE
See Also:
Constant Field Values

ENDTAG_STATE

public static final int ENDTAG_STATE
See Also:
Constant Field Values

ATTLIST_STATE

public static final int ATTLIST_STATE
See Also:
Constant Field Values

ATTNAME_STATE

public static final int ATTNAME_STATE
See Also:
Constant Field Values

ATTEQUAL_STATE

public static final int ATTEQUAL_STATE
See Also:
Constant Field Values

ATTVALUE_STATE

public static final int ATTVALUE_STATE
See Also:
Constant Field Values

VALUE_STATE

public static final int VALUE_STATE
See Also:
Constant Field Values

REF_STATE

public static final int REF_STATE
See Also:
Constant Field Values

REFNAME_STATE

public static final int REFNAME_STATE
See Also:
Constant Field Values

REF2_STATE

public static final int REF2_STATE
See Also:
Constant Field Values

REF2NAME_STATE

public static final int REF2NAME_STATE
See Also:
Constant Field Values

XPI_TARGET_NAME_STATE

public static final int XPI_TARGET_NAME_STATE
See Also:
Constant Field Values

XPI_DATA_STATE

public static final int XPI_DATA_STATE
See Also:
Constant Field Values

XPI_DATA_VALUE_STATE

public static final int XPI_DATA_VALUE_STATE
See Also:
Constant Field Values

XPI_DATA_END_STATE

public static final int XPI_DATA_END_STATE
See Also:
Constant Field Values

XPI_XML_END_STATE

public static final int XPI_XML_END_STATE
See Also:
Constant Field Values

XPI_XML_TARGET_STATE

public static final int XPI_XML_TARGET_STATE
See Also:
Constant Field Values

XPI_ATTNAME_STATE

public static final int XPI_ATTNAME_STATE
See Also:
Constant Field Values

XPI_ATTEQUAL_STATE

public static final int XPI_ATTEQUAL_STATE
See Also:
Constant Field Values

XPI_ATTVALUE_STATE

public static final int XPI_ATTVALUE_STATE
See Also:
Constant Field Values

XPI_VALUE_STATE

public static final int XPI_VALUE_STATE
See Also:
Constant Field Values

CDATA_STATE

public static final int CDATA_STATE
See Also:
Constant Field Values

DOCTYPE_STATE

public static final int DOCTYPE_STATE
See Also:
Constant Field Values

CDATA_VALUE_STATE

public static final int CDATA_VALUE_STATE
See Also:
Constant Field Values

DOCTYPE_VALUE_STATE

public static final int DOCTYPE_VALUE_STATE
See Also:
Constant Field Values

CDATA_END_STATE

public static final int CDATA_END_STATE
See Also:
Constant Field Values

CDATA_END2_STATE

public static final int CDATA_END2_STATE
See Also:
Constant Field Values
Constructor Detail

AbstractSAXParserImpl

public AbstractSAXParserImpl()
Method Detail

resetParser

public void resetParser()

addAttribute

protected void addAttribute(java.lang.String namespace,
                            java.lang.String qName,
                            java.lang.String localName,
                            java.lang.String attvalue)
                     throws SAXException
Throws:
SAXException

parse

public void parse(java.lang.String systemId)
           throws java.io.IOException,
                  SAXException
Throws:
java.io.IOException
SAXException
See Also:
XMLReader.parse(String)

parse

public void parse(InputSource inputSource)
           throws java.io.IOException,
                  SAXException
Internal call

Throws:
java.io.IOException
SAXException

parseNextCharacter

public boolean parseNextCharacter(int c)
                           throws SAXException
Throws:
SAXException

setCharDecoder

public void setCharDecoder(CharDecoder charDecoder)
Sets the XML character decoder.


getCharDecoder

public CharDecoder getCharDecoder()
Returns the XML character decoder.


getWriteBufferAsString

public java.lang.String getWriteBufferAsString()
Returns the current parsed (but not analyzed) token


getElementLocalName

public java.lang.String getElementLocalName()
Returns the current element local name The element is not already anlyzed


getCurrentState

public int getCurrentState()
Returns the current parser state (state machine)

Returns:
byte =

errorMsg

protected static java.lang.String errorMsg(java.lang.String errorMsg,
                                           java.lang.String parameter)
Return a String describing the parsing error. This method can be overwrite by the subclasses to provide a better decription. By default it is the error number.


isValidating

public boolean isValidating()
Indicates whether or not this parser is configured to validate XML documents.

Specified by:
isValidating in class SAXParser
Returns:
true if this parser is configured to validate XML documents; false otherwise. but eXML is a non validating parser so return always 'false'

isNamespaceAware

public boolean isNamespaceAware()
Indicates whether or not this parser is configured to understand namespaces.

Specified by:
isNamespaceAware in class SAXParser
Returns:
true if this parser is configured to understand namespaces; false otherwise.

setNamespaceAware

public void setNamespaceAware(boolean awareness)
Specifies that the parser produced by this code will provide support for XML namespaces. By default the value of this is set to false.

Parameters:
awareness - true if the parser produced by this code will provide support for XML namespaces; false otherwise.

getFeature

public boolean getFeature(java.lang.String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Throws:
SAXNotRecognizedException
SAXNotSupportedException
See Also:
XMLReader.getFeature(String)

setFeature

public void setFeature(java.lang.String name,
                       boolean value)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
Throws:
SAXNotRecognizedException
SAXNotSupportedException
See Also:
XMLReader.setFeature(String, boolean)

getProperty

public java.lang.Object getProperty(java.lang.String name)
                             throws SAXNotRecognizedException,
                                    SAXNotSupportedException
Description copied from class: SAXParser
Returns the particular property requested for in the underlying implementation of XMLReader.

Specified by:
getProperty in class SAXParser
Parameters:
name - The name of the property to be retrieved.
Returns:
Value of the requested property.
Throws:
SAXNotRecognizedException - When the underlying XMLReader does not recognize the property name.
SAXNotSupportedException - When the underlying XMLReader recognizes the property name but doesn't support the property.
See Also:
XMLReader.getProperty(String)

getRecognizedXmlOrgProperty

protected java.lang.Object getRecognizedXmlOrgProperty(java.lang.String name)
                                                throws SAXNotSupportedException
By default, we don't support the default properties...

Throws:
SAXNotSupportedException

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Description copied from class: SAXParser
Sets the particular property in the underlying implementation of XMLReader. A list of the core features and properties can be found at http://www.megginson.com/SAX/Java/features.html

Specified by:
setProperty in class SAXParser
Parameters:
name - The name of the property to be set.
value - The value of the property to be set.
Throws:
SAXNotRecognizedException - When the underlying XMLReader does not recognize the property name.
SAXNotSupportedException - When the underlying XMLReader recognizes the property name but doesn't support the property.
See Also:
XMLReader.setProperty(String, Object)

setRecognizedXmlOrgProperty

protected void setRecognizedXmlOrgProperty(java.lang.String name,
                                           java.lang.Object value)
                                    throws SAXNotSupportedException
By default, we don't support the default properties...

Throws:
SAXNotSupportedException

canDoStringInterning

protected abstract boolean canDoStringInterning()

startCDATA

protected abstract void startCDATA()
                            throws SAXException
Match the SAX2 API: Fire startCDATA event

Throws:
SAXException

endCDATA

protected abstract void endCDATA()
                          throws SAXException
Match the SAX2 API: Fire endCDATA event

Throws:
SAXException

processingInstruction

protected abstract void processingInstruction(java.lang.String target,
                                              java.lang.String data)
                                       throws SAXException
Match the SAX API

Parameters:
target -
data -
Throws:
SAXException

characters

protected abstract void characters(char[] ch,
                                   int start,
                                   int length)
                            throws SAXException
Match the SAX API

Parameters:
ch -
start -
length -
Throws:
SAXException

startElement

protected abstract void startElement(java.lang.String qName,
                                     java.lang.String namespace,
                                     java.lang.String localName,
                                     AttributesImpl attributes)
                              throws SAXException
Match the SAX API

Parameters:
ch -
start -
length -
Throws:
SAXException

endElement

protected abstract void endElement(java.lang.String qName,
                                   java.lang.String namespace,
                                   java.lang.String localName)
                            throws SAXException
Match the SAX API

Parameters:
ch -
start -
length -
Throws:
SAXException

startDocument

protected abstract void startDocument()
                               throws SAXException
Start parsing

Throws:
SAXException

endDocument

protected abstract void endDocument()
                             throws SAXException
End the parsing

Throws:
SAXException

endPrefixMapping

protected abstract void endPrefixMapping(NSDeclaration nsDecl)
                                  throws SAXException
Ending prefix Mapping

Throws:
SAXException

startPrefixMapping

protected abstract void startPrefixMapping(java.lang.String prefix,
                                           java.lang.String uri)
                                    throws SAXException
Starting prefix mapping

Throws:
SAXException

fatalError

protected abstract void fatalError(java.lang.String errorMsg,
                                   java.lang.String parameter)
                            throws SAXException
A fatal error was encountered.

Throws:
SAXException

warning

protected abstract void warning(java.lang.String errorMsg,
                                java.lang.String parameter)
                         throws SAXException
A warning case was encountered.

Throws:
SAXException

getColumnNumber

public int getColumnNumber()
Description copied from interface: Locator
Return the column number where the current document event ends. This is one-based number of Java char values since the last line end.

Warning: The return value from the method is intended only as an approximation for the sake of diagnostics; it is not intended to provide sufficient information to edit the character content of the original XML document. For example, when lines contain combining character sequences, wide characters, surrogate pairs, or bi-directional text, the value may not correspond to the column in a text editor's display.

The return value is an approximation of the column number in the document entity or external parsed entity where the markup triggering the event appears.

If possible, the SAX driver should provide the line position of the first character after the text associated with the document event. The first column in each line is column 1.

Specified by:
getColumnNumber in interface Locator
Returns:
The column number, or -1 if none is available.
See Also:
Locator.getLineNumber()

getLineNumber

public int getLineNumber()
Description copied from interface: Locator
Return the line number where the current document event ends. Lines are delimited by line ends, which are defined in the XML specification.

Warning: The return value from the method is intended only as an approximation for the sake of diagnostics; it is not intended to provide sufficient information to edit the character content of the original XML document. In some cases, these "line" numbers match what would be displayed as columns, and in others they may not match the source text due to internal entity expansion.

The return value is an approximation of the line number in the document entity or external parsed entity where the markup triggering the event appears.

If possible, the SAX driver should provide the line position of the first character after the text associated with the document event. The first line is line 1.

Specified by:
getLineNumber in interface Locator
Returns:
The line number, or -1 if none is available.
See Also:
Locator.getColumnNumber()

getPublicId

public java.lang.String getPublicId()
Description copied from interface: Locator
Return the public identifier for the current document event.

The return value is the public identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.

Specified by:
getPublicId in interface Locator
Returns:
A string containing the public identifier, or null if none is available.
See Also:
Locator.getSystemId()

getSystemId

public java.lang.String getSystemId()
Description copied from interface: Locator
Return the system identifier for the current document event.

The return value is the system identifier of the document entity or of the external parsed entity in which the markup triggering the event appears.

If the system identifier is a URL, the parser must resolve it fully before passing it to the application. For example, a file name must always be provided as a file:... URL, and other kinds of relative URI are also resolved against their bases.

Specified by:
getSystemId in interface Locator
Returns:
A string containing the system identifier, or null if none is available.
See Also:
Locator.getPublicId()