SAXFactoryImplpublic 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. |
Fields Summary |
---|
private SAXParserImpl | prototypeParserThe 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 | featuresThis 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 boolean | getFeature(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 SAXParserImpl | getPrototype()
if (prototypeParser == null) {
prototypeParser = new SAXParserImpl();
}
return prototypeParser;
| public javax.xml.parsers.SAXParser | newSAXParser()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 void | setFeature(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);
|
|