Class ContainerNode
java.lang.Object
org.codehaus.jackson.JsonNode
org.codehaus.jackson.node.BaseJsonNode
org.codehaus.jackson.node.ContainerNode
- All Implemented Interfaces:
Iterable<JsonNode>, JsonSerializable, JsonSerializableWithType
- Direct Known Subclasses:
ArrayNode, ObjectNode
This intermediate base class is used for all container nodes,
specifically, array and object nodes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static class -
Field Summary
Fields inherited from class JsonNode
NO_NODES, NO_STRINGS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ArrayNodeFactory method that constructs and returns an emptyArrayNodeConstruction is done using registeredJsonNodeFactory.asText()Method that will return valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()returns true), otherwise empty String.abstract JsonTokenasToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.final BinaryNodebinaryNode(byte[] data) final BinaryNodebinaryNode(byte[] data, int offset, int length) final BooleanNodebooleanNode(boolean v) abstract ObjectNodefindParent(String fieldName) Method for finding a JSON Object that contains specified field, within this node or its descendants.findParents(String fieldName, List<JsonNode> foundSoFar) abstract JsonNodeMethod for finding a JSON Object field with specified name in this node or its child nodes, and returning value it has.findValues(String fieldName, List<JsonNode> foundSoFar) findValuesAsText(String fieldName, List<String> foundSoFar) abstract JsonNodeget(int index) Method for accessing value of the specified element of an array node.abstract JsonNodeMethod for accessing value of the specified field of an object node.Method that will return valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()returns true), otherwise null.booleanMethod that returns true for container nodes: Arrays and Objects.final NullNodenullNode()final NumericNodenumberNode(byte v) final NumericNodenumberNode(double v) final NumericNodenumberNode(float v) final NumericNodenumberNode(int v) final NumericNodenumberNode(long v) final NumericNodenumberNode(short v) final NumericNodefinal ObjectNodeFactory method that constructs and returns an emptyObjectNodeConstruction is done using registeredJsonNodeFactory.final POJONodeabstract ContainerNodeMethod for removing all children container has (if any)abstract intsize()Method that returns number of child nodes this node contains: for Array nodes, number of child elements, for Object nodes, number of fields, and for all other nodes 0.final TextNodeMethods inherited from class BaseJsonNode
findPath, getNumberType, serialize, serializeWithType, traverseMethods inherited from class JsonNode
asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, equals, findParents, findValues, findValuesAsText, getBigIntegerValue, getBinaryValue, getBooleanValue, getDecimalValue, getDoubleValue, getElements, getFieldNames, getFields, getIntValue, getLongValue, getNumberValue, getPath, getPath, getTextValue, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, has, has, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isDouble, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isTextual, isValueNode, iterator, path, path, toString, withMethods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
ContainerNode
-
-
Method Details
-
isContainerNode
public boolean isContainerNode()Description copied from class:JsonNodeMethod that returns true for container nodes: Arrays and Objects.Note: one and only one of methods
JsonNode.isValueNode(),JsonNode.isContainerNode()andJsonNode.isMissingNode()ever returns true for any given node.- Overrides:
isContainerNodein classJsonNode
-
asToken
Description copied from class:BaseJsonNodeMethod 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)- Specified by:
asTokenin classBaseJsonNode
-
getValueAsText
Description copied from class:JsonNodeMethod that will return valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()returns true), otherwise null.Note: to serialize nodes of any type, you should call
JsonNode.toString()instead.- Overrides:
getValueAsTextin classJsonNode
-
asText
Description copied from class:JsonNodeMethod that will return valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()returns true), otherwise empty String. -
findValue
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.- Overrides:
findValuein classBaseJsonNode- Parameters:
fieldName- Name of field to look for- Returns:
- Value of first matching node found, if any; null if none
-
findParent
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.- Overrides:
findParentin classBaseJsonNode- Parameters:
fieldName- Name of field to look for- Returns:
- Value of first matching node found, if any; null if none
-
findValues
- Overrides:
findValuesin classBaseJsonNode
-
findParents
- Overrides:
findParentsin classBaseJsonNode
-
findValuesAsText
- Overrides:
findValuesAsTextin classBaseJsonNode
-
size
public abstract int size()Description copied from class:JsonNodeMethod that returns number of child nodes this node contains: for Array nodes, number of child elements, for Object nodes, number of fields, and for all other nodes 0. -
get
Description copied from class:JsonNodeMethod for accessing value of the specified element of an array node. For other nodes, null is always returned.For array nodes, index specifies exact location within array and allows for efficient iteration over child elements (underlying storage is guaranteed to be efficiently indexable, i.e. has random-access to elements). If index is less than 0, or equal-or-greater than
node.size(), null is returned; no exception is thrown for any index. -
get
Description copied from class:JsonNodeMethod for accessing value of the specified field of an object node. If this node is not an object (or it does not have a value for specified field name), or if there is no field with such name, null is returned. -
arrayNode
Factory method that constructs and returns an emptyArrayNodeConstruction is done using registeredJsonNodeFactory. -
objectNode
Factory method that constructs and returns an emptyObjectNodeConstruction is done using registeredJsonNodeFactory. -
nullNode
-
booleanNode
-
numberNode
-
numberNode
-
numberNode
-
numberNode
-
numberNode
-
numberNode
-
numberNode
-
textNode
-
binaryNode
-
binaryNode
-
POJONode
-
removeAll
Method for removing all children container has (if any)- Returns:
- Container node itself (to allow method call chaining)
- Since:
- 1.3
-