public abstract class Serializer extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
protected byte[] |
elem
Current element name.
|
protected TokenList |
elems
Stack with names of opened elements.
|
protected boolean |
indent
Indentation flag.
|
protected int |
level
Current level.
|
protected boolean |
more
Indicates if more than one item was serialized.
|
Constructor and Description |
---|
Serializer() |
Modifier and Type | Method and Description |
---|---|
protected void |
atomic(Item item)
Serializes an atomic value.
|
protected void |
attribute(byte[] name,
byte[] value,
boolean standalone)
Serializes an attribute.
|
void |
close()
Closes the serializer.
|
protected void |
closeDoc()
Closes a document.
|
protected void |
closeElement()
Closes an element.
|
protected void |
comment(byte[] value)
Serializes a comment.
|
protected void |
finishClose()
Closes an element.
|
boolean |
finished()
Tests if the serialization was interrupted.
|
protected void |
finishEmpty()
Closes an empty element.
|
protected void |
finishOpen()
Finishes an opening element node.
|
protected void |
function(FItem item)
Serializes a function item.
|
static Serializer |
get(OutputStream os)
Returns an adaptive serializer.
|
static Serializer |
get(OutputStream os,
SerializerOptions sopts)
Returns a specific serializer.
|
protected boolean |
ignore(ANode node)
Checks if an element should be ignored.
|
protected void |
namespace(byte[] prefix,
byte[] uri,
boolean standalone)
Serializes a namespace.
|
protected void |
node(ANode node)
Serializes the specified node.
|
protected byte[] |
nsUri(byte[] prefix)
Gets the namespace URI currently bound by the given prefix.
|
protected void |
openDoc(byte[] name)
Opens a document.
|
protected void |
openElement(byte[] name)
Opens an element.
|
protected void |
pi(byte[] name,
byte[] value)
Serializes a processing instruction.
|
void |
reset()
Resets the serializer (indentation, etc).
|
void |
serialize(Item item)
Serializes the specified item, which may be a node or an atomic value.
|
protected void |
startOpen(byte[] name)
Starts an element.
|
protected void |
text(byte[] value,
FTPos ftp)
Serializes a text.
|
protected final TokenList elems
protected int level
protected byte[] elem
protected boolean indent
protected boolean more
public static Serializer get(OutputStream os) throws IOException
os
- output stream referenceIOException
- I/O exceptionpublic static Serializer get(OutputStream os, SerializerOptions sopts) throws IOException
os
- output stream referencesopts
- serialization parameters (may be null
)IOException
- I/O exceptionpublic void serialize(Item item) throws IOException
item
- item to be serializedIOException
- I/O exceptionpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- I/O exceptionpublic boolean finished()
public void reset()
protected void node(ANode node) throws IOException
node
- node to be serializedIOException
- I/O exceptionprotected final void openElement(byte[] name) throws IOException
name
- element nameIOException
- I/O exceptionprotected final void closeElement() throws IOException
IOException
- I/O exceptionprotected void openDoc(byte[] name) throws IOException
name
- nameIOException
- I/O exceptionprotected void closeDoc() throws IOException
IOException
- I/O exceptionprotected void namespace(byte[] prefix, byte[] uri, boolean standalone) throws IOException
prefix
- prefixuri
- uristandalone
- standalone flagIOException
- I/O exceptionprotected final byte[] nsUri(byte[] prefix)
prefix
- namespace prefixnull
otherwiseprotected boolean ignore(ANode node)
node
- node to be serializedprotected void attribute(byte[] name, byte[] value, boolean standalone) throws IOException
name
- namevalue
- valuestandalone
- standalone flagIOException
- I/O exceptionprotected void startOpen(byte[] name) throws IOException
name
- element nameIOException
- I/O exceptionprotected void finishOpen() throws IOException
IOException
- I/O exceptionprotected void finishEmpty() throws IOException
IOException
- I/O exceptionprotected void finishClose() throws IOException
IOException
- I/O exceptionprotected void text(byte[] value, FTPos ftp) throws IOException
value
- valueftp
- full-text positions, used for visualization highlightingIOException
- I/O exceptionprotected void comment(byte[] value) throws IOException
value
- valueIOException
- I/O exceptionprotected void pi(byte[] name, byte[] value) throws IOException
name
- namevalue
- valueIOException
- I/O exceptionprotected void atomic(Item item) throws IOException
item
- itemIOException
- I/O exceptionprotected void function(FItem item) throws IOException
item
- itemIOException
- I/O exceptionCopyright © 2005–2015 BaseX Team. All rights reserved.