org.eclipse.xsd.util
Class XSDParser

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.eclipse.xsd.util.XSDParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler

public class XSDParser
extends DefaultHandler
implements LexicalHandler

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 of each node to its user data. This class is not intended for reuse outside of the model implementation and is subject to change.


Field Summary
protected  int column
           
protected  Document document
           
protected  Element element
           
protected  String encoding
           
protected  JAXPPool jaxpPool
           
protected  int line
           
protected  Locator locator
           
protected  SAXParser saxParser
           
protected  Stack stack
           
protected static Map userDataMap
           
protected  List xsdDiagnostics
           
protected  XSDFactory xsdFactory
           
protected  XSDSchema xsdSchema
           
 
Constructor Summary
XSDParser()
          Deprecated. since 2.2
XSDParser(Map options)
           
 
Method Summary
 void characters(char[] characters, int start, int length)
           
 void comment(char[] characters, int start, int length)
           
static Document createDocument()
           
 void endCDATA()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(String uri, String localName, String qName)
           
 void endEntity(String name)
           
 void error(SAXParseException exception)
           
protected  void fatalError(IOException exception)
           
protected  void fatalError(ParserConfigurationException exception)
           
 void fatalError(SAXException exception)
           
 void fatalError(SAXParseException exception)
           
 Collection getDiagnostics()
           
 Document getDocument()
           
 String getEncoding()
           
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 Map getUserData(Node node)
          Returns the user data associated with the node.
 void parse(InputSource inputSource)
           
 void parse(InputStream inputStream)
           
 void parse(String uri)
           
 void parseString(String input)
           
 void processingInstruction(String target, String data)
           
 InputSource resolveEntity(String publicId, String systemId)
           
protected  void saveLocation()
           
 void setDocumentLocator(Locator locator)
           
 void setSchema(XSDSchema xsdSchema)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String uri, String localName, String qName, Attributes attributes)
           
 void startEntity(String name)
           
 void warning(SAXParseException exception)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userDataMap

protected static final Map userDataMap

xsdFactory

protected XSDFactory xsdFactory

xsdSchema

protected XSDSchema xsdSchema

xsdDiagnostics

protected List xsdDiagnostics

saxParser

protected SAXParser saxParser

jaxpPool

protected JAXPPool jaxpPool

document

protected Document document

stack

protected Stack stack

element

protected Element element

locator

protected Locator locator

line

protected int line

column

protected int column

encoding

protected String encoding
Constructor Detail

XSDParser

public XSDParser()
Deprecated. since 2.2


XSDParser

public XSDParser(Map options)
Method Detail

getUserData

public static 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.

Parameters:
node - 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:
node - 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:
node - 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:
node - 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:
node - the node to query.
Returns:
the column at which the given node ends.

parse

public void parse(String uri)

parseString

public void parseString(String input)

parse

public void parse(InputSource inputSource)

parse

public void parse(InputStream inputStream)

getEncoding

public String getEncoding()

getDocument

public Document getDocument()

setSchema

public void setSchema(XSDSchema xsdSchema)

getSchema

public XSDSchema getSchema()

getDiagnostics

public Collection getDiagnostics()

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
Specified by:
startDocument in interface ContentHandler

createDocument

public static Document createDocument()

endDocument

public void endDocument()
Specified by:
endDocument in interface ContentHandler

characters

public void characters(char[] characters,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

comment

public void comment(char[] characters,
                    int start,
                    int length)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
Specified by:
startCDATA in interface LexicalHandler

endCDATA

public void endCDATA()
Specified by:
endCDATA in interface LexicalHandler

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
Specified by:
startDTD in interface LexicalHandler

endDTD

public void endDTD()
Specified by:
endDTD in interface LexicalHandler

startEntity

public void startEntity(String name)
Specified by:
startEntity in interface LexicalHandler

endEntity

public void endEntity(String name)
Specified by:
endEntity in interface LexicalHandler

processingInstruction

public void processingInstruction(String target,
                                  String data)
Specified by:
processingInstruction in interface ContentHandler

fatalError

protected void fatalError(IOException exception)

fatalError

protected void fatalError(ParserConfigurationException exception)

fatalError

public void fatalError(SAXException exception)

fatalError

public void fatalError(SAXParseException exception)
Specified by:
fatalError in interface ErrorHandler

error

public void error(SAXParseException exception)
Specified by:
error in interface ErrorHandler

warning

public void warning(SAXParseException exception)
Specified by:
warning in interface ErrorHandler

saveLocation

protected void saveLocation()

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException
Specified by:
resolveEntity in interface EntityResolver
Throws:
SAXException

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.