com.ibm.etools.xsd.util
Class XSDParser

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--com.ibm.etools.xsd.util.XSDParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class XSDParser
extends DefaultHandler

The SAX Parser for the model. This handles the conversion of SAX parse exceptions to XSDDiagnostics. It also computes line column information, which is stored in a map on each node's user data. This class is not intended for reuse outside of the model implementation and is subject to change.


Field Summary
protected  int column
           
static java.lang.String copyright
           
protected static java.lang.String DEFAULT_PARSER_NAME
           
protected  Document document
           
protected  Element element
           
protected  int line
           
protected  Locator locator
           
protected  SAXParser saxParser
           
protected  java.util.Stack stack
           
protected  java.util.List xsdDiagnostics
           
protected  XSDFactory xsdFactory
          The cached factory.
protected  XSDPackage xsdPackage
          The cached package.
protected  XSDSchema xsdSchema
           
 
Constructor Summary
XSDParser()
           
 
Method Summary
 void characters(char[] characters, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void error(SAXParseException exception)
           
protected  void fatalError(java.io.IOException exception)
           
protected  void fatalError(ParserConfigurationException exception)
           
 void fatalError(SAXException exception)
           
 void fatalError(SAXParseException exception)
           
 java.util.Collection getDiagnostics()
           
 Document getDocument()
           
static int getEndColumn(Node node)
          Returns the column at which the given node ends.
static int getEndLine(Node node)
          Returns the line at which the given node ends.
 XSDSchema getSchema()
           
static int getStartColumn(Node node)
          Returns the column at which the given node starts.
static int getStartLine(Node node)
          Returns the line at which the given node starts.
static java.util.Map getUserData(Node node)
          Returns the user data associated with the node.
 void parse(java.io.InputStream inputStream)
           
 void parse(java.lang.String uri)
           
protected  void saveLocation()
           
 void setDocumentLocator(Locator locator)
           
 void setSchema(XSDSchema xsdSchema)
           
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes)
           
 void warning(SAXParseException exception)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright

DEFAULT_PARSER_NAME

protected static final java.lang.String DEFAULT_PARSER_NAME

xsdPackage

protected XSDPackage xsdPackage
The cached package.

xsdFactory

protected XSDFactory xsdFactory
The cached factory.

xsdSchema

protected XSDSchema xsdSchema

xsdDiagnostics

protected java.util.List xsdDiagnostics

saxParser

protected SAXParser saxParser

document

protected Document document

stack

protected java.util.Stack stack

element

protected Element element

locator

protected Locator locator

line

protected int line

column

protected int column
Constructor Detail

XSDParser

public XSDParser()
Method Detail

getUserData

public static java.util.Map getUserData(Node node)
Returns the user data associated with the node. If the node has no user data, a new empty map is created. A null will be returned only in the case that the node cannot have user data or already has some other type of user data.
Parameters:
to - the node to query.
Returns:
the user data associated with the node.

getStartLine

public static int getStartLine(Node node)
Returns the line at which the given node starts.
Parameters:
to - the node to query.
Returns:
the line at which the given node starts.

getStartColumn

public static int getStartColumn(Node node)
Returns the column at which the given node starts.
Parameters:
to - the node to query.
Returns:
the column at which the given node starts.

getEndLine

public static int getEndLine(Node node)
Returns the line at which the given node ends.
Parameters:
to - the node to query.
Returns:
the line at which the given node ends.

getEndColumn

public static int getEndColumn(Node node)
Returns the column at which the given node ends.
Parameters:
to - the node to query.
Returns:
the column at which the given node ends.

parse

public void parse(java.lang.String uri)

parse

public void parse(java.io.InputStream inputStream)

getDocument

public Document getDocument()

setSchema

public void setSchema(XSDSchema xsdSchema)

getSchema

public XSDSchema getSchema()

getDiagnostics

public java.util.Collection getDiagnostics()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         Attributes attributes)
                  throws SAXException
Overrides:
startElement in class DefaultHandler

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws SAXException
Overrides:
endElement in class DefaultHandler

setDocumentLocator

public void setDocumentLocator(Locator locator)
Overrides:
setDocumentLocator in class DefaultHandler

startDocument

public void startDocument()
Overrides:
startDocument in class DefaultHandler

endDocument

public void endDocument()
Overrides:
endDocument in class DefaultHandler

characters

public void characters(char[] characters,
                       int start,
                       int length)
                throws SAXException
Overrides:
characters in class DefaultHandler

fatalError

protected void fatalError(java.io.IOException exception)

fatalError

protected void fatalError(ParserConfigurationException exception)

fatalError

public void fatalError(SAXException exception)

fatalError

public void fatalError(SAXParseException exception)
Overrides:
fatalError in class DefaultHandler

error

public void error(SAXParseException exception)
Overrides:
error in class DefaultHandler

warning

public void warning(SAXParseException exception)
Overrides:
warning in class DefaultHandler

saveLocation

protected void saveLocation()