This class has two types of methods. One type of methods support the writing
of leaf values (for example, writeLong and writeString).
These methods have analogs in Decoder.
The other type of methods support the writing of maps and arrays. These
methods are writeArrayStart, startItem, and
writeArrayEnd (and similar methods for maps). Some implementations
of Encoder handle the buffering required to break large maps and
arrays into blocks, which is necessary for applications that want to do
streaming. (See writeArrayStart for details on these methods.)
EncoderFactory contains Encoder construction and configuration
facilities.
EncoderFactory, Decoder
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | setItemCount(long
The number of itemCount)startItem() calls to follow.Call this method before writing a batch of items in an array or a map. |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public void | |
| public abstract void | |
| public abstract void | |
| public abstract 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)Writes a fixed size binary object. |
| public void | |
| public void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public void | |
| public void |
| Encoder | back to summary |
|---|---|
| public Encoder() | |
| setItemCount | back to summary |
|---|---|
| public abstract void setItemCount(long itemCount) throws IOException 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 abstract void startItem() throws IOException Start a new item of an array or map. See
| |
| writeArrayEnd | back to summary |
|---|---|
| public abstract void writeArrayEnd() throws IOException Call this method to finish writing an array. See
| |
| writeArrayStart | back to summary |
|---|---|
| public abstract void writeArrayStart() throws IOException 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 abstract void writeBoolean(boolean b) throws IOException Write a boolean value.
| |
| writeBytes | back to summary |
|---|---|
| public abstract void writeBytes(ByteBuffer bytes) throws IOException Write a byte string.
| |
| writeBytes | back to summary |
|---|---|
| public abstract void writeBytes(byte[] bytes, int start, int len) throws IOException Write a byte string.
| |
| writeBytes | back to summary |
|---|---|
| public void writeBytes(byte[] bytes) throws IOException Writes a byte string. Equivalent to writeBytes(bytes, 0, bytes.length)
| |
| writeDouble | back to summary |
|---|---|
| public abstract void writeDouble(double d) throws IOException Write a double.
| |
| writeEnum | back to summary |
|---|---|
| public abstract void writeEnum(int e) throws IOException Writes an enumeration.
| |
| writeFixed | back to summary |
|---|---|
| public abstract void writeFixed(byte[] bytes, int start, int len) throws IOException Writes a fixed size binary object.
| |
| writeFixed | back to summary |
|---|---|
| public void writeFixed(byte[] bytes) throws IOException A shorthand for writeFixed(bytes, 0, bytes.length) | |
| writeFixed | back to summary |
|---|---|
| public void writeFixed(ByteBuffer bytes) throws IOException Writes a fixed from a ByteBuffer. | |
| writeFloat | back to summary |
|---|---|
| public abstract void writeFloat(float f) throws IOException Write a float.
| |
| writeIndex | back to summary |
|---|---|
| public abstract void writeIndex(int unionIndex) throws IOException 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 abstract void writeInt(int n) throws IOException Writes a 32-bit integer.
| |
| writeLong | back to summary |
|---|---|
| public abstract void writeLong(long n) throws IOException Write a 64-bit integer.
| |
| writeMapEnd | back to summary |
|---|---|
| public abstract void writeMapEnd() throws IOException Call this method to terminate the inner-most, currently-opened map. See
| |
| writeMapStart | back to summary |
|---|---|
| public abstract void writeMapStart() throws IOException Call this to start a new map. See out.writeMapStart(); out.setItemCount(list.size()); for (Map.Entry
| |
| writeNull | back to summary |
|---|---|
| public abstract void writeNull() throws IOException "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 abstract void writeString(Utf8 utf8) throws IOException Write a Unicode character string.
| |
| writeString | back to summary |
|---|---|
| public void writeString(String str) throws IOException Write a Unicode character string. The default implementation converts the
String to a
| |
| writeString | back to summary |
|---|---|
| public void writeString(CharSequence charSequence) throws IOException Write a Unicode character string. If the CharSequence is an
| |