Package org.codehaus.jackson.node
Class BaseJsonNode
- java.lang.Object
-
- org.codehaus.jackson.JsonNode
-
- org.codehaus.jackson.node.BaseJsonNode
-
- All Implemented Interfaces:
Iterable<JsonNode>,JsonSerializable,JsonSerializableWithType
- Direct Known Subclasses:
ContainerNode,MissingNode,ValueNode
public abstract class BaseJsonNode extends JsonNode implements JsonSerializableWithType
Abstract base class common to all standardJsonNodeimplementations. The main addition here is that we declare that sub-classes must implementJsonSerializableWithType. This simplifies object mapping aspects a bit, as no external serializers are needed.
-
-
Field Summary
-
Fields inherited from class org.codehaus.jackson.JsonNode
NO_NODES, NO_STRINGS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseJsonNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract JsonTokenasToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.ObjectNodefindParent(String fieldName)Method for finding a JSON Object that contains specified field, within this node or its descendants.List<JsonNode>findParents(String fieldName, List<JsonNode> foundSoFar)JsonNodefindPath(String fieldName)Method similar toJsonNode.findValue(java.lang.String), but that will return a "missing node" instead of null if no field is found.JsonNodefindValue(String fieldName)Method for finding a JSON Object field with specified name in this node or its child nodes, and returning value it has.List<JsonNode>findValues(String fieldName, List<JsonNode> foundSoFar)List<String>findValuesAsText(String fieldName, List<String> foundSoFar)JsonParser.NumberTypegetNumberType()If this node is a numeric type (as perJsonNode.isNumber()), returns native type that node uses to store the numeric value.abstract voidserialize(JsonGenerator jgen, SerializerProvider provider)Method called to serialize node instances using given generator.abstract voidserializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer)Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.JsonParsertraverse()Method for constructing aJsonParserinstance for iterating over contents of the tree that this node is root of.-
Methods inherited from class org.codehaus.jackson.JsonNode
asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, asText, equals, findParents, findValues, findValuesAsText, get, get, getBigIntegerValue, getBinaryValue, getBooleanValue, getDecimalValue, getDoubleValue, getElements, getFieldNames, getFields, getIntValue, getLongValue, getNumberValue, getPath, getPath, getTextValue, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsText, has, has, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isTextual, isValueNode, iterator, path, path, size, toString, with
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
findValue
public JsonNode findValue(String fieldName)
Description copied from class:JsonNodeMethod for finding a JSON Object field with specified name in this node or its child nodes, and returning value it has. If no matching field is found in this node or its descendants, returns null.
-
findPath
public final JsonNode findPath(String fieldName)
Description copied from class:JsonNodeMethod similar toJsonNode.findValue(java.lang.String), but that will return a "missing node" instead of null if no field is found. Missing node is a specific kind of node for whichJsonNode.isMissingNode()returns true; and all value access methods return empty or missing value.
-
findParent
public ObjectNode findParent(String fieldName)
Description copied from class:JsonNodeMethod for finding a JSON Object that contains specified field, within this node or its descendants. If no matching field is found in this node or its descendants, returns null.- Specified by:
findParentin classJsonNode- Parameters:
fieldName- Name of field to look for- Returns:
- Value of first matching node found, if any; null if none
-
findValues
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
- Specified by:
findValuesin classJsonNode
-
findValuesAsText
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
- Specified by:
findValuesAsTextin classJsonNode
-
findParents
public List<JsonNode> findParents(String fieldName, List<JsonNode> foundSoFar)
- Specified by:
findParentsin classJsonNode
-
traverse
public JsonParser traverse()
Description copied from class:JsonNodeMethod for constructing aJsonParserinstance for iterating over contents of the tree that this node is root of. Functionally equivalent to first serializing tree usingObjectCodecand then re-parsing but more efficient.
-
asToken
public abstract JsonToken asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonTokenthat equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)
-
getNumberType
public JsonParser.NumberType getNumberType()
Description copied from class:JsonNodeIf this node is a numeric type (as perJsonNode.isNumber()), returns native type that node uses to store the numeric value.- Specified by:
getNumberTypein classJsonNode- 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:
serializein interfaceJsonSerializable- Throws:
IOExceptionJsonProcessingException
-
serializeWithType
public abstract void serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonProcessingException
Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.- Specified by:
serializeWithTypein interfaceJsonSerializableWithType- Throws:
IOExceptionJsonProcessingException
-
-