站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

SAXEntityParser (XML Tools API) - NetBeans API Javadoc (Current Development Version)

org.netbeans.api.xml/1 1.14

org.netbeans.api.xml.parsers
Class SAXEntityParser

java.lang.Object
  extended by org.netbeans.api.xml.parsers.SAXEntityParser
All Implemented Interfaces:
XMLReader

public class SAXEntityParser
extends Object
implements XMLReader

SAX parser wrapper allowing to parse parsed XML entities (including DTDs) for wellformedness.

Default implementation cannot be used for parsing of XML document entities! It wraps client's parser that it actually used for performing the parsing task.

Primary use case (parse general entity):

   XMLReader entityParser = new SAXEntityParser(xmlReader);
   entityParser.setErrorHandler(errorHandler);
   entityParser.parse(inputSource);
 
Secondary use case (delegating parser): It requires subclassing and allow subclass entirely define internal wrapping logic. Warning: Implementation gurantees only proper ErrorHandler callbacks.


Constructor Summary
SAXEntityParser(XMLReader peer)
          Creates a new instance of general entity parser.
SAXEntityParser(XMLReader peer, boolean generalEntity)
          Creates a new instance of SAXEntityParser.
 
Method Summary
 ContentHandler getContentHandler()
           
 DTDHandler getDTDHandler()
           
 EntityResolver getEntityResolver()
           
 ErrorHandler getErrorHandler()
           
 boolean getFeature(String name)
           
 Object getProperty(String name)
           
 void parse(InputSource entity)
          Start entity parsing using peer parser.
 void parse(String sid)
           
protected  boolean propagateException(SAXParseException ex)
          Examine if the exception should be propagated into client's ErrorHandler.
 void setContentHandler(ContentHandler contentHandler)
           
 void setDTDHandler(DTDHandler dTDHandler)
           
 void setEntityResolver(EntityResolver entityResolver)
           
 void setErrorHandler(ErrorHandler errorHandler)
           
 void setFeature(String name, boolean val)
           
 void setProperty(String name, Object val)
           
protected  InputSource wrapInputSource(InputSource input)
          Create wrapper input source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXEntityParser

public SAXEntityParser(XMLReader peer)
Creates a new instance of general entity parser.

Parameters:
peer - parser that will be used for parsing. Wrapped parser is exclusively owned by this class no other clients can share it.

SAXEntityParser

public SAXEntityParser(XMLReader peer,
                       boolean generalEntity)
Creates a new instance of SAXEntityParser.

Parameters:
peer - parser that will be used for parsing
generalEntity - if false treat entity as parameter entity (i.e. DTD entities).
Method Detail

parse

public void parse(InputSource entity)
           throws IOException,
                  SAXException
Start entity parsing using peer parser. Staring from this moment all other methods calls are not supported.

Specified by:
parse in interface XMLReader
Parameters:
entity - entity input source
Throws:
IOException
SAXException

wrapInputSource

protected InputSource wrapInputSource(InputSource input)
Create wrapper input source. Default implementation utilizes fact that default EntityResolver redirects the first query to wrapped InputSource.

Parameters:
input - InputSource to be wrapped.
Returns:
InputSource that hosts of client's one
Since:
0.6

propagateException

protected boolean propagateException(SAXParseException ex)
Examine if the exception should be propagated into client's ErrorHandler.

Parameters:
ex - examined exception
Returns:
true if the exception originates from client's InputSource and should be propagated.

getContentHandler

public ContentHandler getContentHandler()
Specified by:
getContentHandler in interface XMLReader

getDTDHandler

public DTDHandler getDTDHandler()
Specified by:
getDTDHandler in interface XMLReader

getEntityResolver

public EntityResolver getEntityResolver()
Specified by:
getEntityResolver in interface XMLReader

getErrorHandler

public ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface XMLReader

getFeature

public boolean getFeature(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Specified by:
getFeature in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

getProperty

public Object getProperty(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Specified by:
getProperty in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

parse

public void parse(String sid)
           throws IOException,
                  SAXException
Specified by:
parse in interface XMLReader
Throws:
IOException
SAXException

setContentHandler

public void setContentHandler(ContentHandler contentHandler)
Specified by:
setContentHandler in interface XMLReader

setDTDHandler

public void setDTDHandler(DTDHandler dTDHandler)
Specified by:
setDTDHandler in interface XMLReader

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)
Specified by:
setEntityResolver in interface XMLReader

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Specified by:
setErrorHandler in interface XMLReader

setFeature

public void setFeature(String name,
                       boolean val)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
Specified by:
setFeature in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

setProperty

public void setProperty(String name,
                        Object val)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Specified by:
setProperty in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

org.netbeans.api.xml/1 1.14

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.