Interface FieldValue
-
- All Superinterfaces:
Comparable<FieldValue>
- All Known Subinterfaces:
ArrayValue
,BinaryValue
,BooleanValue
,DoubleValue
,EnumValue
,FixedBinaryValue
,FloatValue
,IndexKey
,IntegerValue
,LongValue
,MapValue
,NumberValue
,PrimaryKey
,RecordValue
,ReturnRow
,Row
,StringValue
,TimestampValue
public interface FieldValue extends Comparable<FieldValue>
FieldValue represents an item, that is, a value and its associated type. Values can be atomic or complex. An atomic value is a single, indivisible unit of data. A complex value is a value that contains or consists of other values and provides access to its nested values.FieldValue is the building block of row values in a table.
The FieldValue interface defines casting and interrogation methods common to all implementing classes. Each implementing type has its own interface which is an extension of FieldValue. In most cases interfaces that extend FieldValue have corresponding classes that extend
FieldDef
. The exceptions areRow
,PrimaryKey
andIndexKey
. These all extendRecordValue
as they are specialized instances of records.By default fields can be nullable, which means that a special null value can be assigned to them. A null value is a FieldValue instance that returns true for
isNull()
and will throw exceptions for most other operations that require an actual instance of a type. This means that callers who might reasonably expect a null value should first check to see if the value is null before using the value.FieldValue instances are not thread safe.
- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ArrayValue
asArray()
Casts to ArrayValue.BinaryValue
asBinary()
Casts to BinaryValue.BooleanValue
asBoolean()
Casts to BooleanValue.DoubleValue
asDouble()
Casts to DoubleValue.EnumValue
asEnum()
Casts to EnumValue.FixedBinaryValue
asFixedBinary()
Casts to FixedBinaryValue.FloatValue
asFloat()
Casts to FloatValue.IndexKey
asIndexKey()
Casts to IndexKey.IntegerValue
asInteger()
Casts to IntegerValue.LongValue
asLong()
Casts to LongValue.MapValue
asMap()
Casts to MapValue.NumberValue
asNumber()
Casts to NumberValue.PrimaryKey
asPrimaryKey()
Casts to PrimaryKey.RecordValue
asRecord()
Casts to RecordValue.Row
asRow()
Casts to Row.StringValue
asString()
Casts to StringValue.TimestampValue
asTimestamp()
Casts to TimestampValue.FieldValue
clone()
Create a deep copy of this object.FieldDef
getDefinition()
Returns the type associated with this value.FieldDef.Type
getType()
Returns the kind of the type associated with this value.boolean
isArray()
Returns true if this is anArrayValue
.boolean
isAtomic()
Returns true if this is an atomic value.boolean
isBinary()
Returns true if this is aBinaryValue
.boolean
isBoolean()
Returns true if this is aBooleanValue
.boolean
isComplex()
Returns true if this is a complex value.boolean
isDouble()
Returns true if this is aDoubleValue
.boolean
isEMPTY()
Returns true if this is an EMPTY value instance.boolean
isEnum()
Returns true if this is anEnumValue
.boolean
isFixedBinary()
Returns true if this is aFixedBinaryValue
.boolean
isFloat()
Returns true if this is aFloatValue
.boolean
isIndexKey()
Returns true if this is anIndexKey
.boolean
isInteger()
Returns true if this is anIntegerValue
.boolean
isJsonNull()
Returns true if this is a null value in a JSON field.boolean
isLong()
Returns true if this is aLongValue
.boolean
isMap()
Returns true if this is aMapValue
.boolean
isNull()
Returns true if this is a null value instance.boolean
isNumber()
Returns true if this is aNumberValue
.boolean
isNumeric()
Returns true if this is numeric value.boolean
isPrimaryKey()
Returns true if this is aPrimaryKey
.boolean
isRecord()
Returns true if this is aRecordValue
.boolean
isRow()
Returns true if this is aRow
.boolean
isString()
Returns true if this is aStringValue
.boolean
isTimestamp()
Returns true if this is aTimestampValue
.String
toJsonString(boolean prettyPrint)
Create a JSON representation of the value.-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Method Detail
-
clone
FieldValue clone()
Create a deep copy of this object.- Returns:
- a new copy
-
getType
FieldDef.Type getType()
Returns the kind of the type associated with this value. The method will never return any of the "wildcard" types (ANY, ANY_ATOMIC, ANY_RECORD).- Returns:
- the type of this value
- Throws:
UnsupportedOperationException
- if this is the NullValue
-
getDefinition
FieldDef getDefinition()
Returns the type associated with this value.- Returns:
- the FieldDef
- Throws:
UnsupportedOperationException
- if this is the NullValue
-
isBoolean
boolean isBoolean()
Returns true if this is aBooleanValue
.- Returns:
- true if this is a BooleanValue, false otherwise
-
isBinary
boolean isBinary()
Returns true if this is aBinaryValue
.- Returns:
- true if this is a BinaryValue, false otherwise
-
isDouble
boolean isDouble()
Returns true if this is aDoubleValue
.- Returns:
- true if this is a DoubleValue, false otherwise
-
isEnum
boolean isEnum()
Returns true if this is anEnumValue
.- Returns:
- true if this is an EnumValue, false otherwise
-
isFixedBinary
boolean isFixedBinary()
Returns true if this is aFixedBinaryValue
.- Returns:
- true if this is a FixedBinaryValue, false otherwise
-
isFloat
boolean isFloat()
Returns true if this is aFloatValue
.- Returns:
- true if this is a FloatValue, false otherwise
-
isInteger
boolean isInteger()
Returns true if this is anIntegerValue
.- Returns:
- true if this is an IntegerValue, false otherwise
-
isLong
boolean isLong()
Returns true if this is aLongValue
.- Returns:
- true if this is a LongValue, false otherwise
-
isNumber
boolean isNumber()
Returns true if this is aNumberValue
.- Returns:
- true if this is a NumberValue, false otherwise
- Since:
- 4.4
-
isString
boolean isString()
Returns true if this is aStringValue
.- Returns:
- true if this is a StringValue, false otherwise
-
isTimestamp
boolean isTimestamp()
Returns true if this is aTimestampValue
.- Returns:
- true if this is a TimestampValue, false otherwise
- Since:
- 4.3
-
isArray
boolean isArray()
Returns true if this is anArrayValue
.- Returns:
- true if this is an ArrayValue, false otherwise
-
isMap
boolean isMap()
Returns true if this is aMapValue
.- Returns:
- true if this is a MapValue, false otherwise
-
isRecord
boolean isRecord()
Returns true if this is aRecordValue
.- Returns:
- true if this is a RecordValue, false otherwise
-
isRow
boolean isRow()
Returns true if this is aRow
. Row also returns true forisRecord()
.- Returns:
- true if this is a Row}, false otherwise
-
isPrimaryKey
boolean isPrimaryKey()
- Returns:
- true if this is a PrimaryKey}, false otherwise
-
isIndexKey
boolean isIndexKey()
Returns true if this is anIndexKey
. IndexKey also returns true forisRecord()
.- Returns:
- true if this is an IndexKey}, false otherwise
-
isJsonNull
boolean isJsonNull()
Returns true if this is a null value in a JSON field. This is different from a null that is assigned in the absence of a value in a nullable field, as indicated byisNull()
.- Returns:
- true if this is a JSON null value, false otherwise.
- Since:
- 4.2
-
isNull
boolean isNull()
Returns true if this is a null value instance.- Returns:
- true if this is a null value, false otherwise.
-
isEMPTY
boolean isEMPTY()
Returns true if this is an EMPTY value instance.An EMPTY value is used internally to represent cases where an expression returns an empty result. Applications do not normally have to deal with EMPTY values. The only exception is in IndexKey instances: when a TableIterator is used to scan an index and return index keys, the EMPTY value may appear in the returned IndexKey instances. This method can be used to check if the value of an IndexKey field is EMPTY. Applications may also use the
IndexKey.putEMPTY(int)
orIndexKey.putEMPTY(String)
method to search an index for entries containing the EMPTY value in one or more of their fields.- Returns:
- true if this is an EMPTY value, false otherwise.
- Since:
- 4.4
-
isAtomic
boolean isAtomic()
Returns true if this is an atomic value.- Returns:
- true if this is an atomic value, false otherwise
- Since:
- 4.0
-
isNumeric
boolean isNumeric()
Returns true if this is numeric value.- Returns:
- true if this is a numeric value, false otherwise
- Since:
- 4.0
-
isComplex
boolean isComplex()
Returns true if this is a complex value.- Returns:
- true if this is a complex value, false otherwise
- Since:
- 4.0
-
asBinary
BinaryValue asBinary()
Casts to BinaryValue.- Returns:
- a BinaryValue
- Throws:
ClassCastException
- if this is not a BinaryValue
-
asNumber
NumberValue asNumber()
Casts to NumberValue.- Returns:
- a NumberValue
- Throws:
ClassCastException
- if this is not a NumberValue- Since:
- 4.4
-
asBoolean
BooleanValue asBoolean()
Casts to BooleanValue.- Returns:
- a BooleanValue
- Throws:
ClassCastException
- if this is not a BooleanValue
-
asDouble
DoubleValue asDouble()
Casts to DoubleValue.- Returns:
- a DoubleValue
- Throws:
ClassCastException
- if this is not a DoubleValue
-
asEnum
EnumValue asEnum()
Casts to EnumValue.- Returns:
- an EnumValue
- Throws:
ClassCastException
- if this is not an EnumValue
-
asFixedBinary
FixedBinaryValue asFixedBinary()
Casts to FixedBinaryValue.- Returns:
- a FixedBinaryValue
- Throws:
ClassCastException
- if this is not a FixedBinaryValue
-
asFloat
FloatValue asFloat()
Casts to FloatValue.- Returns:
- a FloatValue
- Throws:
ClassCastException
- if this is not a FloatValue
-
asInteger
IntegerValue asInteger()
Casts to IntegerValue.- Returns:
- an IntegerValue
- Throws:
ClassCastException
- if this is not an IntegerValue
-
asLong
LongValue asLong()
Casts to LongValue.- Returns:
- a LongValue
- Throws:
ClassCastException
- if this is not a LongValue
-
asString
StringValue asString()
Casts to StringValue.- Returns:
- a StringValue
- Throws:
ClassCastException
- if this is not a StringValue
-
asTimestamp
TimestampValue asTimestamp()
Casts to TimestampValue.- Returns:
- a TimestampValue
- Throws:
ClassCastException
- if this is not a TimestampValue- Since:
- 4.3
-
asArray
ArrayValue asArray()
Casts to ArrayValue.- Returns:
- an ArrayValue
- Throws:
ClassCastException
- if this is not an ArrayValue
-
asMap
MapValue asMap()
Casts to MapValue.- Returns:
- a MapValue
- Throws:
ClassCastException
- if this is not a MapValue
-
asRecord
RecordValue asRecord()
Casts to RecordValue.- Returns:
- a RecordValue
- Throws:
ClassCastException
- if this is not a RecordValue
-
asRow
Row asRow()
Casts to Row.- Returns:
- a Row
- Throws:
ClassCastException
- if this is not a Row.
-
asPrimaryKey
PrimaryKey asPrimaryKey()
Casts to PrimaryKey.- Returns:
- a PrimaryKey
- Throws:
ClassCastException
- if this is not a PrimaryKey
-
asIndexKey
IndexKey asIndexKey()
Casts to IndexKey.- Returns:
- an IndexKey
- Throws:
ClassCastException
- if this is not an IndexKey
-
toJsonString
String toJsonString(boolean prettyPrint)
Create a JSON representation of the value.- Parameters:
prettyPrint
- set to true for a nicely formatted JSON string, with indentation and carriage returns, otherwise the string will be a single line- Returns:
- a JSON representation of the value
-
-