public class Value extends Object implements Comparable<Value>, Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Value.Type
The recognized types of values
|
Constructor and Description |
---|
Value()
Creates a null value.
|
Value(Boolean booleanValue)
Creates a boolean value.
|
Value(Date date)
Creates a date value.
|
Value(Number number)
Creates a numeric value.
|
Value(String text)
Creates a text value.
|
Value(Throwable error)
Creates an error value.
|
Value(Value[] matrix)
Creates a one-dimensional matrix value (vector).
|
Value(Value[][] matrix)
Creates a two-dimensional matrix value.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Value otherValue)
Compares this value with the given value for order.
|
boolean |
equals(Object other)
Returns whether the other object is an identical value .
|
Value.Type |
getType()
Returns the type of the value.
|
boolean |
isOfType(Value.Type type)
Returns whether the value is of the given type.
|
static Value |
parseBooleanValue(String value)
Attempts to parse a boolean from the given string.
|
static Value |
parseDateValue(String value)
Attempts to parse a date, time or date/time from the given string.
|
static Value |
parseNumericValue(String value)
Attempts to parse a number from the given string.
|
static Value |
parseValue(String value,
Value.Type... types)
Attempts to parse a value from the given string.
|
Object |
toAny()
Returns the value in untyped form.
|
Boolean |
toBoolean()
Returns a boolean representation of the value.
|
Date |
toDate()
Returns a date representation of the value.
|
double |
toDouble()
Returns a primitive numeric representation of the value.
|
Throwable |
toError()
Returns an error representation of the value.
|
Value[][] |
toMatrix()
Returns a matrix representation of the value.
|
Number |
toNumber()
Returns a numeric representation of the value.
|
String |
toString()
Returns a string representation of the value.
|
String |
toString(Format format)
Returns a string representation of the value, using the given date or
number format.
|
String |
toText()
Returns a text representation of the value.
|
public Value()
public Value(Number number)
number
- the number of the valuepublic Value(Boolean booleanValue)
booleanValue
- the boolean of the valuepublic Value(Value[] matrix)
matrix
- the value vectorpublic Value(Value[][] matrix)
matrix
- the value matrixpublic final Value.Type getType()
public final boolean isOfType(Value.Type type)
type
- the type of value to check againstpublic Number toNumber() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic double toDouble() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic String toText() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic Boolean toBoolean() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic Date toDate() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic Value[][] toMatrix() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic Throwable toError() throws IllegalValueTypeException
IllegalValueTypeException
- if the value cannot be converted to this typepublic int compareTo(Value otherValue)
compareTo
in interface Comparable<Value>
otherValue
- the value to compare topublic String toString(Format format)
format
- the format to use when converting the valuepublic static Value parseValue(String value, Value.Type... types)
value
- the valuetypes
- the types for which parsing should be attemptedpublic static Value parseNumericValue(String value) throws ParseException
value
- the valueIllegalValueTypeException
- if no numeric value was foundParseException
public static Value parseBooleanValue(String value) throws ParseException
value
- the valueIllegalValueTypeException
- if no boolean value was foundParseException
public static Value parseDateValue(String value) throws ParseException
value
- the valueIllegalValueTypeException
- if no date value was foundParseException