|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectXMLInputFactory
public abstract class XMLInputFactory
The class represents the factory for getting XMLStreamReader
intances.
The default implementation
automatically
recycles
any reader which has been
closed
.
Usage example:
// 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.
Field Summary | |
---|---|
static Configurable<Class<? extends XMLInputFactory>> |
CLASS
Holds the XMLInputFactory implementation (configurable). |
static String |
ENTITIES
Property used to specify additional entities to be recognized by the readers (type: java.util.Map , default: null ). |
static String |
IS_COALESCING
The property that requires the parser to coalesce adjacent character data sections (type: Boolean , default: FALSE ) |
Constructor Summary | |
---|---|
protected |
XMLInputFactory()
Default constructor. |
Method Summary | |
---|---|
abstract XMLStreamReader |
createXMLStreamReader(InputStream stream)
Returns a XML stream reader for the specified input stream (encoding autodetected). |
abstract XMLStreamReader |
createXMLStreamReader(InputStream stream,
String encoding)
Returns a XML stream reader for the specified input stream using the specified encoding. |
abstract XMLStreamReader |
createXMLStreamReader(Reader reader)
Returns a XML stream reader for the specified I/O reader. |
abstract Object |
getProperty(String name)
Gets the value of a feature/property from the underlying implementation. |
abstract boolean |
isPropertySupported(String name)
Queries the set of properties that this factory supports. |
static XMLInputFactory |
newInstance()
Returns a new instance of the CLASS input factory
implementation which may be configurated by the user
(see setProperty(String, Object) ). |
abstract void |
setProperty(String name,
Object value)
Allows the user to set specific feature/property on the underlying implementation. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Configurable<Class<? extends XMLInputFactory>> CLASS
public static final String IS_COALESCING
Boolean
, default: FALSE
)
public static final String ENTITIES
java.util.Map
, default: null
).
For example:
FastMap<String, String> HTML_ENTITIES = new FastMap<String, String>();
HTML_ENTITIES.put("nbsp", " ");
HTML_ENTITIES.put("copy", "??");
HTML_ENTITIES.put("eacute", "??");
...
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty(ENTITIES, HTML_ENTITIES);
Constructor Detail |
---|
protected XMLInputFactory()
Method Detail |
---|
public static XMLInputFactory newInstance()
CLASS
input factory
implementation which may be configurated by the user
(see setProperty(String, Object)
). The input factory
instance is allocated through ObjectFactory.getInstance(Class)
.
public abstract XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException
reader
- the XML data to read from.
XMLStreamException
public abstract XMLStreamReader createXMLStreamReader(InputStream stream) throws XMLStreamException
stream
- the input stream to read from.
XMLStreamException
public abstract XMLStreamReader createXMLStreamReader(InputStream stream, String encoding) throws XMLStreamException
stream
- the input stream to read from.encoding
- the character encoding of the stream.
XMLStreamException
public abstract void setProperty(String name, Object value) throws IllegalArgumentException
IllegalArgumentException
to signal that an unsupported
property may not be set with the specified value.
name
- the name of the property.value
- the value of the property
IllegalArgumentException
- if the property is not supported.public abstract Object getProperty(String name) throws IllegalArgumentException
name
- the name of the property (may not be null).
IllegalArgumentException
- if the property is not supported.public abstract boolean isPropertySupported(String name)
name
- the name of the property.
true
if the property is supported;
false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |