org.jvnet.wom.api.parser
Class WOMParser

java.lang.Object
  extended by org.jvnet.wom.api.parser.WOMParser

public final class WOMParser
extends java.lang.Object

Parses a WSDL and provides a model - WSDLSet. The interfaces provided by WOMParser are largely based on XSOM.

TODO: support for WSDL 2.0

Author:
Vivek Pandey

Constructor Summary
WOMParser()
          Creates a new WOMParser using SAX parser from the default implementation of XMLParser
WOMParser(javax.xml.parsers.SAXParserFactory factory)
          Creates a new WOMParser, the underlying XMLParser will use the factory to create SAX parser.
WOMParser(com.sun.xml.xsom.parser.XMLParser parser)
          Creates a new WOMParser that will use the given XMLParser to parse the WSDL.
 
Method Summary
 void addWSDLExtensionHandler(WSDLExtensionHandler extension)
           
 com.sun.xml.xsom.parser.XMLParser getDefaultXMLParserInstance()
          Gives the default XMLParser instance.
 org.xml.sax.EntityResolver getEntityResolver()
           
 org.xml.sax.ErrorHandler getErrorHandler()
           
 org.xml.sax.ContentHandler getParserHandler()
          Gets the parser implemented as a ContentHandler.
 WSDLSet getResult()
          Gets the parsed wsdl as WSDLSet.
 WSDLSet parse(java.io.File wsdl)
          Parses a WSDL document from the given File.
 WSDLSet parse(org.xml.sax.InputSource wsdl)
          Parses a new XML Schema document.
 WSDLSet parse(java.io.InputStream wsdl)
          Parses a WSDL document from the given InputStream.
 WSDLSet parse(java.io.Reader reader)
          Parses a WSDL document from the given Reader.
 WSDLSet parse(java.lang.String systemId)
          Parses a WSDL document from the given systemId
 WSDLSet parse(java.net.URL wsdl)
          Parses a WSDL document from the given URL.
 void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
          Set EntityResolver to resolve <wsdl:import
 void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
          ErrorHandler to receive any error/warning that happens during parsing.
 void setSchemaContentHandler(org.xml.sax.ContentHandler handler)
          WOM will fire events for the schema under <wsdl:types section to this ContentHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WOMParser

public WOMParser()
Creates a new WOMParser using SAX parser from the default implementation of XMLParser


WOMParser

public WOMParser(javax.xml.parsers.SAXParserFactory factory)
Creates a new WOMParser, the underlying XMLParser will use the factory to create SAX parser.

Parameters:
factory - Must be non-null. The factory must be configured correctly, such as SAXParserFactory.setNamespaceAware(true) must be called to create a namespace aware SAX parser.

WOMParser

public WOMParser(com.sun.xml.xsom.parser.XMLParser parser)
Creates a new WOMParser that will use the given XMLParser to parse the WSDL. The provided XMLParser will send SAX events to the WOM ContentHandler.

Parameters:
parser - non null.
Method Detail

parse

public WSDLSet parse(org.xml.sax.InputSource wsdl)
              throws java.io.IOException,
                     org.xml.sax.SAXException
Parses a new XML Schema document.

Note that if the InputSource does not have a system ID, WOM will fail to resolve them.

Returns:
Gives WSDLSet, null if there was any error.
Throws:
java.io.IOException
org.xml.sax.SAXException

parse

public WSDLSet parse(java.io.File wsdl)
              throws java.io.IOException,
                     org.xml.sax.SAXException
Parses a WSDL document from the given File.

Parameters:
wsdl - non-null
Returns:
Gives WSDLSet, null if there was any error.
Throws:
java.io.IOException
org.xml.sax.SAXException

parse

public WSDLSet parse(java.io.InputStream wsdl)
              throws org.xml.sax.SAXException
Parses a WSDL document from the given InputStream.

When using this method, WOM does not know the system ID of this document, therefore, when this stream contains relative references to other schemas, WOM will fail to resolve them. To specify an system ID with a stream, use InputSource

Returns:
Gives WSDLSet, null if there was any error.
Throws:
org.xml.sax.SAXException

parse

public WSDLSet parse(java.net.URL wsdl)
              throws org.xml.sax.SAXException
Parses a WSDL document from the given URL.

Parameters:
wsdl - non-null
Returns:
Gives WSDLSet, null if there was any error.
Throws:
org.xml.sax.SAXException

parse

public WSDLSet parse(java.lang.String systemId)
              throws org.xml.sax.SAXException
Parses a WSDL document from the given systemId

Parameters:
systemId - non-null
Returns:
Gives WSDLSet, null if there was any error.
Throws:
org.xml.sax.SAXException

parse

public WSDLSet parse(java.io.Reader reader)
              throws org.xml.sax.SAXException
Parses a WSDL document from the given Reader.

When using this method, WOM does not know the system ID of this document, therefore, when this reader contains relative references to other schemas, WOM will fail to resolve them. To specify an system ID with a reader, use InputSource

Returns:
Gives WSDLSet, null if there was any error.
Throws:
org.xml.sax.SAXException

getResult

public WSDLSet getResult()
                  throws org.xml.sax.SAXException
Gets the parsed wsdl as WSDLSet. Call this method only after the parsing is done.

Throws:
org.xml.sax.SAXException

getEntityResolver

public org.xml.sax.EntityResolver getEntityResolver()

getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()

setEntityResolver

public void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
Set EntityResolver to resolve <wsdl:import


setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
ErrorHandler to receive any error/warning that happens during parsing.


setSchemaContentHandler

public void setSchemaContentHandler(org.xml.sax.ContentHandler handler)
WOM will fire events for the schema under <wsdl:types section to this ContentHandler. The idea is that the schema inside a WSDL can be parsed and a schema object model can be created and used by for the purpose of data binding.

Parameters:
handler - always non-null

addWSDLExtensionHandler

public void addWSDLExtensionHandler(WSDLExtensionHandler extension)

getDefaultXMLParserInstance

public com.sun.xml.xsom.parser.XMLParser getDefaultXMLParserInstance()
Gives the default XMLParser instance. This can be used when a custom XMLParser wants to use the default as a fallback parser.


getParserHandler

public org.xml.sax.ContentHandler getParserHandler()
Gets the parser implemented as a ContentHandler. One can feed WSDL or XML Schema as SAX events to this interface to parse a WSDL. To parse multiple WSDL files, feed multiple sets of events.

If you don't send a complete event sequence from a startDocument event to an endDocument event, the state of WOMParser can become unstable. This sometimes happen when you encounter an error while generating SAX events. Don't call the getResult method in that case.



Copyright © 2009 Sun Microsystems, Inc. All Rights Reserved.