| java.lang.Object javolution.xml.stream.XMLInputFactory
XMLInputFactory | abstract public class XMLInputFactory (Code) | | The class represents the factory for getting
XMLStreamReader intances.
The
XMLInputFactory.newInstance() default implementation automatically
ObjectFactory.recycle recycles any reader which has been
XMLStreamReader.close closed .
Usage example:[code]
// Lets read a CharSequence input.
String xml = "...";
CharSequenceReader in = new CharSequenceReader().setInput(xml);
// Creates a factory of readers coalescing adjacent character data.
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(XMLInputFactory.IS_COALESCING, true);
// Creates a new reader (potentially recycled).
XMLStreamReader reader = factory.createXMLStreamReader(in);
// Parses XML.
for (int e=reader.next(); e != XMLStreamConstants.END_DOCUMENT; e = reader.next()) {
switch (e) { // Event.
...
}
}
reader.close(); // Automatically recycles this writer.
in.close(); // Underlying input should be closed explicitly.
[/code]
author: Jean-Marie Dautelle version: 4.0, September 4, 2006 |
Field Summary | |
final public static Configurable | DEFAULT Holds the XMLInputFactory default implementation (configurable). | final public static String | ENTITIES Property used to specify additional entities to be recognized by the
readers (type: java.util.Map , default: null ). | final public static String | IS_COALESCING |
DEFAULT | final public static Configurable DEFAULT(Code) | | Holds the XMLInputFactory default implementation (configurable).
|
ENTITIES | final public static String ENTITIES(Code) | | Property used to specify additional entities to be recognized by the
readers (type: java.util.Map , default: null ).
For example:[code]
FastMap HTML_ENTITIES = new FastMap();
HTML_ENTITIES.put("nbsp", " ");
HTML_ENTITIES.put("copy", "©");
HTML_ENTITIES.put("eacute", "é");
...
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(ENTITIES, HTML_ENTITIES);
[/code]
|
IS_COALESCING | final public static String IS_COALESCING(Code) | | The property that requires the parser to coalesce adjacent character data
sections (type: Boolean , default: FALSE )
|
XMLInputFactory | protected XMLInputFactory()(Code) | | Default constructor.
|
createXMLStreamReader | abstract public XMLStreamReader createXMLStreamReader(InputStream stream, String encoding) throws XMLStreamException(Code) | | Returns a XML stream reader for the specified input stream using the
specified encoding.
Parameters: stream - the input stream to read from. Parameters: encoding - the character encoding of the stream. throws: XMLStreamException - |
isPropertySupported | abstract public boolean isPropertySupported(String name)(Code) | | Queries the set of properties that this factory supports.
Parameters: name - the name of the property. true if the property is supported;false otherwise. |
setProperty | abstract public void setProperty(String name, Object value) throws IllegalArgumentException(Code) | | Allows the user to set specific feature/property on the underlying
implementation. The underlying implementation is not required to support
every setting of every property in the specification and may use
IllegalArgumentException to signal that an unsupported
property may not be set with the specified value.
Parameters: name - the name of the property. Parameters: value - the value of the property throws: IllegalArgumentException - if the property is not supported. |
|
|