Package org.basex.io.serial
Class OutputSerializer
java.lang.Object
org.basex.io.serial.Serializer
org.basex.io.serial.OutputSerializer
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
AdaptiveSerializer,StandardSerializer
This class serializes items to an output stream.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringEncoding.protected byte[]Item separator.protected final PrintOutputOutput stream.protected final SerializerOptionsSerializer options. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOutputSerializer(OutputStream os, SerializerOptions sopts) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the serializer.final booleanfinished()Tests if the serialization was interrupted.protected voidindent()Prints indentation whitespaces.protected abstract voidprintChar(int cp) Encodes and prints a character.protected final voidprintChars(byte[] text) Encodes and prints characters.protected final voidprintHex(int cp) Returns a hex entity for the specified codepoint.voidreset()Resets the serializer (indentation, etc).protected booleanseparate()Prints an item separator.Methods inherited from class org.basex.io.serial.Serializer
atomic, attribute, closeDoc, closeElement, comment, finishClose, finishEmpty, finishOpen, function, get, get, namespace, node, nsUri, openDoc, openElement, pi, sc, serialize, skipElement, startOpen, text, value
-
Field Details
-
out
Output stream. -
sopts
Serializer options. -
encoding
Encoding. -
itemsep
protected byte[] itemsepItem separator.
-
-
Constructor Details
-
OutputSerializer
Constructor.- Parameters:
os- output streamsopts- serializer options- Throws:
IOException- I/O exception
-
-
Method Details
-
reset
public void reset()Description copied from class:SerializerResets the serializer (indentation, etc).- Overrides:
resetin classSerializer
-
finished
public final boolean finished()Description copied from class:SerializerTests if the serialization was interrupted.- Overrides:
finishedin classSerializer- Returns:
- result of check
-
close
Description copied from class:SerializerCloses the serializer.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSerializer- Throws:
IOException- I/O exception
-
indent
Prints indentation whitespaces.- Throws:
IOException- I/O exception
-
separate
Prints an item separator.- Returns:
- boolean indicating if separator was printed
- Throws:
IOException- I/O exception
-
printChars
Encodes and prints characters.- Parameters:
text- characters to be printed- Throws:
IOException- I/O exception
-
printChar
Encodes and prints a character.- Parameters:
cp- codepoint to be printed- Throws:
IOException- I/O exception
-
printHex
Returns a hex entity for the specified codepoint.- Parameters:
cp- codepoint- Throws:
IOException- I/O exception
-