Encoder for Avro's JSON data encoding.
Construct using EncoderFactory.
JsonEncoder buffers output, and data may not appear on the output until
Encoder#flush() is called.
JsonEncoder is not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| protected BitSet | isEmpty
Has anything been written into the collections? |
| private static final String | |
| private JsonGenerator | |
| pack-priv final Parser |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public JsonEncoder | Returns: this JsonEncoderThe OutputStream to direct output to. Cannot be null. out)Reconfigures this JsonEncoder to use the output stream provided. |
| private JsonEncoder | Returns: this JsonEncoderThe JsonGenerator to direct output to. Cannot be null. generator)Reconfigures this JsonEncoder to output to the JsonGenerator provided. |
| 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. |
| private static JsonGenerator | |
| public boolean | |
| public void | |
| 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. |
| private void | |
| 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. |
| includeNamespace | back to summary |
|---|---|
| private boolean includeNamespace | |
| isEmpty | back to summary |
|---|---|
| protected BitSet isEmpty Has anything been written into the collections? | |
| LINE_SEPARATOR | back to summary |
|---|---|
| private static final String LINE_SEPARATOR | |
| out | back to summary |
|---|---|
| private JsonGenerator out | |
| parser | back to summary |
|---|---|
| pack-priv final Parser parser | |
| JsonEncoder | back to summary |
|---|---|
| pack-priv JsonEncoder(Schema sc, OutputStream out) throws IOException | |
| JsonEncoder | back to summary |
|---|---|
| pack-priv JsonEncoder(Schema sc, OutputStream out, boolean pretty) throws IOException | |
| JsonEncoder | back to summary |
|---|---|
| pack-priv JsonEncoder(Schema sc, JsonGenerator out) throws IOException | |
| configure | back to summary |
|---|---|
| public JsonEncoder configure(OutputStream out) throws IOException Reconfigures this JsonEncoder to use the output stream provided. If the OutputStream provided is null, a NullPointerException is thrown. Otherwise, this JsonEncoder will flush its current output and then reconfigure its output to use a default UTF8 JsonGenerator that writes to the provided OutputStream.
| |
| configure | back to summary |
|---|---|
| private JsonEncoder configure(JsonGenerator generator) throws IOException Reconfigures this JsonEncoder to output to the JsonGenerator provided. If the JsonGenerator provided is null, a NullPointerException is thrown. Otherwise, this JsonEncoder will flush its current output and then reconfigure its output to use the provided JsonGenerator.
| |
| 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.
| |
| getJsonGenerator | back to summary |
|---|---|
| private static JsonGenerator getJsonGenerator(OutputStream out, boolean pretty) throws IOException | |
| isIncludeNamespace | back to summary |
|---|---|
| public boolean isIncludeNamespace() | |
| setIncludeNamespace | back to summary |
|---|---|
| public void setIncludeNamespace(final boolean includeNamespace) | |
| 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.
| |
| writeByteArray | back to summary |
|---|---|
| private void writeByteArray(byte[] bytes, int start, int len) throws IOException | |
| 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
| |