Java Code Examples for javax.xml.parsers.SAXParser#reset()

The following examples show how to use javax.xml.parsers.SAXParser#reset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JarConfigLoader.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void parseConfigXML( final InputStream in,
        final IEmitterDescriptor descriptor,
        final Map<String, RenderOptionDefn> options ) throws Exception
{

    final SAXParser parser = CommonUtil.createSAXParser( );
    try
    {
        parser.parse( in, new RenderOptionHandler( descriptor, options ) );
    }
    finally
    {
        // even there is XML exception, need to release the resource.
        try
        {
            parser.reset( );
        }
        catch ( Exception e1 )
        {
            logger.log( Level.WARNING, "failed to parse config", e1 );
        }
    }
}
 
Example 2
Source File: ParserPool.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}
 
Example 3
Source File: ParserPool.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}
 
Example 4
Source File: ParserPool.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}
 
Example 5
Source File: ParserPool.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}
 
Example 6
Source File: ParserPool.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    put(saxParser);
}
 
Example 7
Source File: SymbolTableResetTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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");
    }
}
 
Example 8
Source File: ParserPool.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}
 
Example 9
Source File: ParserPool.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}
 
Example 10
Source File: ParserPool.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void returnParser(SAXParser saxParser) {
    saxParser.reset();
    resetSaxParser(saxParser);
    put(saxParser);
}