本文整理匯總了Java中javax.xml.parsers.SAXParser.reset方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXParser.reset方法的具體用法?Java SAXParser.reset怎麽用?Java SAXParser.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.parsers.SAXParser
的用法示例。
在下文中一共展示了SAXParser.reset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: returnParser
import javax.xml.parsers.SAXParser; //導入方法依賴的package包/類
public void returnParser(SAXParser saxParser) {
saxParser.reset();
resetSaxParser(saxParser);
put(saxParser);
}
示例2: returnParser
import javax.xml.parsers.SAXParser; //導入方法依賴的package包/類
public void returnParser(SAXParser saxParser) {
saxParser.reset();
put(saxParser);
}
示例3: parseAndCheckReset
import javax.xml.parsers.SAXParser; //導入方法依賴的package包/類
private void parseAndCheckReset(boolean setFeature, boolean value) throws Exception {
// Expected result based on system property and feature
boolean resetExpected = setFeature && value;
// Indicates if system property is set
boolean spSet = runWithAllPerm(() -> System.getProperty(RESET_FEATURE)) != null;
// Dummy xml input for parser
String input = "<dummy>Test</dummy>";
// Check if system property is set only when feature setting is not requested
// and estimate if reset of symbol table is expected
if (!setFeature && spSet) {
resetExpected = runWithAllPerm(() -> Boolean.getBoolean(RESET_FEATURE));
}
// Create SAXParser and set feature if it is requested
SAXParserFactory spf = SAXParserFactory.newInstance();
if (setFeature) {
spf.setFeature(RESET_FEATURE, value);
}
SAXParser p = spf.newSAXParser();
// First parse iteration
p.parse(new InputSource(new StringReader(input)), new DefaultHandler());
// Get first symbol table reference
Object symTable1 = p.getProperty(SYMBOL_TABLE_PROPERTY);
// reset parser
p.reset();
// Second parse iteration
p.parse(new InputSource(new StringReader(input)), new DefaultHandler());
// Get second symbol table reference
Object symTable2 = p.getProperty(SYMBOL_TABLE_PROPERTY);
// Check symbol table references after two subsequent parse operations
if (resetExpected) {
Assert.assertNotSame(symTable1, symTable2, "Symbol table references");
} else {
Assert.assertSame(symTable1, symTable2, "Symbol table references");
}
}