Package org.apache.groovy.json.internal
Class ValueContainer
java.lang.Object
org.apache.groovy.json.internal.ValueContainer
- All Implemented Interfaces:
CharSequence,Value
Simple
Value wrapper for literals and already-hydrated JSON containers.-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanIndicates whether string values should decode escape sequences when materialized.static final ValueShared wrapper for the JSON literalfalse.static final ValueShared wrapper for the JSON literalnull.static final ValueShared wrapper for the JSON literaltrue.Token type represented by this wrapper.Cached hydrated value, when one already exists. -
Constructor Summary
ConstructorsConstructorDescriptionValueContainer(Object value, Type type, boolean decodeStrings) Creates a wrapper around an already known value and type.ValueContainer(List<Object> list) Creates a wrapper for a parsed array container.ValueContainer(Map<String, Object> map) Creates a wrapper for a parsed object container.ValueContainer(Type type) Creates a wrapper for a scalar token that can be materialized later. -
Method Summary
Modifier and TypeMethodDescriptionReturnsnullbecause this wrapper is not numeric.Returnsnullbecause this wrapper is not numeric.booleanConverts this token to a boolean value.byteReturns0because this wrapper is not numeric.charcharAt(int index) Returns the placeholder character'0'because no character data is available.charReturns0because this wrapper is not backed by character data.voidchop()No-op because this wrapper does not retain a shared parser buffer.Returnsnullbecause this wrapper does not provide date conversion here.doubleReturns0because this wrapper is not numeric.floatReturns0because this wrapper is not numeric.intintValue()Unsupported for these literal and container wrappers.booleanIndicates whether this value wraps a map or a collection.intlength()Returns0because this wrapper does not expose a character sequence.longUnsupported for these literal and container wrappers.shortReturns0because this wrapper is not numeric.Returns the string form using the value's configured decoding policy.Returns the fully decoded string form.subSequence(int start, int end) Returns an empty character sequence because this wrapper has no character backing.<T extends Enum>
TReturns the cached enum instance stored in this wrapper.toString()Returns the token name for this wrapper.toValue()Materializes this token as a regular Java value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Field Details
-
TRUE
Shared wrapper for the JSON literaltrue. -
FALSE
Shared wrapper for the JSON literalfalse. -
NULL
Shared wrapper for the JSON literalnull. -
value
Cached hydrated value, when one already exists. -
type
Token type represented by this wrapper. -
decodeStrings
public boolean decodeStringsIndicates whether string values should decode escape sequences when materialized.
-
-
Constructor Details
-
ValueContainer
Creates a wrapper around an already known value and type.- Parameters:
value- cached valuetype- token typedecodeStrings- whether string decoding should be applied
-
ValueContainer
Creates a wrapper for a scalar token that can be materialized later.- Parameters:
type- token type
-
ValueContainer
Creates a wrapper for a parsed object container.- Parameters:
map- hydrated object value
-
ValueContainer
Creates a wrapper for a parsed array container.- Parameters:
list- hydrated array value
-
-
Method Details
-
intValue
public int intValue()Unsupported for these literal and container wrappers. -
longValue
public long longValue()Unsupported for these literal and container wrappers. -
booleanValue
public boolean booleanValue()Converts this token to a boolean value.- Specified by:
booleanValuein interfaceValue- Returns:
- the boolean representation
-
stringValue
Returns the string form using the value's configured decoding policy.- Specified by:
stringValuein interfaceValue- Returns:
- the string representation
-
stringValueEncoded
Returns the fully decoded string form.- Specified by:
stringValueEncodedin interfaceValue- Returns:
- the decoded string representation
-
toString
Returns the token name for this wrapper.- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject- Returns:
- the type name
-
toValue
Materializes this token as a regular Java value. -
toEnum
Returns the cached enum instance stored in this wrapper. -
isContainer
public boolean isContainer()Indicates whether this value wraps a map or a collection.- Specified by:
isContainerin interfaceValue- Returns:
truefor container values
-
chop
public void chop()No-op because this wrapper does not retain a shared parser buffer. -
charValue
public char charValue()Returns0because this wrapper is not backed by character data. -
length
public int length()Returns0because this wrapper does not expose a character sequence.- Specified by:
lengthin interfaceCharSequence- Returns:
0
-
charAt
public char charAt(int index) Returns the placeholder character'0'because no character data is available.- Specified by:
charAtin interfaceCharSequence- Parameters:
index- ignored- Returns:
'0'
-
subSequence
Returns an empty character sequence because this wrapper has no character backing.- Specified by:
subSequencein interfaceCharSequence- Parameters:
start- ignoredend- ignored- Returns:
- an empty sequence
-
dateValue
Returnsnullbecause this wrapper does not provide date conversion here. -
byteValue
public byte byteValue()Returns0because this wrapper is not numeric. -
shortValue
public short shortValue()Returns0because this wrapper is not numeric.- Specified by:
shortValuein interfaceValue- Returns:
0
-
bigDecimalValue
Returnsnullbecause this wrapper is not numeric.- Specified by:
bigDecimalValuein interfaceValue- Returns:
null
-
bigIntegerValue
Returnsnullbecause this wrapper is not numeric.- Specified by:
bigIntegerValuein interfaceValue- Returns:
null
-
doubleValue
public double doubleValue()Returns0because this wrapper is not numeric.- Specified by:
doubleValuein interfaceValue- Returns:
0
-
floatValue
public float floatValue()Returns0because this wrapper is not numeric.- Specified by:
floatValuein interfaceValue- Returns:
0
-