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 ClassesModifier and TypeInterfaceDescriptionstatic final classAn array, or a row of a larger array, whose elements stay in place until they are asked for.static final recordA single float.static final recordA single integer.static final recordA single string. -
Method Summary
Modifier and TypeMethodDescriptiondefault doubleasDouble()Returns this single number, as a float if it is an integer.default longasLong()Returns this single integer.default StringasString()Returns this single string.default Valueat(int... path) Follows indices into this value.default intdepth()Returns the depth: 0 for a single value, and otherwise the levels of nesting.default double[]doubles()Returns a copy of the numbers of this one-dimensional array, integers as floats.default Valueget(int index) Gets an element of this array.default int[]ints()Narrows the integers of this one-dimensional array.default long[]longs()Returns a copy of the integers of this one-dimensional array.default intsize()Returns the number of elements of this array.strings()Returns the strings of this one-dimensional array, as an unmodifiable list.type()Returns the type of the leaves.
-
Method Details
-
type
-
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
Gets an element of this array.- Parameters:
index- the index of the element, counted from 0- Returns:
- the element
-
at
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
-
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 anint
-
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
-