Package: org.apache.groovy.json.internal

## [Java] Class NumberValue

- org.apache.groovy.json.internal.NumberValue

- All Implemented Interfaces and Traits:
    Value

      public class NumberValue
      extends java.langNumber
      implements Value

  Overlay-backed numeric Value that parses JSON numbers on demand.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `NumberValue(Type type)` Creates an uninitialized numeric wrapper for the supplied token type.
    `NumberValue()` Creates an uninitialized numeric wrapper with no preset token type.
    `NumberValue(boolean chop, Type type, int startIndex, int endIndex, char[] buffer)` Creates a numeric overlay over a character buffer slice.

  - ### 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 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 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
    `<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, int value)` Resolves an enum constant from its ordinal.
    `` | `public String` | `toString()` Returns the current numeric slice as text.
    `` | `public final Object` | `toValue()` Materializes this token as a regular Java value. Returns: the hydrated value

- - ### Constructor Detail

    - #### public NumberValue(Type type)

      Creates an uninitialized numeric wrapper for the supplied token type.

      Parameters:
        `type` - numeric token type

    - #### public NumberValue()

      Creates an uninitialized numeric wrapper with no preset token type.

    - #### public NumberValue(boolean chop, Type type, int startIndex, int endIndex, char[] buffer)

      Creates a numeric overlay over a character buffer slice.

      Parameters:
        `chop` - whether to copy the slice immediately
        `type` - numeric token type
        `startIndex` - slice start
        `endIndex` - slice end
        `buffer` - backing buffer

  - ### 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 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 numeric overlay

    - #### 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 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

    - #### <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, 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 numeric slice as text.

      Returns:
        the raw numeric token text

    - #### public final Object toValue()

      Materializes this token as a regular Java value.

      Returns:
        the hydrated value