Package: org.apache.groovy.json.internal

## [Java] Class CharSequenceValue

- org.apache.groovy.json.internal.CharSequenceValue

- All Implemented Interfaces and Traits:
    Value, CharSequence

      public class CharSequenceValue
      extends Object
      implements Value, CharSequence

  Overlay-backed Value that keeps a character slice until conversion is required.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CharSequenceValue(boolean chop, Type type, int startIndex, int endIndex, char[] buffer, boolean encoded, boolean checkDate)` Retained so that the boolean form of this constructor keeps working.
    `CharSequenceValue(boolean chop, Type type, int startIndex, int endIndex, char[] buffer, boolean encoded, JsonDateHandling dateHandling)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public BigDecimal` | `bigDecimalValue()` * Converts this token to a BigDecimal. * * Returns: the decimal representation
    `` | `public BigInteger` | `bigIntegerValue()` * Converts this token to a BigInteger. * * Returns: the integer representation
    `` | `public boolean` | `booleanValue()` * Converts this token to a boolean value. * * Returns: the boolean representation
    `` | `public byte` | `byteValue()` * Converts this token to a byte value. * * Returns: the byte representation
    `` | `public final char` | `charAt(int index)` Returns the character at the supplied backing-buffer index.
    `` | `public char` | `charValue()` * Converts this token to a single character. * * Returns: the leading character representation
    `` | `public final void` | `chop()` * Copies any shared backing buffer into a dedicated slice.
    `` | `public Date` | `dateValue()` * Converts this token to a Date. * * Returns: the date representation
    `` | `public double` | `doubleValue()` * Converts this token to a double value. * * Returns: the double representation
    `` | `public boolean` | `equals(Object o)` Compares the overlay state and cached value.
    `` | `public float` | `floatValue()` * Converts this token to a float value. * * Returns: the float representation
    `` | `public int` | `hashCode()` Returns a hash code for the overlay state and cached value.
    `` | `public int` | `intValue()` * Converts this token to an int value. * * Returns: the int representation
    `` | `public boolean` | `isContainer()` * Indicates whether this value wraps a map or a collection. * * Returns: `true` for container values
    `` | `public final int` | `length()` Returns the length of the current backing buffer.
    `` | `public long` | `longValue()` * Converts this token to a long value. * * Returns: the long representation
    `` | `public short` | `shortValue()` * Converts this token to a short value. * * Returns: the short representation
    `` | `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 final CharSequence` | `subSequence(int start, int end)` Creates another overlay view over the same backing buffer.
    `<T extends Enum>` | `public T` | `toEnum(Class<T> cls)` * Converts this token to an enum constant. * * Parameters: `cls` - enum type to resolve * Type Parameters: `T` - enum type * Returns: the resolved enum constant
    `<T extends Enum>` | `public static T` | `toEnum(Class<T> cls, String value)` Resolves an enum constant from the decoded token text.
    `<T extends Enum>` | `public static T` | `toEnum(Class<T> cls, int value)` Resolves an enum constant from its ordinal.
    `` | `public String` | `toString()` Returns the current character slice without additional decoding.
    `` | `public final 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`

- - ### Constructor Detail

    - #### @Deprecated
      public CharSequenceValue(boolean chop, Type type, int startIndex, int endIndex, char[] buffer, boolean encoded, boolean checkDate)

      Retained so that the boolean form of this constructor keeps working.

      deprecated:
        use the constructor taking a JsonDateHandling
      Parameters:
        `chop` - whether to eagerly copy the slice out of the buffer
        `type` - token type
        `startIndex` - start index, inclusive
        `endIndex` - end index, exclusive
        `buffer` - buffer holding the token
        `encoded` - whether the token carries escapes
        `checkDate` - whether a date-like string should become a Date

    - #### public CharSequenceValue(boolean chop, Type type, int startIndex, int endIndex, char[] buffer, boolean encoded, JsonDateHandling dateHandling)

  - ### Method Detail

    - #### public BigDecimal bigDecimalValue()

      * Converts this token to a BigDecimal. * *

      Returns:
        the decimal representation

    - #### public BigInteger bigIntegerValue()

      * Converts this token to a BigInteger. * *

      Returns:
        the integer representation

    - #### public boolean booleanValue()

      * Converts this token to a boolean value. * *

      Returns:
        the boolean representation

    - #### public byte byteValue()

      * Converts this token to a byte value. * *

      Returns:
        the byte representation

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

      Returns the character at the supplied backing-buffer index.

      Parameters:
        `index` - backing-buffer index
      Returns:
        the character at `index`

    - #### public char charValue()

      * Converts this token to a single character. * *

      Returns:
        the leading character representation

    - #### public final void chop()

      * Copies any shared backing buffer into a dedicated slice.

    - #### public Date dateValue()

      * Converts this token to a Date. * *

      Returns:
        the date representation

    - #### public double doubleValue()

      * Converts this token to a double value. * *

      Returns:
        the double representation

    - #### public boolean equals(Object o)

      Compares the overlay state and cached value.

      Parameters:
        `o` - other object
      Returns:
        `true` when the overlays match

    - #### public float floatValue()

      * Converts this token to a float value. * *

      Returns:
        the float representation

    - #### public int hashCode()

      Returns a hash code for the overlay state and cached value.

      Returns:
        hash code for this value view

    - #### public int intValue()

      * Converts this token to an int value. * *

      Returns:
        the int representation

    - #### public boolean isContainer()

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

      Returns:
        `true` for container values

    - #### public final int length()

      Returns the length of the current backing buffer.

      Returns:
        backing buffer length

    - #### public long longValue()

      * Converts this token to a long value. * *

      Returns:
        the long representation

    - #### public short shortValue()

      * Converts this token to a short value. * *

      Returns:
        the short representation

    - #### 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 final CharSequence subSequence(int start, int end)

      Creates another overlay view over the same backing buffer.

      Parameters:
        `start` - subsequence start in the backing buffer
        `end` - subsequence end in the backing buffer
      Returns:
        a new overlay view

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

      * Converts this token to an enum constant. * *

      Parameters:
        `cls` - enum type to resolve *
      Type Parameters:
        `T` - enum type *
      Returns:
        the resolved enum constant

    - #### <T extends Enum> public static T toEnum(Class<T> cls, String value)

      Resolves an enum constant from the decoded token text.

      Parameters:
        `cls` - enum type
        `value` - decoded token text
      Type Parameters:
        `T` - enum type
      Returns:
        the matching enum constant

    - #### <T extends Enum> public static T toEnum(Class<T> cls, int value)

      Resolves an enum constant from its ordinal.

      Parameters:
        `cls` - enum type
        `value` - ordinal value
      Type Parameters:
        `T` - enum type
      Returns:
        the matching enum constant

    - #### public String toString()

      Returns the current character slice without additional decoding.

      Returns:
        the raw slice text

    - #### public final Object toValue()

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

      Returns:
        the hydrated value