Package org.basex.io.serial
Class StandardSerializer
java.lang.Object
org.basex.io.serial.Serializer
org.basex.io.serial.OutputSerializer
org.basex.io.serial.StandardSerializer
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CsvDirectSerializer,CsvXQuerySerializer,JsonSerializer,XMLSerializer
This class serializes items to an output stream.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanAtomic flag.protected final Normalizer.FormNormalization form.protected booleanInclude separator.Fields inherited from class org.basex.io.serial.OutputSerializer
encoding, itemsep, out, sopts -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStandardSerializer(OutputStream os, SerializerOptions sopts) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSerializes an atomic value.protected final booleancharacterMap(int cp) Replaces a character with an entry from the character map.protected voidSerializes a function item.protected voidSerializes the specified node.protected final byte[]norm(byte[] text) Normalizes the specified text.protected voidprint(int cp) Prints a single character.protected final voidprintChar(int cp) Encodes and prints a character.voidreset()Resets the serializer (indentation, etc).voidSerializes the specified item, which may be a node or an atomic value.Methods inherited from class org.basex.io.serial.OutputSerializer
close, finished, indent, printChars, printHex, separateMethods inherited from class org.basex.io.serial.Serializer
attribute, closeDoc, closeElement, comment, finishClose, finishEmpty, finishOpen, get, get, namespace, nsUri, openDoc, openElement, pi, sc, skipElement, startOpen, text, value
-
Field Details
-
form
Normalization form. -
sep
protected boolean sepInclude separator. -
atomic
protected boolean atomicAtomic flag.
-
-
Constructor Details
-
StandardSerializer
Constructor.- Parameters:
os- output streamsopts- serialization parameters- Throws:
IOException- I/O exception
-
-
Method Details
-
serialize
Description copied from class:SerializerSerializes the specified item, which may be a node or an atomic value.- Overrides:
serializein classSerializer- Parameters:
item- item to be serialized- Throws:
IOException- I/O exception
-
reset
public void reset()Description copied from class:SerializerResets the serializer (indentation, etc).- Overrides:
resetin classOutputSerializer
-
node
Description copied from class:SerializerSerializes the specified node.- Overrides:
nodein classSerializer- Parameters:
node- node to be serialized- Throws:
IOException- I/O exception
-
function
Description copied from class:SerializerSerializes a function item.- Overrides:
functionin classSerializer- Parameters:
item- item- Throws:
IOException- I/O exception
-
atomic
Description copied from class:SerializerSerializes an atomic value.- Overrides:
atomicin classSerializer- Parameters:
item- item- Throws:
IOException- I/O exception
-
printChar
Description copied from class:OutputSerializerEncodes and prints a character.- Specified by:
printCharin classOutputSerializer- Parameters:
cp- codepoint to be printed- Throws:
IOException- I/O exception
-
print
Prints a single character.- Parameters:
cp- codepoint- Throws:
IOException- I/O exception
-
norm
protected final byte[] norm(byte[] text) Normalizes the specified text.- Parameters:
text- text to be normalized- Returns:
- normalized text
-
characterMap
Replaces a character with an entry from the character map.- Parameters:
cp- codepoint- Returns:
trueif replacement was found- Throws:
IOException- I/O exception
-