public class JsonFieldFormat extends Object implements FieldFormat, JsonNode
FieldFormat
implementation for a field in a JSON formatted record.Constructor and Description |
---|
JsonFieldFormat()
Constructs a new JsonFieldFormat.
|
Modifier and Type | Method and Description |
---|---|
String |
extract(UnmarshallingContext context,
boolean reportErrors)
Extracts the field text from a record.
|
int |
getJsonArrayIndex()
Returns the index of this node in its parent array, or -1 if not applicable
(i.e.
|
String |
getJsonName()
Returns the JSON field name.
|
char |
getJsonType()
Returns the type of node.
|
String |
getName()
Returns the field name.
|
FieldPadding |
getPadding() |
int |
getSize()
Returns the size of the field.
|
void |
insertField(MarshallingContext context,
String text)
Inserts field text into a record.
|
boolean |
insertValue(MarshallingContext context,
Object value)
Inserts a value into a record.
|
boolean |
isBypassTypeHandler() |
boolean |
isJsonArray()
Returns whether this node is a JSON array.
|
boolean |
isLazy()
TODO rename isLazy to something better??
Returns whether this field is optionally present in the record.
|
boolean |
isNillable()
Returns whether this field is nillable.
|
void |
setBypassTypeHandler(boolean bypassTypeHandler) |
void |
setJsonArray(boolean repeating) |
void |
setJsonArrayIndex(int jsonArrayIndex) |
void |
setJsonName(String jsonName) |
void |
setJsonType(char jsonType) |
void |
setLazy(boolean lazy) |
void |
setName(String name) |
void |
setNillable(boolean nillable) |
void |
setPadding(FieldPadding padding) |
String |
toString() |
public String extract(UnmarshallingContext context, boolean reportErrors)
FieldFormat
May return Value.INVALID
if the field is invalid, or Value.NIL
if the field is explicitly set to nil or null such as in an XML or JSON formatted
stream.
Implementations should also remove any field padding before returning the text.
extract
in interface FieldFormat
context
- the UnmarshallingContext
holding the recordpublic boolean insertValue(MarshallingContext context, Object value)
FieldFormat
FieldFormat.insertField(MarshallingContext, String)
is called. If the method returns true, FieldFormat.insertField(MarshallingContext, String)
is not invoked.insertValue
in interface FieldFormat
context
- the MarshallingContext
value
- the value to insert into the recordFieldFormat.insertField(MarshallingContext, String)
must be invoked, false otherwisepublic void insertField(MarshallingContext context, String text)
FieldFormat
insertField
in interface FieldFormat
context
- the MarshallingContext
holding the recordtext
- the field text to insert into the recordpublic void setName(String name)
name
- public void setLazy(boolean lazy)
lazy
- public int getSize()
FieldFormat
getSize
in interface FieldFormat
public void setNillable(boolean nillable)
nillable
- public boolean isNillable()
FieldFormat
isNillable
in interface FieldFormat
isNillable
in interface JsonNode
public boolean isLazy()
FieldFormat
isLazy
in interface FieldFormat
public void setJsonName(String jsonName)
jsonName
- public String getJsonName()
JsonNode
getJsonName
in interface JsonNode
public void setJsonType(char jsonType)
jsonType
- public char getJsonType()
JsonNode
JsonNode.isJsonArray()
is true, this method
returns the component type of the array.getJsonType
in interface JsonNode
public void setJsonArray(boolean repeating)
public boolean isJsonArray()
JsonNode
isJsonArray
in interface JsonNode
public int getJsonArrayIndex()
JsonNode
getJsonArrayIndex
in interface JsonNode
public void setJsonArrayIndex(int jsonArrayIndex)
public FieldPadding getPadding()
public void setPadding(FieldPadding padding)
public boolean isBypassTypeHandler()
public void setBypassTypeHandler(boolean bypassTypeHandler)