Package org.basex.io.serial
Class XMLSerializer
- java.lang.Object
-
- org.basex.io.serial.Serializer
-
- org.basex.io.serial.OutputSerializer
-
- org.basex.io.serial.StandardSerializer
-
- org.basex.io.serial.XMLSerializer
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class XMLSerializer extends StandardSerializer
This class serializes items as XML.- Author:
- BaseX Team 2005-24, BSD License, Christian Gruen
-
-
Field Summary
Fields Modifier and Type Field Description protected long
indAttrLength
Attribute indentation length.-
Fields inherited from class org.basex.io.serial.StandardSerializer
atomic, form, map, sep
-
Fields inherited from class org.basex.io.serial.OutputSerializer
encoding, itemsep, out, sopts
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
atomic(Item item)
Serializes an atomic value.protected void
attribute(byte[] name, byte[] value, boolean standalone)
Serializes an attribute.protected void
comment(byte[] value)
Serializes a comment.protected void
delimitAttribute()
Print the delimiter preceding an attribute inside of an opening or empty tag.protected void
doctype(byte[] type)
Prints the document type declaration.protected void
finishClose()
Closes an element.protected void
finishEmpty()
Closes an empty element.protected void
finishOpen()
Finishes an opening element node.protected void
indent()
Prints indentation whitespace.protected void
namespace(byte[] prefix, byte[] uri, boolean standalone)
Serializes a namespace.protected void
openDoc(byte[] name)
Opens a document.protected void
pi(byte[] name, byte[] value)
Serializes a processing instruction.protected void
print(int cp)
Prints a single character.protected boolean
printCT(boolean empty, boolean html)
Prints the content type declaration.protected void
printDoctype(byte[] type, String pub, String sys)
Prints the document type declaration.void
serialize(Item item)
Serializes the specified item, which may be a node or an atomic value.protected boolean
skipElement(ANode node)
Checks if an element should be skipped.protected void
startOpen(QNm name)
Starts an element.protected void
text(byte[] value, FTPos ftp)
Serializes a text.-
Methods inherited from class org.basex.io.serial.StandardSerializer
characterMap, function, node, printChar, reset
-
Methods inherited from class org.basex.io.serial.OutputSerializer
close, finished, printChars, printHex, separate
-
Methods inherited from class org.basex.io.serial.Serializer
closeDoc, closeElement, get, get, nsUri, openElement, sc, value
-
-
-
-
Method Detail
-
doctype
protected void doctype(byte[] type) throws IOException
Prints the document type declaration.- Parameters:
type
- document type- Throws:
IOException
- I/O exception
-
serialize
public void serialize(Item item) throws IOException
Description copied from class:Serializer
Serializes the specified item, which may be a node or an atomic value.- Overrides:
serialize
in classStandardSerializer
- Parameters:
item
- item to be serialized- Throws:
IOException
- I/O exception
-
namespace
protected void namespace(byte[] prefix, byte[] uri, boolean standalone) throws IOException
Description copied from class:Serializer
Serializes a namespace.- Overrides:
namespace
in classSerializer
- Parameters:
prefix
- prefixuri
- namespace URIstandalone
- standalone flag- Throws:
IOException
- I/O exception
-
attribute
protected void attribute(byte[] name, byte[] value, boolean standalone) throws IOException
Description copied from class:Serializer
Serializes an attribute.- Overrides:
attribute
in classSerializer
- Parameters:
name
- namevalue
- valuestandalone
- standalone flag- Throws:
IOException
- I/O exception
-
delimitAttribute
protected void delimitAttribute() throws IOException
Print the delimiter preceding an attribute inside of an opening or empty tag. This is attribute indentation, if enabled, for all but the first attribute, but at least a single space.- Throws:
IOException
- I/O exception
-
text
protected void text(byte[] value, FTPos ftp) throws IOException
Description copied from class:Serializer
Serializes a text.- Overrides:
text
in classSerializer
- Parameters:
value
- valueftp
- full-text positions, used for visualization highlighting- Throws:
IOException
- I/O exception
-
comment
protected void comment(byte[] value) throws IOException
Description copied from class:Serializer
Serializes a comment.- Overrides:
comment
in classSerializer
- Parameters:
value
- value- Throws:
IOException
- I/O exception
-
pi
protected void pi(byte[] name, byte[] value) throws IOException
Description copied from class:Serializer
Serializes a processing instruction.- Overrides:
pi
in classSerializer
- Parameters:
name
- namevalue
- value- Throws:
IOException
- I/O exception
-
openDoc
protected void openDoc(byte[] name)
Description copied from class:Serializer
Opens a document.- Overrides:
openDoc
in classSerializer
- Parameters:
name
- name
-
startOpen
protected void startOpen(QNm name) throws IOException
Description copied from class:Serializer
Starts an element.- Overrides:
startOpen
in classSerializer
- Parameters:
name
- element name- Throws:
IOException
- I/O exception
-
finishOpen
protected void finishOpen() throws IOException
Description copied from class:Serializer
Finishes an opening element node.- Overrides:
finishOpen
in classSerializer
- Throws:
IOException
- I/O exception
-
finishEmpty
protected void finishEmpty() throws IOException
Description copied from class:Serializer
Closes an empty element.- Overrides:
finishEmpty
in classSerializer
- Throws:
IOException
- I/O exception
-
finishClose
protected void finishClose() throws IOException
Description copied from class:Serializer
Closes an element.- Overrides:
finishClose
in classSerializer
- Throws:
IOException
- I/O exception
-
atomic
protected void atomic(Item item) throws IOException
Description copied from class:Serializer
Serializes an atomic value.- Overrides:
atomic
in classStandardSerializer
- Parameters:
item
- item- Throws:
IOException
- I/O exception
-
print
protected void print(int cp) throws IOException
Description copied from class:StandardSerializer
Prints a single character.- Overrides:
print
in classStandardSerializer
- Parameters:
cp
- codepoint- Throws:
IOException
- I/O exception
-
skipElement
protected boolean skipElement(ANode node)
Description copied from class:Serializer
Checks if an element should be skipped.- Overrides:
skipElement
in classSerializer
- Parameters:
node
- node to be serialized- Returns:
- result of check
-
printDoctype
protected final void printDoctype(byte[] type, String pub, String sys) throws IOException
Prints the document type declaration.- Parameters:
type
- document typepub
- doctype-public parametersys
- doctype-system parameter- Throws:
IOException
- I/O exception
-
indent
protected void indent() throws IOException
Description copied from class:OutputSerializer
Prints indentation whitespace.- Overrides:
indent
in classOutputSerializer
- Throws:
IOException
- I/O exception
-
printCT
protected final boolean printCT(boolean empty, boolean html) throws IOException
Prints the content type declaration.- Parameters:
empty
- empty flaghtml
- method- Returns:
true
if declaration was printed- Throws:
IOException
- I/O exception
-
-