BeanIO 2.0.4

org.beanio.internal.parser.format.json
Class JsonWrapper

java.lang.Object
  extended by org.beanio.internal.util.TreeNode<Component>
      extended by org.beanio.internal.parser.Component
          extended by org.beanio.internal.parser.ParserComponent
              extended by org.beanio.internal.parser.DelegatingParser
                  extended by org.beanio.internal.parser.format.json.JsonWrapper
All Implemented Interfaces:
Cloneable, Iterable<Component>, JsonNode, Parser, Replicateable

public class JsonWrapper
extends DelegatingParser
implements JsonNode

A JsonWrapper is used to handle nested JSON objects.

Since:
2.0
Author:
Kevin Seim

Field Summary
 
Fields inherited from interface org.beanio.internal.parser.format.json.JsonNode
ARRAY, BOOLEAN, NUMBER, OBJECT, STRING
 
Constructor Summary
JsonWrapper()
          Constructs a new JsonWrapper.
 
Method Summary
 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.
 boolean isJsonArray()
          Returns whether this node is a JSON array.
 boolean isLazy()
          Returns whether this node must exist during unmarshalling.
 boolean isNillable()
          Returns whether this node may be explicitly set to null.
 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(String jsonName)
           
 void setJsonType(char jsonType)
           
 void setLazy(boolean lazy)
           
 void setNillable(boolean nillable)
           
protected  void toParamString(StringBuilder s)
          Called by TreeNode.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, iterator, print, setName, size, sort, toString, updateReferences
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.beanio.internal.parser.format.json.JsonNode
getName
 
Methods inherited from interface org.beanio.internal.parser.Parser
getName
 

Constructor Detail

JsonWrapper

public JsonWrapper()
Constructs a new JsonWrapper.

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 interface Parser
Overrides:
matches in class DelegatingParser
Parameters:
context - the UnmarshallingContext
Returns:
true if matched, false otherwise

unmarshal

public boolean unmarshal(UnmarshallingContext context)
Description copied from interface: Parser
Unmarshals a record.

Specified by:
unmarshal in interface Parser
Overrides:
unmarshal in class DelegatingParser
Parameters:
context - the UnmarshallingContext
Returns:
true if this component was present in the unmarshalled record, or false otherwise

marshal

public boolean marshal(MarshallingContext context)
                throws IOException
Description copied from interface: Parser
Marshals a record.

Specified by:
marshal in interface Parser
Overrides:
marshal in class DelegatingParser
Parameters:
context - the MarshallingContext
Returns:
whether a value was marshalled
Throws:
IOException - if an I/O error occurs

getJsonName

public String getJsonName()
Description copied from interface: JsonNode
Returns the JSON field name.

Specified by:
getJsonName in interface JsonNode
Returns:
the JSON field name

setJsonName

public void setJsonName(String jsonName)

getJsonType

public char getJsonType()
Description copied from interface: JsonNode
Returns the type of node. If JsonNode.isJsonArray() is true, this method returns the component type of the array.

Specified by:
getJsonType in interface JsonNode
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 interface JsonNode
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 interface JsonNode
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 to null.

Specified by:
isNillable in interface JsonNode
Returns:
true if this node value may be set to null, false otherwise

setNillable

public void setNillable(boolean nillable)

isLazy

public boolean isLazy()
Description copied from interface: Parser
Returns whether this node must exist during unmarshalling.

Specified by:
isLazy in interface Parser
Overrides:
isLazy in class DelegatingParser
Returns:
true if this node is optional during unmarshalling, false otherwise

setLazy

public void setLazy(boolean lazy)
Parameters:
lazy -

toParamString

protected void toParamString(StringBuilder s)
Description copied from class: TreeNode
Called by TreeNode.toString() to append node parameters to the output.

Overrides:
toParamString in class TreeNode<Component>
Parameters:
s - the output to append

BeanIO 2.0.4

Copyright © 2010-2013 Kevin Seim