public abstract class Serializer
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
level
Current level.
|
static SerializerProp |
PROPS
Default serialization parameters.
|
protected byte[] |
tag
Current tag.
|
protected TokenList |
tags
Stack of opened tags.
|
protected boolean |
undecl
Declare namespaces flag.
|
| Constructor and Description |
|---|
Serializer() |
| Modifier and Type | Method and Description |
|---|---|
void |
atomic(Item item)
Serializes an atomic value.
|
abstract void |
attribute(byte[] name,
byte[] value)
Serializes an attribute.
|
void |
close()
Closes the serializer.
|
void |
closeElement()
Closes an element.
|
void |
closeResult()
Closes a result.
|
void |
comment(byte[] value)
Serializes a comment.
|
void |
emptyElement(byte[] name,
byte[]... atts)
Opens and closes an empty element.
|
void |
emptyElement(ExprInfo expr,
byte[]... atts)
Opens and closes an empty element, adopting the expression name as
element name.
|
protected abstract void |
finishAtomic(Item i)
Serializes an item.
|
protected abstract void |
finishClose()
Closes an element.
|
protected abstract void |
finishComment(byte[] v)
Serializes a comment.
|
boolean |
finished()
Tests if the serialization was interrupted.
|
protected abstract void |
finishEmpty()
Closes an empty element.
|
protected abstract void |
finishOpen()
Finishes an opening element node.
|
protected abstract void |
finishPi(byte[] n,
byte[] v)
Serializes a processing instruction.
|
protected abstract void |
finishText(byte[] v)
Serializes a text.
|
static XMLSerializer |
get(java.io.OutputStream os)
Returns an XML serializer.
|
static Serializer |
get(java.io.OutputStream os,
SerializerProp props)
Returns a specific serializer.
|
void |
namespace(byte[] pref,
byte[] uri)
Serializes a namespace if it has not been serialized by an ancestor yet.
|
void |
node(Data data,
int pre)
Serializes a node of the specified data reference.
|
void |
node(Data data,
int pre,
FTPosData ft)
Serializes a node of the specified data reference.
|
void |
openElement(byte[] name,
byte[]... atts)
Opens an element.
|
void |
openElement(ExprInfo expr,
byte[]... atts)
Opens an element, adopting the expression name as element name.
|
void |
openResult()
Starts a result.
|
void |
pi(byte[] name,
byte[] value)
Serializes a processing instruction.
|
void |
reset()
Resets the serializer (indentation, etc).
|
protected abstract void |
startOpen(byte[] n)
Starts an element.
|
void |
text(byte[] value)
Serializes a text.
|
public static final SerializerProp PROPS
protected final TokenList tags
protected int level
protected byte[] tag
protected boolean undecl
public static XMLSerializer get(java.io.OutputStream os) throws java.io.IOException
os - output stream referencejava.io.IOException - I/O exceptionpublic static Serializer get(java.io.OutputStream os, SerializerProp props) throws java.io.IOException
os - output stream referenceprops - serialization properties (can be null)java.io.IOException - I/O exceptionpublic final void openElement(byte[] name,
byte[]... atts)
throws java.io.IOException
name - tag nameatts - attributesjava.io.IOException - I/O exceptionpublic final void closeElement()
throws java.io.IOException
java.io.IOException - I/O exceptionpublic final void emptyElement(byte[] name,
byte[]... atts)
throws java.io.IOException
name - tag nameatts - attributesjava.io.IOException - I/O exceptionpublic final void text(byte[] value)
throws java.io.IOException
value - text bytesjava.io.IOException - I/O exceptionpublic final void comment(byte[] value)
throws java.io.IOException
value - valuejava.io.IOException - I/O exceptionpublic final void pi(byte[] name,
byte[] value)
throws java.io.IOException
name - namevalue - valuejava.io.IOException - I/O exceptionpublic final void atomic(Item item) throws java.io.IOException
Item.serialize(org.basex.io.serial.Serializer) to serialize nodes.item - text bytesjava.io.IOException - I/O exceptionpublic final void node(Data data, int pre) throws java.io.IOException
data - data referencepre - pre value to start fromjava.io.IOException - I/O exceptionpublic final void node(Data data, int pre, FTPosData ft) throws java.io.IOException
data - data referencepre - pre value to start fromft - full-text datajava.io.IOException - I/O exceptionpublic final void openElement(ExprInfo expr, byte[]... atts) throws java.io.IOException
expr - expression infoatts - attributesjava.io.IOException - I/O exceptionpublic final void emptyElement(ExprInfo expr, byte[]... atts) throws java.io.IOException
expr - expression infoatts - attributesjava.io.IOException - I/O exceptionpublic void openResult()
throws java.io.IOException
java.io.IOException - I/O exceptionpublic void closeResult()
throws java.io.IOException
java.io.IOException - I/O exceptionpublic void close()
throws java.io.IOException
java.io.IOException - I/O exceptionpublic void namespace(byte[] pref,
byte[] uri)
throws java.io.IOException
pref - prefixuri - URIjava.io.IOException - I/O exceptionpublic boolean finished()
public void reset()
public abstract void attribute(byte[] name,
byte[] value)
throws java.io.IOException
name - namevalue - valuejava.io.IOException - I/O exceptionprotected abstract void startOpen(byte[] n)
throws java.io.IOException
n - tag namejava.io.IOException - I/O exceptionprotected abstract void finishOpen()
throws java.io.IOException
java.io.IOException - I/O exceptionprotected abstract void finishEmpty()
throws java.io.IOException
java.io.IOException - I/O exceptionprotected abstract void finishClose()
throws java.io.IOException
java.io.IOException - I/O exceptionprotected abstract void finishText(byte[] v)
throws java.io.IOException
v - valuejava.io.IOException - I/O exceptionprotected abstract void finishComment(byte[] v)
throws java.io.IOException
v - valuejava.io.IOException - I/O exceptionprotected abstract void finishPi(byte[] n,
byte[] v)
throws java.io.IOException
n - namev - valuejava.io.IOException - I/O exceptionprotected abstract void finishAtomic(Item i) throws java.io.IOException
i - itemjava.io.IOException - I/O exception