Top Description Fields Constructors Methods
tools.jackson.databind.node

public Class StringNode

extends ValueNode
Class Inheritance
Imports
java.math.BigDecimal, .BigInteger, java.util.Objects, .Optional, .OptionalDouble, .OptionalInt, .OptionalLong, tools.jackson.core.*, tools.jackson.core.io.NumberInput, tools.jackson.core.util.ByteArrayBuilder, tools.jackson.databind.SerializationContext, tools.jackson.databind.exc.JsonNodeException

Value node that contains a String value.

Field Summary

Modifier and TypeField and Description
protected final String
pack-priv static final StringNode
private static final long
Inherited from tools.jackson.databind.node.ValueNode:
BD_MAX_INTEGERBD_MAX_LONGBD_MAX_SHORTBD_MIN_INTEGERBD_MIN_LONGBD_MIN_SHORTBI_MAX_INTEGERBI_MAX_LONGBI_MAX_SHORTBI_MIN_INTEGERBI_MIN_LONGBI_MIN_SHORTMISSING

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Boolean
_asBoolean()

Overrides tools.jackson.databind.node.BaseJsonNode._asBoolean.

Method sub-classes should override if they can produce boolean values via asBoolean() -- if not, return null (in which case appropriate error will be thrown or default value returned).

protected String
_asString()

Overrides tools.jackson.databind.node.BaseJsonNode._asString.

Method sub-classes should override if they can produce String values via asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).

protected BigDecimal
protected BigInteger
protected Double
protected Float
protected Integer
protected Long
protected Short
protected String
_valueDesc()

Implements abstract tools.jackson.databind.node.BaseJsonNode._valueDesc.

Method for implementation classes to return a short description of contained value, to be used in error messages.

public BigInteger
asBigInteger()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Method similar to bigIntegerValue() but in addition to coercing Number values (same as bigIntegerValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public BigInteger
asBigInteger(BigInteger defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Method similar to asBigInteger(), but that will return specified defaultValue if this node cannot be converted to BigInteger.

public Optional<BigInteger>
asBigIntegerOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigIntegerOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public BigDecimal
asDecimal()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Method that will try to access value of this node as a BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown.

public BigDecimal
asDecimal(BigDecimal defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public Optional<BigDecimal>
asDecimalOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimalOpt.

Method similar to asDecimal(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

public double
asDouble()

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Method similar to doubleValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0d)
  • POJO nodes that contain Number values
public double
asDouble(double defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

public OptionalDouble
asDoubleOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDoubleOpt.

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

public float
asFloat()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Method similar to floatValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0f)
  • POJO nodes that contain Number values
public float
asFloat(float defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

public Optional<Float>
asFloatOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloatOpt.

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

public int
asInt()

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Method similar to intValue() but in addition to coercing Number values (same as intValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public int
asInt(int defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to int.

public OptionalInt
asIntOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asIntOpt.

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

public long
asLong()

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Method similar to longValue() but in addition to coercing Number values (same as longValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public long
asLong(long defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

public OptionalLong
asLongOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asLongOpt.

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

public short
asShort()

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Method similar to shortValue() but in addition to coercing Number values (same as shortValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public short
asShort(short defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to short.

public Optional<Short>
asShortOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asShortOpt.

Method similar to asShort(), but that will return (Optional.empty()) if this node cannot be coerced to short.

public String
asString()

Overrides tools.jackson.databind.node.BaseJsonNode.asString.

Method that will try to convert value of this node to a String.

public String
asString(String defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asString.

Similar to asString(), but instead of throwing an exception for non-coercible values, will return specified default value.

public Optional<String>
asStringOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asStringOpt.

Similar to asString(), but instead of throwing an exception for non-coercible values, will return Optional.empty().

public JsonToken
asToken()

Implements abstract tools.jackson.databind.node.ValueNode.asToken.

Implements tools.jackson.core.TreeNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.

public byte[]
binaryValue()

Overrides tools.jackson.databind.node.BaseJsonNode.binaryValue.

Method that will try to access value of this node as binary value (Java byte[]) which works if (and only if) node contains binary value (for JSON, Base64-encoded String, for other formats native binary value): if not, a JsonNodeException will be thrown.

public StringNode
deepCopy()

Overrides tools.jackson.databind.node.ValueNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

public boolean
equals(Object o)

Implements abstract tools.jackson.databind.JsonNode.equals.

Equality for node objects is defined as full (deep) value equality.

public byte[]
getBinaryValue(Base64Variant b64variant)

Method for accessing content String assuming they were base64 encoded; if so, content is decoded and resulting binary data is returned.

public JsonNodeType
getNodeType()

Implements abstract tools.jackson.databind.JsonNode.getNodeType.

Return the type of this node

public int
hashCode()

Implements abstract tools.jackson.databind.node.BaseJsonNode.hashCode.

Returns a hash code value for this object.

public final void
serialize(JsonGenerator g, SerializationContext provider)

Implements abstract tools.jackson.databind.node.BaseJsonNode.serialize.

Implements tools.jackson.databind.JacksonSerializable.serialize.

Method called to serialize node instances using given generator.

public String
stringValue()

Overrides tools.jackson.databind.node.BaseJsonNode.stringValue.

Method that will try to access value of this node as a Java String which works if (and only if) node contains JSON String or null value: if not, a JsonNodeException will be thrown.

public String
stringValue(String defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.stringValue.

Method similar to stringValue(), but that will return specified defaultValue if this node does not contain a JSON String.

public Optional<String>
stringValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.stringValueOpt.

Method similar to stringValue(), but that will return Optional.empty() if this node does not contain a JSON String (NOTE: JSON null is not considered a String here)

public static StringNode

Returns:

Resulting StringNode object, if v is NOT null; null if it is.
valueOf
(String v)

Factory method that should be used to construct instances.

Inherited from tools.jackson.databind.node.ValueNode:
_atfindParentfindParentsfindValuefindValuesfindValuesAsStringgetgethashashasNonNullhasNonNullisEmptypathpathserializeWithType

Field Detail

_valueback to summary
protected final String _value
EMPTY_STRING_NODEback to summary
pack-priv static final StringNode EMPTY_STRING_NODE
serialVersionUIDback to summary
private static final long serialVersionUID

Hides tools.jackson.databind.node.ValueNode.serialVersionUID.

Constructor Detail

StringNodeback to summary
public StringNode(String v)

Method Detail

_asBooleanback to summary
public Boolean _asBoolean()

Overrides tools.jackson.databind.node.BaseJsonNode._asBoolean.

Doc from tools.jackson.databind.node.BaseJsonNode._asBoolean.

Method sub-classes should override if they can produce boolean values via asBoolean() -- if not, return null (in which case appropriate error will be thrown or default value returned).

Annotations
@Override
_asStringback to summary
protected String _asString()

Overrides tools.jackson.databind.node.BaseJsonNode._asString.

Doc from tools.jackson.databind.node.BaseJsonNode._asString.

Method sub-classes should override if they can produce String values via asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).

Annotations
@Override
_tryParseAsBigDecimalback to summary
protected BigDecimal _tryParseAsBigDecimal()
_tryParseAsBigIntegerback to summary
protected BigInteger _tryParseAsBigInteger()
_tryParseAsDoubleback to summary
protected Double _tryParseAsDouble()
_tryParseAsFloatback to summary
protected Float _tryParseAsFloat()
_tryParseAsIntegerback to summary
protected Integer _tryParseAsInteger()
_tryParseAsLongback to summary
protected Long _tryParseAsLong()
_tryParseAsShortback to summary
protected Short _tryParseAsShort()
_valueDescback to summary
protected String _valueDesc()

Implements abstract tools.jackson.databind.node.BaseJsonNode._valueDesc.

Doc from tools.jackson.databind.node.BaseJsonNode._valueDesc.

Method for implementation classes to return a short description of contained value, to be used in error messages.

Annotations
@Override
asBigIntegerback to summary
public BigInteger asBigInteger()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Doc from tools.jackson.databind.JsonNode.asBigInteger.

Method similar to bigIntegerValue() but in addition to coercing Number values (same as bigIntegerValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asBigIntegerback to summary
public BigInteger asBigInteger(BigInteger defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Doc from tools.jackson.databind.JsonNode.asBigInteger.

Method similar to asBigInteger(), but that will return specified defaultValue if this node cannot be converted to BigInteger.

Annotations
@Override
asBigIntegerOptback to summary
public Optional<BigInteger> asBigIntegerOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigIntegerOpt.

Doc from tools.jackson.databind.JsonNode.asBigIntegerOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

Annotations
@Override
asDecimalback to summary
public BigDecimal asDecimal()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Doc from tools.jackson.databind.JsonNode.asDecimal.

Method that will try to access value of this node as a BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Floating-point values (but not "NaN" or "Infinity")
  • JSON Integer values
  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to BigDecimal#ZERO))
  • POJO nodes that contain Number values

Annotations
@Override
asDecimalback to summary
public BigDecimal asDecimal(BigDecimal defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Doc from tools.jackson.databind.JsonNode.asDecimal.

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

Annotations
@Override
asDecimalOptback to summary
public Optional<BigDecimal> asDecimalOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimalOpt.

Doc from tools.jackson.databind.JsonNode.asDecimalOpt.

Method similar to asDecimal(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

Annotations
@Override
asDoubleback to summary
public double asDouble()

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Doc from tools.jackson.databind.JsonNode.asDouble.

Method similar to doubleValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0d)
  • POJO nodes that contain Number values

Annotations
@Override
asDoubleback to summary
public double asDouble(double defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Doc from tools.jackson.databind.JsonNode.asDouble.

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

Annotations
@Override
asDoubleOptback to summary
public OptionalDouble asDoubleOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDoubleOpt.

Doc from tools.jackson.databind.JsonNode.asDoubleOpt.

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

Annotations
@Override
asFloatback to summary
public float asFloat()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Doc from tools.jackson.databind.JsonNode.asFloat.

Method similar to floatValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0f)
  • POJO nodes that contain Number values

Annotations
@Override
asFloatback to summary
public float asFloat(float defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Doc from tools.jackson.databind.JsonNode.asFloat.

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

Annotations
@Override
asFloatOptback to summary
public Optional<Float> asFloatOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloatOpt.

Doc from tools.jackson.databind.JsonNode.asFloatOpt.

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

Annotations
@Override
asIntback to summary
public int asInt()

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Doc from tools.jackson.databind.JsonNode.asInt.

Method similar to intValue() but in addition to coercing Number values (same as intValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asIntback to summary
public int asInt(int defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Doc from tools.jackson.databind.JsonNode.asInt.

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to int.

Annotations
@Override
asIntOptback to summary
public OptionalInt asIntOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asIntOpt.

Doc from tools.jackson.databind.JsonNode.asIntOpt.

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

Annotations
@Override
asLongback to summary
public long asLong()

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Doc from tools.jackson.databind.JsonNode.asLong.

Method similar to longValue() but in addition to coercing Number values (same as longValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asLongback to summary
public long asLong(long defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Doc from tools.jackson.databind.JsonNode.asLong.

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

Annotations
@Override
asLongOptback to summary
public OptionalLong asLongOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asLongOpt.

Doc from tools.jackson.databind.JsonNode.asLongOpt.

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

Annotations
@Override
asShortback to summary
public short asShort()

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Doc from tools.jackson.databind.JsonNode.asShort.

Method similar to shortValue() but in addition to coercing Number values (same as shortValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asShortback to summary
public short asShort(short defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Doc from tools.jackson.databind.JsonNode.asShort.

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to short.

Annotations
@Override
asShortOptback to summary
public Optional<Short> asShortOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asShortOpt.

Doc from tools.jackson.databind.JsonNode.asShortOpt.

Method similar to asShort(), but that will return (Optional.empty()) if this node cannot be coerced to short.

Annotations
@Override
asStringback to summary
public String asString()

Overrides tools.jackson.databind.node.BaseJsonNode.asString.

Doc from tools.jackson.databind.JsonNode.asString.

Method that will try to convert value of this node to a String. JSON Strings map naturally; other scalars map to their string representation (including Binary data as Base64 encoded String); JSON nulls map to empty String. Other values (including structured types like Objects and Arrays, and "missing" value) will result in a JsonNodeException being thrown.

Note

this is NOT same as toString() in that result is

NOT VALID ENCODED JSON

for all nodes (although is for some, like NumberNodes and BooleanNodes).
Annotations
@Override
asStringback to summary
public String asString(String defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asString.

Doc from tools.jackson.databind.JsonNode.asString.

Similar to asString(), but instead of throwing an exception for non-coercible values, will return specified default value.

Annotations
@Override
asStringOptback to summary
public Optional<String> asStringOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asStringOpt.

Doc from tools.jackson.databind.JsonNode.asStringOpt.

Similar to asString(), but instead of throwing an exception for non-coercible values, will return Optional.empty().

Annotations
@Override
asTokenback to summary
public JsonToken asToken()

Implements abstract tools.jackson.databind.node.ValueNode.asToken.

Implements tools.jackson.core.TreeNode.asToken.

Doc from tools.jackson.databind.node.BaseJsonNode.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)

Annotations
@Override
binaryValueback to summary
public byte[] binaryValue() throws JacksonException

Overrides tools.jackson.databind.node.BaseJsonNode.binaryValue.

Doc from tools.jackson.databind.JsonNode.binaryValue.

Method that will try to access value of this node as binary value (Java byte[]) which works if (and only if) node contains binary value (for JSON, Base64-encoded String, for other formats native binary value): if not, a JsonNodeException will be thrown. To check if this method can be used, you may call isBinary().

Annotations
@Override
deepCopyback to summary
public StringNode deepCopy()

Overrides tools.jackson.databind.node.ValueNode.deepCopy.

Doc from tools.jackson.databind.node.ValueNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Implements abstract tools.jackson.databind.JsonNode.equals.

Doc from tools.jackson.databind.JsonNode.equals.

Equality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.

Note

marked as abstract to ensure all implementation classes define it properly and not rely on definition from java.lang.Object.

Annotations
@Override
getBinaryValueback to summary
public byte[] getBinaryValue(Base64Variant b64variant) throws JacksonException

Method for accessing content String assuming they were base64 encoded; if so, content is decoded and resulting binary data is returned.

Annotations
@SuppressWarnings:resource
Exceptions
JsonNodeException:
if String contents are not valid Base64 encoded content
getNodeTypeback to summary
public JsonNodeType getNodeType()

Implements abstract tools.jackson.databind.JsonNode.getNodeType.

Doc from tools.jackson.databind.JsonNode.getNodeType.

Return the type of this node

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract tools.jackson.databind.node.BaseJsonNode.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
serializeback to summary
public final void serialize(JsonGenerator g, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.node.BaseJsonNode.serialize.

Implements tools.jackson.databind.JacksonSerializable.serialize.

Doc from tools.jackson.databind.node.BaseJsonNode.serialize.

Method called to serialize node instances using given generator.

Annotations
@Override
stringValueback to summary
public String stringValue()

Overrides tools.jackson.databind.node.BaseJsonNode.stringValue.

Doc from tools.jackson.databind.JsonNode.stringValue.

Method that will try to access value of this node as a Java String which works if (and only if) node contains JSON String or null value: if not, a JsonNodeException will be thrown. In case of JSON null, Java null is returned.

Note

for more conversions, use asString() instead.

Note

in Jackson 2.x, this method was named textValue().

Annotations
@Override
stringValueback to summary
public String stringValue(String defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.stringValue.

Doc from tools.jackson.databind.JsonNode.stringValue.

Method similar to stringValue(), but that will return specified defaultValue if this node does not contain a JSON String. This default value case includes JSON null.

Annotations
@Override
stringValueOptback to summary
public Optional<String> stringValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.stringValueOpt.

Doc from tools.jackson.databind.JsonNode.stringValueOpt.

Method similar to stringValue(), but that will return Optional.empty() if this node does not contain a JSON String (NOTE: JSON null is not considered a String here)

Annotations
@Override
valueOfback to summary
public static StringNode valueOf(String v)

Factory method that should be used to construct instances. For some common cases, can reuse canonical instances: currently this is the case for empty Strings, in future possible for others as well. If null is passed, will return null.

Returns:StringNode

Resulting StringNode object, if v is NOT null; null if it is.