org.codehaus.jackson.node
Class BaseJsonNode

java.lang.Object
  extended by org.codehaus.jackson.JsonNode
      extended by org.codehaus.jackson.node.BaseJsonNode
All Implemented Interfaces:
Iterable<JsonNode>, JsonSerializable
Direct Known Subclasses:
ContainerNode, MissingNode, ValueNode

public abstract class BaseJsonNode
extends JsonNode
implements JsonSerializable

Abstract base class common to all standard JsonNode implementations. The main addition here is that we declare that sub-classes must implement JsonSerializable. This simplifies object mapping aspects a bit, as no external serializers are needed.


Constructor Summary
protected BaseJsonNode()
           
 
Method Summary
abstract  JsonToken asToken()
          Method that can be used for efficient type detection when using stream abstraction for traversing nodes.
 JsonParser.NumberType getNumberType()
          If this node is a numeric type (as per JsonNode.isNumber()), returns native type that node uses to store the numeric value.
abstract  void serialize(JsonGenerator jgen, SerializerProvider provider)
          Method called to serialize node instances using given generator.
 JsonParser traverse()
          Method for constructing a JsonParser instance for iterating over contents of the tree that this node is root of.
 void writeTo(JsonGenerator jgen)
           Note: this method should probably be deprecated, given that we want to use the standard serialization interface.
 
Methods inherited from class org.codehaus.jackson.JsonNode
append, equals, get, get, getBigIntegerValue, getBinaryValue, getBooleanValue, getDecimalValue, getDoubleValue, getElements, getElementValue, getFieldNames, getFieldValue, getIntValue, getLongValue, getNumberValue, getPath, getPath, getTextValue, getValueAsText, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isTextual, isValueNode, iterator, path, path, size, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseJsonNode

protected BaseJsonNode()
Method Detail

traverse

public JsonParser traverse()
Description copied from class: JsonNode
Method for constructing a JsonParser instance for iterating over contents of the tree that this node is root of. Functionally equivalent to first serializing tree using JsonNode.writeTo(org.codehaus.jackson.JsonGenerator) and then re-parsing but much more efficient.

Specified by:
traverse in class JsonNode

asToken

public abstract JsonToken asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)

Specified by:
asToken in class JsonNode
Since:
1.3

getNumberType

public JsonParser.NumberType getNumberType()
Description copied from class: JsonNode
If this node is a numeric type (as per JsonNode.isNumber()), returns native type that node uses to store the numeric value.

Specified by:
getNumberType in class JsonNode
Since:
1.3

serialize

public abstract void serialize(JsonGenerator jgen,
                               SerializerProvider provider)
                        throws IOException,
                               JsonProcessingException
Method called to serialize node instances using given generator.

Specified by:
serialize in interface JsonSerializable
Throws:
IOException
JsonProcessingException

writeTo

public final void writeTo(JsonGenerator jgen)
                   throws IOException,
                          JsonGenerationException

Note: this method should probably be deprecated, given that we want to use the standard serialization interface.

Specified by:
writeTo in class JsonNode
Throws:
IOException
JsonGenerationException