Skip to content

Interface Value

Javadoc 27 generates this reference during each site build from the exported packages and the annotation processor. The Java guide shows the API in use.

All Known Implementing Classes:
Value.ArrayValue, Value.FloatValue, Value.IntValue, Value.StringValue
public sealed interface Value permits Value.IntValue, Value.FloatValue, Value.StringValue, Value.ArrayValue
A value that a read produced: a single integer, float or string, or an array of them, which can be nested and ragged (§3.2).

Asking a value for something it is not, such as the integer of a string, is a mistake in the calling code, never an IrisException. It throws IllegalStateException or, for an index out of range, IndexOutOfBoundsException.

Values are equal if they have the same type, shape and leaves, where floats compare as Double.equals(Object) does.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    An array, or a row of a larger array, whose elements stay in place until they are asked for.
    static final record 
    A single float.
    static final record 
    A single integer.
    static final record 
    A single string.
  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    Returns this single number, as a float if it is an integer.
    default long
    Returns this single integer.
    default String
    Returns this single string.
    default Value
    at(int... path)
    Follows indices into this value.
    default int
    Returns the depth: 0 for a single value, and otherwise the levels of nesting.
    default double[]
    Returns a copy of the numbers of this one-dimensional array, integers as floats.
    default Value
    get(int index)
    Gets an element of this array.
    default int[]
    Narrows the integers of this one-dimensional array.
    default long[]
    Returns a copy of the integers of this one-dimensional array.
    default int
    Returns the number of elements of this array.
    default List<String>
    Returns the strings of this one-dimensional array, as an unmodifiable list.
    Returns the type of the leaves.
  • Method Details

    • type

      ValueType type()
      Returns the type of the leaves.
      Returns:
      the type of the leaves
    • depth

      default int depth()
      Returns the depth: 0 for a single value, and otherwise the levels of nesting.
      Returns:
      the depth: 0 for a single value, and otherwise the levels of nesting
    • size

      default int size()
      Returns the number of elements of this array.
      Returns:
      the number of elements of this array
    • get

      default Value get(int index)
      Gets an element of this array.
      Parameters:
      index - the index of the element, counted from 0
      Returns:
      the element
    • at

      default Value at(int... path)
      Follows indices into this value.
      Parameters:
      path - the indices to select in turn
      Returns:
      what they select, or this value if there are none
    • asLong

      default long asLong()
      Returns this single integer.
      Returns:
      this single integer
    • asDouble

      default double asDouble()
      Returns this single number, as a float if it is an integer.
      Returns:
      this single number, as a float if it is an integer
    • asString

      default String asString()
      Returns this single string.
      Returns:
      this single string
    • longs

      default long[] longs()
      Returns a copy of the integers of this one-dimensional array.
      Returns:
      a copy of the integers of this one-dimensional array
    • ints

      default int[] ints()
      Narrows the integers of this one-dimensional array.
      Returns:
      a copy of the integers
      Throws:
      ArithmeticException - if an integer does not fit an int
    • doubles

      default double[] doubles()
      Returns a copy of the numbers of this one-dimensional array, integers as floats.
      Returns:
      a copy of the numbers of this one-dimensional array, integers as floats
    • strings

      default List<String> strings()
      Returns the strings of this one-dimensional array, as an unmodifiable list.
      Returns:
      the strings of this one-dimensional array, as an unmodifiable list