Class JsonWrapper
- java.lang.Object
-
- org.beanio.internal.util.TreeNode<Component>
-
- org.beanio.internal.parser.Component
-
- org.beanio.internal.parser.ParserComponent
-
- org.beanio.internal.parser.DelegatingParser
-
- org.beanio.internal.parser.format.json.JsonWrapper
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Iterable<Component>
,JsonNode
,Parser
,Replicateable
public class JsonWrapper extends DelegatingParser implements JsonNode
AJsonWrapper
is used to handle nested JSON objects.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description JsonWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getJsonArrayIndex()
Returns the index of this node in its parent array, or -1 if not applicable (i.e.java.lang.String
getJsonName()
Returns the JSON field name.char
getJsonType()
Returns the type of node.boolean
isJsonArray()
Returns whether this node is a JSON array.boolean
isNillable()
Returns whether this node may be explicitly set tonull
.boolean
isOptional()
Returns whether this node must exist during unmarshalling.boolean
marshal(MarshallingContext context)
Marshals a record.boolean
matches(UnmarshallingContext context)
Returns whether this parser and its children match a record being unmarshalled.void
setJsonArray(boolean jsonArray)
void
setJsonArrayIndex(int jsonArrayIndex)
void
setJsonName(java.lang.String jsonName)
void
setJsonType(char jsonType)
void
setNillable(boolean nillable)
void
setOptional(boolean optional)
protected void
toParamString(java.lang.StringBuilder s)
Called byTreeNode.toString()
to append node parameters to the output.boolean
unmarshal(UnmarshallingContext context)
Unmarshals a record.-
Methods inherited from class org.beanio.internal.parser.DelegatingParser
clearValue, getParser, getSize, getValue, hasContent, isIdentifier, setValue
-
Methods inherited from class org.beanio.internal.parser.ParserComponent
isSupportedChild
-
Methods inherited from class org.beanio.internal.parser.Component
registerLocals
-
Methods inherited from class org.beanio.internal.util.TreeNode
add, clone, find, getChildren, getFirst, getName, isDescendant, iterator, print, print, setName, size, sort, toString, updateReferences
-
-
-
-
Method Detail
-
matches
public boolean matches(UnmarshallingContext context)
Description copied from interface:Parser
Returns whether this parser and its children match a record being unmarshalled.- Specified by:
matches
in interfaceParser
- Overrides:
matches
in classDelegatingParser
- Parameters:
context
- theUnmarshallingContext
- Returns:
- true if matched, false otherwise
-
unmarshal
public boolean unmarshal(UnmarshallingContext context)
Description copied from interface:Parser
Unmarshals a record.- Specified by:
unmarshal
in interfaceParser
- Overrides:
unmarshal
in classDelegatingParser
- Parameters:
context
- theUnmarshallingContext
- Returns:
true
if this component was present in the unmarshalled record, orfalse
otherwise
-
marshal
public boolean marshal(MarshallingContext context) throws java.io.IOException
Description copied from interface:Parser
Marshals a record.- Specified by:
marshal
in interfaceParser
- Overrides:
marshal
in classDelegatingParser
- Parameters:
context
- theMarshallingContext
- Returns:
- whether a value was marshalled
- Throws:
java.io.IOException
- if an I/O error occurs
-
getJsonName
public java.lang.String getJsonName()
Description copied from interface:JsonNode
Returns the JSON field name.- Specified by:
getJsonName
in interfaceJsonNode
- Returns:
- the JSON field name
-
setJsonName
public void setJsonName(java.lang.String jsonName)
-
getJsonType
public char getJsonType()
Description copied from interface:JsonNode
Returns the type of node. IfJsonNode.isJsonArray()
is true, this method returns the component type of the array.- Specified by:
getJsonType
in interfaceJsonNode
- Returns:
- the node type
-
setJsonType
public void setJsonType(char jsonType)
-
isJsonArray
public boolean isJsonArray()
Description copied from interface:JsonNode
Returns whether this node is a JSON array.- Specified by:
isJsonArray
in interfaceJsonNode
- Returns:
- true if this node a JSON array, false otherwise
-
setJsonArray
public void setJsonArray(boolean jsonArray)
-
getJsonArrayIndex
public int getJsonArrayIndex()
Description copied from interface:JsonNode
Returns the index of this node in its parent array, or -1 if not applicable (i.e. its parent is an object).- Specified by:
getJsonArrayIndex
in interfaceJsonNode
- Returns:
- the index of this node in its parent array
-
setJsonArrayIndex
public void setJsonArrayIndex(int jsonArrayIndex)
-
isNillable
public boolean isNillable()
Description copied from interface:JsonNode
Returns whether this node may be explicitly set tonull
.- Specified by:
isNillable
in interfaceJsonNode
- Returns:
- true if this node value may be set to
null
, false otherwise
-
setNillable
public void setNillable(boolean nillable)
-
isOptional
public boolean isOptional()
Description copied from interface:Parser
Returns whether this node must exist during unmarshalling.- Specified by:
isOptional
in interfaceParser
- Overrides:
isOptional
in classDelegatingParser
- Returns:
- true if this node is optional during unmarshalling, false otherwise
-
setOptional
public void setOptional(boolean optional)
-
toParamString
protected void toParamString(java.lang.StringBuilder s)
Description copied from class:TreeNode
Called byTreeNode.toString()
to append node parameters to the output.- Overrides:
toParamString
in classTreeNode<Component>
- Parameters:
s
- the output to append
-
-