JsonParser
implementation for decoding Avro content and
exposing at as a stream of JsonToken
s, to be used
for data binding.
Modifier and Type | Class and Description |
---|---|
public static enum | AvroParser.
Enumeration that defines all togglable features for Avro parsers. |
Modifier and Type | Field and Description |
---|---|
protected AvroReadContext | |
protected int | |
protected ObjectCodec | _objectCodec
Codec used for data binding when (if) requested. |
protected AvroSchema | |
protected static final JacksonFeatureSet |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
protected abstract void | |
protected void | |
protected abstract void | |
public boolean | canReadTypeId()
Overrides com. Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't). |
public boolean | canUseSchema(FormatSchema
Schema to check schema)Overrides com. Method that can be used to verify that given schema can be used with
this parser (using |
public JsonParser | configure(AvroParser.
Method for enabling or disabling specified Avro feature
(check |
public JsonLocation | currentLocation()
Overrides com. Method that returns location of the last processed input unit (character or byte) from the input; usually for error reporting purposes. |
public String | currentName()
Overrides com. Method that can be called to get the name associated with
the current token: for |
public JsonLocation | currentTokenLocation()
Overrides com. Method that return the starting location of the current (most recently returned) token; that is, the position of the first input unit (character or byte) from input that starts the current token. |
public JsonParser | disable(AvroParser.
Method for disabling specified Avro feature
(check |
public JsonParser | enable(AvroParser.
Method for enabling specified Avro feature
(check |
public byte[] | getBinaryValue(Base64Variant
Expected variant of base64 encoded
content (see variant)Base64Variants for definitions
of "standard" variants).Overrides com. Method that can be used to read (and consume -- results may not be accessible using other methods after the call) base64-encoded binary data included in the current textual JSON value. |
public ObjectCodec | getCodec()
Implements abstract com. Accessor for |
public JsonLocation | getCurrentLocation()
Overrides com.
Deprecated
Method that returns location of the last processed character; usually for error reporting purposes |
public String | getCurrentName()
Overrides com.
Deprecated
Method that can be called to get the name associated with the current event. |
public Object | getEmbeddedObject()
Overrides com. Accessor that can be called if (and only if) the current token
is |
public abstract Object | getInputSource()
Overrides com. Method that can be used to get access to object that is used
to access input being parsed; this is usually either
|
public JacksonFeatureSet | getReadCapabilities()
Overrides com. Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly). |
public AvroSchema | getSchema()
Overrides com. Method for accessing Schema that this parser uses, if any. |
public abstract String | getText()
Implements abstract com. Method for accessing textual representation of the current token;
if no current token (before first call to |
public abstract int | getText(Writer
Writer to write textual content to writer)Overrides com. Method to read the textual representation of the current token in chunks and pass it to the given Writer. |
public char[] | getTextCharacters()
Implements abstract com. Method similar to |
public int | getTextLength()
Implements abstract com. Accessor used with |
public int | getTextOffset()
Implements abstract com. Accessor used with |
public JsonLocation | getTokenLocation()
Overrides com.
Deprecated
Method that return the starting location of the current token; that is, position of the first character from input that starts the current token. |
public Object | getTypeId()
Overrides com. Method that can be called to check whether current token (one that was just read) has an associated type id, and if so, return it. |
public abstract boolean | hasTextCharacters()
Overrides com. Method that can be used to determine whether calling of
|
public boolean | |
public abstract JsonToken | nextToken()
Implements abstract com. Main iteration method, which will advance stream enough to determine type of the next token, if any. |
public void | overrideCurrentName(String
Name to use as the current name; may be null. name)Overrides com. Method that can be used to change what is considered to be the current (field) name. |
public abstract JsonParser | overrideFormatFeatures(int
Bit mask of set/clear state for features to change values, int Bit mask of features to change mask)Overrides com. Bulk set method for (re)setting states of |
public void | setCodec(ObjectCodec
Codec to assign, if any; c)null if noneImplements abstract com. Setter that allows defining |
public void | setSchema(FormatSchema
Schema to use schema)Overrides com. Method to call to make this parser use specified schema. |
public Version | version()
Overrides com. Implements com. Accessor for getting version of the core package, given a parser instance. |
_avroContext | back to summary |
---|---|
protected AvroReadContext _avroContext |
_formatFeatures | back to summary |
---|---|
protected int _formatFeatures |
_objectCodec | back to summary |
---|---|
protected ObjectCodec _objectCodec Codec used for data binding when (if) requested. |
_rootSchema | back to summary |
---|---|
protected AvroSchema _rootSchema |
AVRO_READ_CAPABILITIES | back to summary |
---|---|
protected static final JacksonFeatureSet<StreamReadCapability> AVRO_READ_CAPABILITIES |
AvroParser | back to summary |
---|---|
protected AvroParser(IOContext ctxt, int parserFeatures, int avroFeatures, ObjectCodec codec) |
_closeInput | back to summary |
---|---|
protected abstract void _closeInput() throws IOException Implements abstract com.
|
_finishString | back to summary |
---|---|
protected void _finishString() throws IOException Overrides com.
|
_initSchema | back to summary |
---|---|
protected abstract void _initSchema(AvroSchema schema) throws IOException |
canReadTypeId | back to summary |
---|---|
public boolean canReadTypeId() Overrides com. Doc from com. Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't). Default implementation returns true; overridden by data formats that do support native Type Ids. Caller is expected to either use a non-native notation (explicit property or such), or fail, in case it can not use native type ids.
|
canUseSchema | back to summary |
---|---|
public boolean canUseSchema(FormatSchema schema) Overrides com. Doc from com. Method that can be used to verify that given schema can be used with
this parser (using
|
configure | back to summary |
---|---|
public JsonParser configure(AvroParser. Method for enabling or disabling specified Avro feature
(check |
currentLocation | back to summary |
---|---|
public JsonLocation currentLocation() Overrides com. Doc from com. Method that returns location of the last processed input unit (character or byte) from the input; usually for error reporting purposes.
Note that the location is not guaranteed to be accurate (although most
implementation will try their best): some implementations may only
report specific boundary locations (start or end locations of tokens)
and others only return
|
currentName | back to summary |
---|---|
public String currentName() throws IOException Overrides com. Doc from com. Method that can be called to get the name associated with
the current token: for
|
currentTokenLocation | back to summary |
---|---|
public JsonLocation currentTokenLocation() Overrides com. Doc from com. Method that return the starting location of the current (most recently returned) token; that is, the position of the first input unit (character or byte) from input that starts the current token.
Note that the location is not guaranteed to be accurate (although most
implementation will try their best): some implementations may only
return
|
disable | back to summary |
---|---|
public JsonParser disable(AvroParser. Method for disabling specified Avro feature
(check |
enable | back to summary |
---|---|
public JsonParser enable(AvroParser. Method for enabling specified Avro feature
(check |
getBinaryValue | back to summary |
---|---|
public byte[] getBinaryValue(Base64Variant variant) throws IOException Overrides com. Doc from com. Method that can be used to read (and consume -- results
may not be accessible using other methods after the call)
base64-encoded binary data
included in the current textual JSON value.
It works similar to getting String value via Note that non-decoded textual contents of the current token are not guaranteed to be accessible after this method is called. Current implementation, for example, clears up textual content during decoding. Decoded binary content, however, will be retained until parser is advanced to the next event.
|
getCodec | back to summary |
---|---|
public ObjectCodec getCodec() Implements abstract com. Doc from com. Accessor for
|
getCurrentLocation | back to summary |
---|---|
public JsonLocation getCurrentLocation() Overrides com. Doc from com. Deprecated
Method that returns location of the last processed character; usually for error reporting purposes
|
getCurrentName | back to summary |
---|---|
public String getCurrentName() throws IOException Overrides com. Doc from com. Deprecated
Method that can be called to get the name associated with the current event.
|
getEmbeddedObject | back to summary |
---|---|
public Object getEmbeddedObject() throws IOException Overrides com. Doc from com. Accessor that can be called if (and only if) the current token
is Note only some specialized parser implementations support
embedding of objects (usually ones that are facades on top
of non-streaming sources, such as object trees). One exception
is access to binary content (whether via base64 encoding or not)
which typically is accessible using this method, as well as
|
getInputSource | back to summary |
---|---|
public abstract Object getInputSource() Overrides com. Doc from com. Method that can be used to get access to object that is used
to access input being parsed; this is usually either
In general use of this accessor should be considered as "last effort", i.e. only used if no other mechanism is applicable. |
getReadCapabilities | back to summary |
---|---|
public JacksonFeatureSet Overrides com. Doc from com. Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).
|
getSchema | back to summary |
---|---|
public AvroSchema getSchema() Overrides com. Doc from com. Method for accessing Schema that this parser uses, if any. Default implementation returns null.
|
getText | back to summary |
---|---|
public abstract String getText() throws IOException Implements abstract com. Doc from com. Method for accessing textual representation of the current token;
if no current token (before first call to
|
getText | back to summary |
---|---|
public abstract int getText(Writer writer) throws IOException Overrides com. Doc from com. Method to read the textual representation of the current token in chunks and pass it to the given Writer. Conceptually same as calling: writer.write(parser.getText());but should typically be more efficient as longer content does need to be combined into a single String to return, and write
can occur directly from intermediate buffers Jackson uses.Note textual content will still be buffered (usually
using
|
getTextCharacters | back to summary |
---|---|
public char[] getTextCharacters() throws IOException Implements abstract com. Doc from com. Method similar to
Note that caller MUST NOT modify the returned character array in any way -- doing so may corrupt current parser state and render parser instance useless.
The only reason to call this method (over
|
getTextLength | back to summary |
---|---|
public int getTextLength() throws IOException Implements abstract com. Doc from com. Accessor used with
|
getTextOffset | back to summary |
---|---|
public int getTextOffset() throws IOException Implements abstract com. Doc from com. Accessor used with
|
getTokenLocation | back to summary |
---|---|
public JsonLocation getTokenLocation() Overrides com. Doc from com. Deprecated
Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.
|
getTypeId | back to summary |
---|---|
public Object getTypeId() throws IOException Overrides com. Doc from com. Method that can be called to check whether current token
(one that was just read) has an associated type id, and if
so, return it.
Note that while typically caller should check with Default implementation will simply return null.
|
hasTextCharacters | back to summary |
---|---|
public abstract boolean hasTextCharacters() Overrides com. Doc from com. Method that can be used to determine whether calling of
Default implementation simply returns false since only actual implementation class has knowledge of its internal buffering state. Implementations are strongly encouraged to properly override this method, to allow efficient copying of content by other code.
|
isEnabled | back to summary |
---|---|
public boolean isEnabled(AvroParser. Method for checking whether specified Avro |
nextToken | back to summary |
---|---|
public abstract JsonToken nextToken() throws IOException Implements abstract com. Doc from com. Main iteration method, which will advance stream enough to determine type of the next token, if any. If none remaining (stream has no content other than possible white space before ending), null will be returned.
|
overrideCurrentName | back to summary |
---|---|
public void overrideCurrentName(String name) Overrides com. Doc from com. Method that can be used to change what is considered to be the current (field) name. May be needed to support non-JSON data formats or unusual binding conventions; not needed for typical processing. Note that use of this method should only be done as sort of last resort, as it is a work-around for regular operation. |
overrideFormatFeatures | back to summary |
---|---|
public abstract JsonParser overrideFormatFeatures(int values, int mask) Overrides com. Doc from com. Bulk set method for (re)setting states of
Default implementation will simply throw an exception to indicate that
the parser implementation does not support any
|
setCodec | back to summary |
---|---|
public void setCodec(ObjectCodec c) Implements abstract com. Doc from com. Setter that allows defining
|
setSchema | back to summary |
---|---|
public void setSchema(FormatSchema schema) Overrides com. Doc from com. Method to call to make this parser use specified schema. Method must be called before trying to parse any content, right after parser instance has been created. Note that not all parsers support schemas; and those that do usually only accept specific types of schemas: ones defined for data format parser can read.
If parser does not support specified schema,
|
version | back to summary |
---|---|
public Version version() Overrides com. Implements com. Doc from com. Accessor for getting version of the core package, given a parser instance. Left for sub-classes to implement. |
Modifier and Type | Field and Description |
---|---|
pack-priv final boolean | |
pack-priv final int | |
public static final AvroParser. | AVRO_BUFFERING
Feature that can be disabled to prevent Avro from buffering any more data then absolutely necessary. |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static int | collectDefaults()
Method that calculates bit set (flags) of all features that are enabled by default. |
public boolean | enabledByDefault()
Implements com. Accessor for checking whether this feature is enabled by default. |
public boolean | enabledIn(int
Bit field that contains a set of enabled features of this type flags)Implements com. Convenience method for checking whether feature is enabled in given bitmask |
public int | getMask()
Implements com. Returns bit mask for this feature instance; must be a single bit,
that is of form |
public static AvroParser. | |
public static AvroParser. |
_defaultState | back to summary |
---|---|
pack-priv final boolean _defaultState |
_mask | back to summary |
---|---|
pack-priv final int _mask |
AVRO_BUFFERING | back to summary |
---|---|
public static final AvroParser. Feature that can be disabled to prevent Avro from buffering any more data then absolutely necessary. This affects buffering by underlying `SnakeYAML` codec. Enabled by default to preserve the existing behavior.
|
Feature | back to summary |
---|---|
private Feature(boolean defaultState) |
collectDefaults | back to summary |
---|---|
public static int collectDefaults() Method that calculates bit set (flags) of all features that are enabled by default. |
enabledByDefault | back to summary |
---|---|
public boolean enabledByDefault() Implements com. Doc from com. Accessor for checking whether this feature is enabled by default.
|
enabledIn | back to summary |
---|---|
public boolean enabledIn(int flags) Implements com. Doc from com. Convenience method for checking whether feature is enabled in given bitmask
|
getMask | back to summary |
---|---|
public int getMask() Implements com. Doc from com. Returns bit mask for this feature instance; must be a single bit,
that is of form
|
valueOf | back to summary |
---|---|
public static AvroParser. |
values | back to summary |
---|---|
public static AvroParser. |