FileDocCategorySizeDatePackage
SAXFactoryImpl.javaAPI DocAndroid 1.5 API3776Wed May 06 22:41:42 BST 2009org.ccil.cowan.tagsoup.jaxp

SAXFactoryImpl

public class SAXFactoryImpl extends SAXParserFactory
This is a simple implementation of JAXP {@link SAXParserFactory}, to allow easier integration of TagSoup with the default JDK xml processing stack.
author
Tatu Saloranta (cowtowncoder@yahoo.com)

Fields Summary
private SAXParserImpl
prototypeParser
The easiest way to test validity of features to set is to use a prototype object. Currently this is actually not a real prototype, in the sense that the configuration is actually passed separately (as opposed to instantiating new readers from this prototype), but this could be changed in future, if TagSoup parser object allowed cloning.
private HashMap
features
This Map contains explicitly set features that can be succesfully set for XMLReader instances. Temporary storage is needed due to JAXP design: multiple readers can be instantiated from a single factory, and settings can be changed between instantiations.

Note that we wouldn't need this map if we could create instances directly using the prototype instance.

Constructors Summary
public SAXFactoryImpl()


     
    
        super();
    
Methods Summary
public booleangetFeature(java.lang.String name)
Returns whether the specified property will be enabled or disabled on reader instances constructed by this factory.

        return getPrototype().getFeature(name);
    
private SAXParserImplgetPrototype()

        if (prototypeParser == null) {
            prototypeParser = new SAXParserImpl();
        }
        return prototypeParser;
    
public javax.xml.parsers.SAXParsernewSAXParser()
Creates a new instance of SAXParser using the currently configured factory parameters.

        try {
            return SAXParserImpl.newInstance(features);
        } catch (SAXException se) {
            // Translate to ParserConfigurationException
            throw new ParserConfigurationException(se.getMessage());
        }
    
public voidsetFeature(java.lang.String name, boolean value)
Defines that the specified feature is to enabled/disabled (as per second argument) on reader instances created by this factory.

        // First, let's see if it's a valid call
        getPrototype().setFeature(name, value);

        // If not, exception was thrown: so we are good now:
        if (features == null) {
            // Let's retain the ordering as well
            features = new LinkedHashMap();
        }
        features.put(name, value ? Boolean.TRUE : Boolean.FALSE);