|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectXMLOutputFactory
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 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<Class<? extends XMLOutputFactory>> |
CLASS
Holds the XMLOutputFactory implementation (configurable). |
static 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 String |
IS_REPAIRING_NAMESPACES
Property used to set prefix defaulting on the output side (type: Boolean , default: FALSE ). |
static String |
LINE_SEPARATOR
Property used to specify the new line characters (type: String , default: "\n" ). |
static String |
NO_EMPTY_ELEMENT_TAG
Property indicating if the stream writers are not allowed to use empty element tags (type: Boolean , default: FALSE ). |
static 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(OutputStream stream)
Returns a XML stream writer to the specified output stream (UTF-8 encoding). |
abstract XMLStreamWriter |
createXMLStreamWriter(OutputStream stream,
String encoding)
Returns a XML stream writer to the specified output stream using the specified encoding. |
abstract XMLStreamWriter |
createXMLStreamWriter(Writer writer)
Returns a XML stream writer to the specified i/o writer. |
abstract Object |
getProperty(String name)
Gets a feature/property on the underlying implementation. |
abstract boolean |
isPropertySupported(String name)
Queries the set of properties that this factory supports. |
static XMLOutputFactory |
newInstance()
Returns a new instance of the CLASS output 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 features/properties 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 XMLOutputFactory>> CLASS
public static final String IS_REPAIRING_NAMESPACES
Boolean
, default: FALSE
).
public static final String REPAIRING_PREFIX
String
, default: "ns"
).
public static final String INDENTATION
String
, default: null
).
public static final String LINE_SEPARATOR
String
, default: "\n"
).
public static final String AUTOMATIC_EMPTY_ELEMENTS
Boolean
, default: FALSE
).
public static final String NO_EMPTY_ELEMENT_TAG
Boolean
, default: FALSE
).
When set, this property forces the use of start/end element tag
(e.g. i.e. "<empty />" replaced by "<empty></empty>"),
This property takes precedence over AUTOMATIC_EMPTY_ELEMENTS
.
Constructor Detail |
---|
protected XMLOutputFactory()
Method Detail |
---|
public static XMLOutputFactory newInstance()
CLASS
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(Writer writer) throws XMLStreamException
writer
- the writer to write to.
XMLStreamException
public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream) throws XMLStreamException
stream
- the stream to write to.
XMLStreamException
public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding) throws XMLStreamException
stream
- the stream to write to.encoding
- the encoding to use.
XMLStreamException
public abstract void setProperty(String name, Object value) throws IllegalArgumentException
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
IllegalArgumentException
- if the property is not supported.public abstract boolean isPropertySupported(String name)
name
- the name of the property (may not be null).
true
if the property is supported;
false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |