Constructor and Description |
---|
DecoderFactory()
Constructor for factory instances
|
Modifier and Type | Method and Description |
---|---|
BinaryDecoder |
binaryDecoder(byte[] bytes,
BinaryDecoder reuse)
This method is shorthand for
|
BinaryDecoder |
binaryDecoder(byte[] bytes,
int offset,
int length,
BinaryDecoder reuse)
Creates or reinitializes a
BinaryDecoder with the byte array provided
as the source of data. |
BinaryDecoder |
binaryDecoder(InputStream in,
BinaryDecoder reuse)
Creates or reinitializes a
BinaryDecoder with the input stream
provided as the source of data. |
DecoderFactory |
configureDecoderBufferSize(int size)
Configures this factory to use the specified buffer size when creating
Decoder instances that buffer their input.
|
BinaryDecoder |
createBinaryDecoder(byte[] bytes,
BinaryDecoder reuse)
Deprecated.
use
binaryDecoder(byte[], BinaryDecoder) instead |
BinaryDecoder |
createBinaryDecoder(byte[] bytes,
int offset,
int length,
BinaryDecoder reuse)
Deprecated.
use
binaryDecoder(byte[], int, int, BinaryDecoder)
instead |
BinaryDecoder |
createBinaryDecoder(InputStream in,
BinaryDecoder reuse)
Deprecated.
use the equivalent
binaryDecoder(InputStream, BinaryDecoder) instead |
static DecoderFactory |
defaultFactory()
Deprecated.
use the equivalent
get() instead |
BinaryDecoder |
directBinaryDecoder(InputStream in,
BinaryDecoder reuse)
Creates or reinitializes a
BinaryDecoder with the input stream
provided as the source of data. |
static DecoderFactory |
get()
Returns an immutable static DecoderFactory configured with default settings
All mutating methods throw IllegalArgumentExceptions.
|
int |
getConfiguredBufferSize()
Returns this factory's configured preferred buffer size.
|
JsonDecoder |
jsonDecoder(Schema schema,
InputStream input)
Creates a
JsonDecoder using the InputStream provided for reading data
that conforms to the Schema provided. |
JsonDecoder |
jsonDecoder(Schema schema,
String input)
Creates a
JsonDecoder using the String provided for reading data that
conforms to the Schema provided. |
ResolvingDecoder |
resolvingDecoder(Schema writer,
Schema reader,
Decoder wrapped)
Creates a
ResolvingDecoder wrapping the Decoder provided. |
ValidatingDecoder |
validatingDecoder(Schema schema,
Decoder wrapped)
Creates a
ValidatingDecoder wrapping the Decoder provided. |
@Deprecated public static DecoderFactory defaultFactory()
get()
insteadpublic static DecoderFactory get()
public DecoderFactory configureDecoderBufferSize(int size)
size
- The preferred buffer size. Valid values are in the range [32,
16*1024*1024]. Values outside this range are rounded to the
nearest value in the range. Values less than 512 or greater than
1024*1024 are not recommended.DecoderFactory myFactory = new DecoderFactory().useBinaryDecoderBufferSize(4096);
public int getConfiguredBufferSize()
configureDecoderBufferSize(int)
@Deprecated public BinaryDecoder createBinaryDecoder(InputStream in, BinaryDecoder reuse)
binaryDecoder(InputStream, BinaryDecoder)
insteadpublic BinaryDecoder binaryDecoder(InputStream in, BinaryDecoder reuse)
BinaryDecoder
with the input stream
provided as the source of data. If reuse is provided, it will be
reinitialized to the given input stream.
BinaryDecoder
instances returned by this method buffer their input,
reading up to getConfiguredBufferSize()
bytes past the minimum
required to satisfy read requests in order to achieve better performance. If
the buffering is not desired, use
directBinaryDecoder(InputStream, BinaryDecoder)
.
BinaryDecoder.inputStream()
provides a view on the data that is
buffer-aware, for users that need to interleave access to data with the
Decoder API.in
- The InputStream to initialize toreuse
- The BinaryDecoder to attempt to reuse given the factory
configuration. A BinaryDecoder implementation may not be
compatible with reuse, causing a new instance to be returned. If
null, a new instance is returned.BinaryDecoder
,
Decoder
public BinaryDecoder directBinaryDecoder(InputStream in, BinaryDecoder reuse)
BinaryDecoder
with the input stream
provided as the source of data. If reuse is provided, it will be
reinitialized to the given input stream.
BinaryDecoder
instances returned by this method do not buffer their
input. In most cases a buffering BinaryDecoder is sufficient in combination
with BinaryDecoder.inputStream()
which provides a buffer-aware view
on the data.
A "direct" BinaryDecoder does not read ahead from an InputStream or other
data source that cannot be rewound. From the perspective of a client, a
"direct" decoder must never read beyond the minimum necessary bytes to
service a BinaryDecoder
API read request.
In the case that the improved performance of a buffering implementation does
not outweigh the inconvenience of its buffering semantics, a "direct" decoder
can be used.in
- The InputStream to initialize toreuse
- The BinaryDecoder to attempt to reuse given the factory
configuration. A BinaryDecoder implementation may not be
compatible with reuse, causing a new instance to be returned. If
null, a new instance is returned.DirectBinaryDecoder
,
Decoder
@Deprecated public BinaryDecoder createBinaryDecoder(byte[] bytes, int offset, int length, BinaryDecoder reuse)
binaryDecoder(byte[], int, int, BinaryDecoder)
insteadpublic BinaryDecoder binaryDecoder(byte[] bytes, int offset, int length, BinaryDecoder reuse)
BinaryDecoder
with the byte array provided
as the source of data. If reuse is provided, it will attempt to
reinitialize reuse to the new byte array. This instance will use the
provided byte array as its buffer.
BinaryDecoder.inputStream()
provides a view on the data that is
buffer-aware and can provide a view of the data not yet read by Decoder API
methods.bytes
- The byte array to initialize tooffset
- The offset to start reading fromlength
- The maximum number of bytes to read from the byte arrayreuse
- The BinaryDecoder to attempt to reinitialize. if null a new
BinaryDecoder is created.@Deprecated public BinaryDecoder createBinaryDecoder(byte[] bytes, BinaryDecoder reuse)
binaryDecoder(byte[], BinaryDecoder)
insteadpublic BinaryDecoder binaryDecoder(byte[] bytes, BinaryDecoder reuse)
createBinaryDecoder(bytes, 0, bytes.length, reuse);
binaryDecoder(byte[], int, int, BinaryDecoder)
public JsonDecoder jsonDecoder(Schema schema, InputStream input) throws IOException
JsonDecoder
using the InputStream provided for reading data
that conforms to the Schema provided.
schema
- The Schema for data read from this JsonEncoder. Cannot be null.input
- The InputStream to read from. Cannot be null.IOException
public JsonDecoder jsonDecoder(Schema schema, String input) throws IOException
JsonDecoder
using the String provided for reading data that
conforms to the Schema provided.
schema
- The Schema for data read from this JsonEncoder. Cannot be null.input
- The String to read from. Cannot be null.IOException
public ValidatingDecoder validatingDecoder(Schema schema, Decoder wrapped) throws IOException
ValidatingDecoder
wrapping the Decoder provided. This
ValidatingDecoder will ensure that operations against it conform to the
schema provided.schema
- The Schema to validate against. Cannot be null.wrapped
- The Decoder to wrap.IOException
public ResolvingDecoder resolvingDecoder(Schema writer, Schema reader, Decoder wrapped) throws IOException
ResolvingDecoder
wrapping the Decoder provided. This
ResolvingDecoder will resolve input conforming to the writer schema
from the wrapped Decoder, and present it as the reader schema.writer
- The Schema that the source data is in. Cannot be null.reader
- The Schema that the reader wishes to read the data as. Cannot
be null.wrapped
- The Decoder to wrap.IOException
Copyright © 2009–2021 The Apache Software Foundation. All rights reserved.