|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.xml.stream.XMLOutputFactory
public abstract class XMLOutputFactory
The class represents the factory for getting XMLStreamWriter
intances.
The default implementation automatically
recycles any writer which has been
closed.
Usage example:
// Lets format to an appendable.
TextBuilder xml = new TextBuilder();
AppendableWriter out = new AppendableWriter(xml);
// Creates a factory producing writers using tab indentation.
XMLOutpuFactory factory = XMLOutputFactory.newInstance();
factory.setProperty(XMLOutputFactory.INDENTATION, "/t");
// Creates a new writer (potentially recycled).
XMLStreamWriter writer = factory.createXMLStreamReader(out);
// Formats to XML.
writer.writeStartDocument();
writer.writeStartElement(...);
...
writer.close(); // Automatically recycles this writer.
out.close(); // Underlying output should be closed explicitly.
// Displays the formatted output.
System.out.println(xml);
| Field Summary | |
|---|---|
static java.lang.String |
AUTOMATIC_EMPTY_ELEMENTS
Property indicating if the stream writers are allowed to automatically output empty elements when a start element is immediately followed by matching end element (type: Boolean, default: FALSE). |
static Configurable<java.lang.Class<? extends XMLOutputFactory>> |
DEFAULT
Holds the XMLOutputFactory default implementation (configurable). |
static java.lang.String |
INDENTATION
Property used to specify an indentation string; non-null indentation forces the writer to write elements into separate lines (type: String, default: null). |
static java.lang.String |
IS_REPAIRING_NAMESPACES
Property used to set prefix defaulting on the output side (type: Boolean, default: FALSE). |
static java.lang.String |
REPAIRING_PREFIX
Property used to specify the prefix to be appended by a trailing part (a sequence number) in order to make it unique to be usable as a temporary non-colliding prefix when repairing namespaces (type: String, default: "ns"). |
| Constructor Summary | |
|---|---|
protected |
XMLOutputFactory()
Default constructor. |
| Method Summary | |
|---|---|
abstract XMLStreamWriter |
createXMLStreamWriter(java.io.OutputStream stream)
Returns a XML stream writer to the specified output stream (UTF-8 encoding). |
abstract XMLStreamWriter |
createXMLStreamWriter(java.io.OutputStream stream,
java.lang.String encoding)
Returns a XML stream writer to the specified output stream using the specified encoding. |
abstract XMLStreamWriter |
createXMLStreamWriter(java.io.Writer writer)
Returns a XML stream writer to the specified i/o writer. |
abstract java.lang.Object |
getProperty(java.lang.String name)
Gets a feature/property on the underlying implementation. |
abstract boolean |
isPropertySupported(java.lang.String name)
Queries the set of properties that this factory supports. |
static XMLOutputFactory |
newInstance()
Returns a new instance of the DEFAULT output factory
implementation which may be configurated by the user
(see setProperty(String, Object)). |
abstract void |
setProperty(java.lang.String name,
java.lang.Object value)
Allows the user to set specific features/properties on the underlying implementation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Configurable<java.lang.Class<? extends XMLOutputFactory>> DEFAULT
public static final java.lang.String IS_REPAIRING_NAMESPACES
Boolean, default: FALSE).
public static final java.lang.String REPAIRING_PREFIX
String, default: "ns").
public static final java.lang.String INDENTATION
String, default: null).
public static final java.lang.String AUTOMATIC_EMPTY_ELEMENTS
Boolean, default: FALSE).
| Constructor Detail |
|---|
protected XMLOutputFactory()
| Method Detail |
|---|
public static XMLOutputFactory newInstance()
DEFAULT output factory
implementation which may be configurated by the user
(see setProperty(String, Object)). The output factory
instance is allocated through ObjectFactory.getInstance(Class).
public abstract XMLStreamWriter createXMLStreamWriter(java.io.Writer writer)
throws XMLStreamException
writer - the writer to write to.
XMLStreamException
public abstract XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream)
throws XMLStreamException
stream - the stream to write to.
XMLStreamException
public abstract XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream,
java.lang.String encoding)
throws XMLStreamException
stream - the stream to write to.encoding - the encoding to use.
XMLStreamException
public abstract void setProperty(java.lang.String name,
java.lang.Object value)
throws java.lang.IllegalArgumentException
name - the name of the property.value - the value of the property.
java.lang.IllegalArgumentException - if the property is not supported.
public abstract java.lang.Object getProperty(java.lang.String name)
throws java.lang.IllegalArgumentException
name - the name of the property
java.lang.IllegalArgumentException - if the property is not supported.public abstract boolean isPropertySupported(java.lang.String name)
name - the name of the property (may not be null).
true if the property is supported;
false otherwise.
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||