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
AJsonWrapperis 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 intgetJsonArrayIndex()Returns the index of this node in its parent array, or -1 if not applicable (i.e.java.lang.StringgetJsonName()Returns the JSON field name.chargetJsonType()Returns the type of node.booleanisJsonArray()Returns whether this node is a JSON array.booleanisNillable()Returns whether this node may be explicitly set tonull.booleanisOptional()Returns whether this node must exist during unmarshalling.booleanmarshal(MarshallingContext context)Marshals a record.booleanmatches(UnmarshallingContext context)Returns whether this parser and its children match a record being unmarshalled.voidsetJsonArray(boolean jsonArray)voidsetJsonArrayIndex(int jsonArrayIndex)voidsetJsonName(java.lang.String jsonName)voidsetJsonType(char jsonType)voidsetNillable(boolean nillable)voidsetOptional(boolean optional)protected voidtoParamString(java.lang.StringBuilder s)Called byTreeNode.toString()to append node parameters to the output.booleanunmarshal(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:ParserReturns whether this parser and its children match a record being unmarshalled.- Specified by:
matchesin interfaceParser- Overrides:
matchesin classDelegatingParser- Parameters:
context- theUnmarshallingContext- Returns:
- true if matched, false otherwise
-
unmarshal
public boolean unmarshal(UnmarshallingContext context)
Description copied from interface:ParserUnmarshals a record.- Specified by:
unmarshalin interfaceParser- Overrides:
unmarshalin classDelegatingParser- Parameters:
context- theUnmarshallingContext- Returns:
trueif this component was present in the unmarshalled record, orfalseotherwise
-
marshal
public boolean marshal(MarshallingContext context) throws java.io.IOException
Description copied from interface:ParserMarshals a record.- Specified by:
marshalin interfaceParser- Overrides:
marshalin 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:JsonNodeReturns the JSON field name.- Specified by:
getJsonNamein interfaceJsonNode- Returns:
- the JSON field name
-
setJsonName
public void setJsonName(java.lang.String jsonName)
-
getJsonType
public char getJsonType()
Description copied from interface:JsonNodeReturns the type of node. IfJsonNode.isJsonArray()is true, this method returns the component type of the array.- Specified by:
getJsonTypein interfaceJsonNode- Returns:
- the node type
-
setJsonType
public void setJsonType(char jsonType)
-
isJsonArray
public boolean isJsonArray()
Description copied from interface:JsonNodeReturns whether this node is a JSON array.- Specified by:
isJsonArrayin 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:JsonNodeReturns the index of this node in its parent array, or -1 if not applicable (i.e. its parent is an object).- Specified by:
getJsonArrayIndexin 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:JsonNodeReturns whether this node may be explicitly set tonull.- Specified by:
isNillablein 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:ParserReturns whether this node must exist during unmarshalling.- Specified by:
isOptionalin interfaceParser- Overrides:
isOptionalin 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:TreeNodeCalled byTreeNode.toString()to append node parameters to the output.- Overrides:
toParamStringin classTreeNode<Component>- Parameters:
s- the output to append
-
-