Package: org.apache.groovy.json.internal

## [Java] Class ValueContainer

- org.apache.groovy.json.internal.ValueContainer

- All Implemented Interfaces and Traits:
    CharSequence, Value

      public class ValueContainer
      extends Object
      implements CharSequence, Value

  Simple Value wrapper for literals and already-hydrated JSON containers.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static Value` | `FALSE` | Shared wrapper for the JSON literal `false`.
    `static Value` | `NULL` | Shared wrapper for the JSON literal `null`.
    `static Value` | `TRUE` | Shared wrapper for the JSON literal `true`.
    `boolean` | `decodeStrings` | Indicates whether string values should decode escape sequences when materialized.
    `Type` | `type` | Token type represented by this wrapper.
    `Object` | `value` | Cached hydrated value, when one already exists.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ValueContainer(Object value, Type type, boolean decodeStrings)` Creates a wrapper around an already known value and type.
    `ValueContainer(Type type)` Creates a wrapper for a scalar token that can be materialized later.
    `ValueContainer(Map<String, Object> map)` Creates a wrapper for a parsed object container.
    `ValueContainer(List<Object> list)` Creates a wrapper for a parsed array container.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public BigDecimal` | `bigDecimalValue()` Returns `null` because this wrapper is not numeric.
    `` | `public BigInteger` | `bigIntegerValue()` Returns `null` because this wrapper is not numeric.
    `` | `public boolean` | `booleanValue()` * Converts this token to a boolean value. * * Returns: the boolean representation
    `` | `public byte` | `byteValue()` Returns `0` because this wrapper is not numeric.
    `` | `public char` | `charAt(int index)` Returns the placeholder character `'0'` because no character data is available.
    `` | `public char` | `charValue()` Returns `0` because this wrapper is not backed by character data.
    `` | `public void` | `chop()` No-op because this wrapper does not retain a shared parser buffer.
    `` | `public Date` | `dateValue()` Returns `null` because this wrapper does not provide date conversion here.
    `` | `public double` | `doubleValue()` Returns `0` because this wrapper is not numeric.
    `` | `public float` | `floatValue()` Returns `0` because this wrapper is not numeric.
    `` | `public int` | `intValue()` Unsupported for these literal and container wrappers.
    `` | `public boolean` | `isContainer()` * Indicates whether this value wraps a map or a collection. * * Returns: `true` for container values
    `` | `public int` | `length()` Returns `0` because this wrapper does not expose a character sequence.
    `` | `public long` | `longValue()` Unsupported for these literal and container wrappers.
    `` | `public short` | `shortValue()` Returns `0` because this wrapper is not numeric.
    `` | `public String` | `stringValue()` * Returns the string form using the value's configured decoding policy. * * Returns: the string representation
    `` | `public String` | `stringValueEncoded()` * Returns the fully decoded string form. * * Returns: the decoded string representation
    `` | `public CharSequence` | `subSequence(int start, int end)` Returns an empty character sequence because this wrapper has no character backing.
    `<T extends Enum>` | `public T` | `toEnum(Class<T> cls)` Returns the cached enum instance stored in this wrapper.
    `` | `public String` | `toString()` Returns the token name for this wrapper.
    `` | `public Object` | `toValue()` * Materializes this token as a regular Java value. * * Returns: the hydrated value

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final Value FALSE

      Shared wrapper for the JSON literal `false`.

    - #### public static final Value NULL

      Shared wrapper for the JSON literal `null`.

    - #### public static final Value TRUE

      Shared wrapper for the JSON literal `true`.

    - #### public boolean decodeStrings

      Indicates whether string values should decode escape sequences when materialized.

    - #### public Type type

      Token type represented by this wrapper.

    - #### public Object value

      Cached hydrated value, when one already exists.

  - ### Constructor Detail

    - #### public ValueContainer(Object value, Type type, boolean decodeStrings)

      Creates a wrapper around an already known value and type.

      Parameters:
        `value` - cached value
        `type` - token type
        `decodeStrings` - whether string decoding should be applied

    - #### public ValueContainer(Type type)

      Creates a wrapper for a scalar token that can be materialized later.

      Parameters:
        `type` - token type

    - #### public ValueContainer(Map<String, Object> map)

      Creates a wrapper for a parsed object container.

      Parameters:
        `map` - hydrated object value

    - #### public ValueContainer(List<Object> list)

      Creates a wrapper for a parsed array container.

      Parameters:
        `list` - hydrated array value

  - ### Method Detail

    - #### public BigDecimal bigDecimalValue()

      Returns `null` because this wrapper is not numeric.

      Returns:
        `null`

    - #### public BigInteger bigIntegerValue()

      Returns `null` because this wrapper is not numeric.

      Returns:
        `null`

    - #### public boolean booleanValue()

      * Converts this token to a boolean value. * *

      Returns:
        the boolean representation

    - #### public byte byteValue()

      Returns `0` because this wrapper is not numeric.

      Returns:
        `0`

    - #### public char charAt(int index)

      Returns the placeholder character `'0'` because no character data is available.

      Parameters:
        `index` - ignored
      Returns:
        `'0'`

    - #### public char charValue()

      Returns `0` because this wrapper is not backed by character data.

      Returns:
        `0`

    - #### public void chop()

      No-op because this wrapper does not retain a shared parser buffer.

    - #### public Date dateValue()

      Returns `null` because this wrapper does not provide date conversion here.

      Returns:
        `null`

    - #### public double doubleValue()

      Returns `0` because this wrapper is not numeric.

      Returns:
        `0`

    - #### public float floatValue()

      Returns `0` because this wrapper is not numeric.

      Returns:
        `0`

    - #### public int intValue()

      Unsupported for these literal and container wrappers.

      Returns:
        never returns normally

    - #### public boolean isContainer()

      * Indicates whether this value wraps a map or a collection. * *

      Returns:
        `true` for container values

    - #### public int length()

      Returns `0` because this wrapper does not expose a character sequence.

      Returns:
        `0`

    - #### public long longValue()

      Unsupported for these literal and container wrappers.

      Returns:
        never returns normally

    - #### public short shortValue()

      Returns `0` because this wrapper is not numeric.

      Returns:
        `0`

    - #### public String stringValue()

      * Returns the string form using the value's configured decoding policy. * *

      Returns:
        the string representation

    - #### public String stringValueEncoded()

      * Returns the fully decoded string form. * *

      Returns:
        the decoded string representation

    - #### public CharSequence subSequence(int start, int end)

      Returns an empty character sequence because this wrapper has no character backing.

      Parameters:
        `start` - ignored
        `end` - ignored
      Returns:
        an empty sequence

    - #### <T extends Enum> public T toEnum(Class<T> cls)

      Returns the cached enum instance stored in this wrapper.

      Parameters:
        `cls` - enum type
      Type Parameters:
        `T` - enum type
      Returns:
        the cached enum value

    - #### public String toString()

      Returns the token name for this wrapper.

      Returns:
        the type name

    - #### public Object toValue()

      * Materializes this token as a regular Java value. * *

      Returns:
        the hydrated value