Encoder that wraps another Encoder and ensures
that the sequence of operations conforms to the provided schema.
Use EncoderFactory#validatingEncoder(Schema, Encoder) to construct
and configure.
ValidatingEncoder is not thread-safe.
Encoder, EncoderFactory
| Modifier and Type | Field and Description |
|---|---|
| protected Encoder | |
| protected final Parser |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public ValidatingEncoder | |
| public Symbol | doAction(Symbol
The input symbol from the caller of advance input, Symbol The symbol at the top the stack. top)Implements org. |
| public void | flush()
Implements java. |
| public void | setItemCount(long
The number of itemCount)
Call this method before writing a batch of items in an array or a map.
startItem() calls to follow. |
| public void | startItem()
Overrides org. |
| public void | writeArrayEnd()
Implements abstract org. |
| public void | writeArrayStart()
Implements abstract org. |
| public void | writeBoolean(boolean b)
Implements abstract org. |
| public void | writeBytes(ByteBuffer bytes)
Implements abstract org. |
| public void | writeBytes(byte[] bytes, int start, int len)
Implements abstract org. |
| public void | |
| public void | |
| public void | writeFixed(byte[]
The contents to write bytes, int The position within bytes where the contents start. start, int The number of bytes to write. len)Implements abstract org. |
| public void | |
| public void | writeIndex(int unionIndex)
Implements abstract org. |
| public void | |
| public void | |
| public void | writeMapEnd()
Implements abstract org. |
| public void | writeMapStart()
Implements abstract org. |
| public void | |
| public void | writeString(Utf8 utf8)
Implements abstract org. |
| public void | writeString(String str)
Overrides org. |
| public void | writeString(CharSequence charSequence)
Overrides org. |
| out | back to summary |
|---|---|
| protected Encoder out | |
| parser | back to summary |
|---|---|
| protected final Parser parser | |
| ValidatingEncoder | back to summary |
|---|---|
| pack-priv ValidatingEncoder(Symbol root, Encoder out) throws IOException | |
| ValidatingEncoder | back to summary |
|---|---|
| pack-priv ValidatingEncoder(Schema schema, Encoder in) throws IOException | |
| configure | back to summary |
|---|---|
| public ValidatingEncoder configure(Encoder encoder) Reconfigures this ValidatingEncoder to wrap the encoder provided.
| |
| doAction | back to summary |
|---|---|
| public Symbol doAction(Symbol input, Symbol top) throws IOException Implements org. Doc from org. Handle the action symbol top when the input is sought to be taken off the stack. | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements java. Doc from java. Flushes this stream by writing any buffered output to the underlying stream.
| |
| setItemCount | back to summary |
|---|---|
| public void setItemCount(long itemCount) throws IOException Overrides org. Doc from org. Call this method before writing a batch of items in an array or a map. Then
for each item, call
| |
| startItem | back to summary |
|---|---|
| public void startItem() throws IOException Overrides org. Doc from org. Start a new item of an array or map. See
| |
| writeArrayEnd | back to summary |
|---|---|
| public void writeArrayEnd() throws IOException Implements abstract org. Doc from org. Call this method to finish writing an array. See
| |
| writeArrayStart | back to summary |
|---|---|
| public void writeArrayStart() throws IOException Implements abstract org. Doc from org. Call this method to start writing an array.
When starting to serialize an array, call
out.writeArrayStart();
out.setItemCount(list.size());
for (Record r : list) {
out.startItem();
out.writeLong(r.longField);
out.writeBoolean(r.boolField);
}
out.writeArrayEnd();
| |
| writeBoolean | back to summary |
|---|---|
| public void writeBoolean(boolean b) throws IOException Implements abstract org. Doc from org. Write a boolean value.
| |
| writeBytes | back to summary |
|---|---|
| public void writeBytes(ByteBuffer bytes) throws IOException Implements abstract org. Doc from org. Write a byte string.
| |
| writeBytes | back to summary |
|---|---|
| public void writeBytes(byte[] bytes, int start, int len) throws IOException Implements abstract org. Doc from org. Write a byte string.
| |
| writeDouble | back to summary |
|---|---|
| public void writeDouble(double d) throws IOException Implements abstract org. Doc from org. Write a double.
| |
| writeEnum | back to summary |
|---|---|
| public void writeEnum(int e) throws IOException Implements abstract org. Doc from org. Writes an enumeration.
| |
| writeFixed | back to summary |
|---|---|
| public void writeFixed(byte[] bytes, int start, int len) throws IOException Implements abstract org. Doc from org. Writes a fixed size binary object.
| |
| writeFloat | back to summary |
|---|---|
| public void writeFloat(float f) throws IOException Implements abstract org. Doc from org. Write a float.
| |
| writeIndex | back to summary |
|---|---|
| public void writeIndex(int unionIndex) throws IOException Implements abstract org. Doc from org. Call this method to write the tag of a union. As an example of usage, let's say you want to write a union, whose second branch is a record consisting of an Long field and a Boolean field. Your code would look something like this: out.writeIndex(1); out.writeLong(record.longField); out.writeBoolean(record.boolField);
| |
| writeInt | back to summary |
|---|---|
| public void writeInt(int n) throws IOException Implements abstract org. Doc from org. Writes a 32-bit integer.
| |
| writeLong | back to summary |
|---|---|
| public void writeLong(long n) throws IOException Implements abstract org. Doc from org. Write a 64-bit integer.
| |
| writeMapEnd | back to summary |
|---|---|
| public void writeMapEnd() throws IOException Implements abstract org. Doc from org. Call this method to terminate the inner-most, currently-opened map. See
| |
| writeMapStart | back to summary |
|---|---|
| public void writeMapStart() throws IOException Implements abstract org. Doc from org. Call this to start a new map. See out.writeMapStart(); out.setItemCount(list.size()); for (Map.Entry
| |
| writeNull | back to summary |
|---|---|
| public void writeNull() throws IOException Implements abstract org. Doc from org. "Writes" a null value. (Doesn't actually write anything, but advances the state of the parser if this class is stateful.)
| |
| writeString | back to summary |
|---|---|
| public void writeString(Utf8 utf8) throws IOException Implements abstract org. Doc from org. Write a Unicode character string.
| |
| writeString | back to summary |
|---|---|
| public void writeString(String str) throws IOException Overrides org. Doc from org. Write a Unicode character string. The default implementation converts the
String to a
| |
| writeString | back to summary |
|---|---|
| public void writeString(CharSequence charSequence) throws IOException Overrides org. Doc from org. Write a Unicode character string. If the CharSequence is an
| |