本文整理汇总了Java中jdk.internal.org.xml.sax.helpers.DefaultHandler类的典型用法代码示例。如果您正苦于以下问题:Java DefaultHandler类的具体用法?Java DefaultHandler怎么用?Java DefaultHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultHandler类属于jdk.internal.org.xml.sax.helpers包,在下文中一共展示了DefaultHandler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import jdk.internal.org.xml.sax.helpers.DefaultHandler; //导入依赖的package包/类
/**
* Parse the content given {@link org.xml.sax.InputSource}
* as XML using the specified
* {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param is The InputSource containing the content to be parsed.
* @param dh The SAX DefaultHandler to use.
*
* @throws IllegalArgumentException If the <code>InputSource</code> object
* is <code>null</code>.
* @throws IOException If any IO errors occur.
* @throws SAXException If any SAX errors occur during processing.
*
* @see org.xml.sax.DocumentHandler
*/
public void parse(InputSource is, DefaultHandler dh)
throws SAXException, IOException
{
if (is == null) {
throw new IllegalArgumentException("InputSource cannot be null");
}
XMLReader reader = this.getXMLReader();
if (dh != null) {
reader.setContentHandler(dh);
reader.setEntityResolver(dh);
reader.setErrorHandler(dh);
reader.setDTDHandler(dh);
}
reader.parse(is);
}
示例2: ParserSAX
import jdk.internal.org.xml.sax.helpers.DefaultHandler; //导入依赖的package包/类
/**
* Constructor.
*/
public ParserSAX() {
super();
// SAX feature defaut values
mFNamespaces = true;
mFPrefixes = false;
// Default handler which will be used in case the application
// do not set one of handlers.
mHand = new DefaultHandler();
mHandCont = mHand;
mHandDtd = mHand;
mHandErr = mHand;
mHandEnt = mHand;
}
示例3: parse
import jdk.internal.org.xml.sax.helpers.DefaultHandler; //导入依赖的package包/类
/**
* Parse the content given {@link org.xml.sax.InputSource} as XML using the
* specified {@link org.xml.sax.helpers.DefaultHandler}.
*
* @param is The InputSource containing the content to be parsed.
* @param handler The SAX DefaultHandler to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the InputSource or handler is
* null.
* @exception SAXException If the underlying parser throws a SAXException
* while parsing.
* @see org.xml.sax.helpers.DefaultHandler
*/
public void parse(InputSource is, DefaultHandler handler)
throws SAXException, IOException
{
if ((is == null) || (handler == null)) {
throw new IllegalArgumentException("");
}
// Set up the handler
mHandCont = handler;
mHandDtd = handler;
mHandErr = handler;
mHandEnt = handler;
// Set up the document
mInp = new Input(BUFFSIZE_READER);
mPh = PH_BEFORE_DOC; // before parsing
try {
setinp(is);
} catch (SAXException | IOException | RuntimeException saxe) {
throw saxe;
} catch (Exception e) {
panic(e.toString());
}
parse();
}