public interface FieldDef
FieldDef objects never stand alone. They are always defined as part of a RecordDef or other complex type. Some FieldDef types allow specification of properties and constraints, such as range constraints on numbers or strings. Additional properties may be assigned to a FieldDef instance in the context of its containing type, such as a default value for a field in a RecordDef.
All supported data types are represented as instances of FieldDef.
Supported types are defined in the enumeration Type
.
Instances are created when defining the fields for a new
Table
.
Each instance has these properties:
Table
, RecordDef
, etc.
Modifier and Type | Interface and Description |
---|---|
static class |
FieldDef.Type |
Modifier and Type | Method and Description |
---|---|
ArrayDef |
asArray()
Casts to ArrayDef.
|
BinaryDef |
asBinary()
Casts to BinaryDef.
|
BooleanDef |
asBoolean()
Casts to BooleanDef.
|
DoubleDef |
asDouble()
Casts to DoubleDef.
|
EnumDef |
asEnum()
Casts to EnumDef.
|
FixedBinaryDef |
asFixedBinary()
Casts to FixedBinaryDef.
|
FloatDef |
asFloat()
Casts to FloatDef.
|
IntegerDef |
asInteger()
Casts to IntegerDef.
|
LongDef |
asLong()
Casts to LongDef.
|
MapDef |
asMap()
Casts to MapDef.
|
RecordDef |
asRecord()
Casts to RecordDef.
|
StringDef |
asString()
Casts to StringDef.
|
FieldDef |
clone()
Perform a deep copy of this FieldDef instance.
|
ArrayValue |
createArray()
Creates an empty ArrayValue if this is an
ArrayDef . |
BinaryValue |
createBinary(byte[] value)
Creates a BinaryValue instance based on the value
if this is a
BinaryDef . |
BooleanValue |
createBoolean(boolean value)
Creates a BooleanValue instance based on the value if this is
a
BooleanDef . |
DoubleValue |
createDouble(double value)
Creates a DoubleValue instance based on the value if this is
a
DoubleDef . |
EnumValue |
createEnum(String value)
Creates an EnumValue instance based on the value if this is
an
EnumDef . |
FixedBinaryValue |
createFixedBinary(byte[] value)
Creates a FixedBinaryValue instance based on the value if this is
a
FixedBinaryDef . |
FloatValue |
createFloat(float value)
Creates a FloatValue instance based on the value if this is
FloatDef . |
IntegerValue |
createInteger(int value)
Creates an IntegerValue instance based on the value if this is
an
IntegerDef . |
LongValue |
createLong(long value)
Creates a LongValue instance based on the value if this is
a
LongDef . |
MapValue |
createMap()
Creates an empty MapValue if this is a
MapDef . |
RecordValue |
createRecord()
Creates an empty RecordValue if this is a
RecordDef . |
StringValue |
createString(String value)
Creates a StringValue instance based on the value if this is
a
StringDef . |
String |
getDescription()
Returns the description of the field.
|
FieldDef.Type |
getType()
Returns the type of the field.
|
boolean |
isArray()
Returns true if this is an
ArrayDef . |
boolean |
isBinary()
Returns true if this is a
BinaryDef . |
boolean |
isBoolean()
Returns true if this is a
BooleanDef . |
boolean |
isDouble()
Returns true if this is a
DoubleDef . |
boolean |
isEnum()
Returns true if this is an
EnumDef . |
boolean |
isFixedBinary()
Returns true if this is a
FixedBinaryDef . |
boolean |
isFloat()
Returns true if this is a
FloatDef . |
boolean |
isInteger()
Returns true if this is an
IntegerDef . |
boolean |
isLong()
Returns true if this is a
LongDef . |
boolean |
isMap()
Returns true if this is a
MapDef . |
boolean |
isRecord()
Returns true if this is a
RecordDef . |
boolean |
isString()
Returns true if this is a
StringDef . |
boolean |
isType(FieldDef.Type type)
Returns true if the type of this field matches the parameter.
|
boolean |
isValidIndexField() |
boolean |
isValidKeyField() |
String getDescription()
FieldDef.Type getType()
boolean isType(FieldDef.Type type)
ArrayValue createArray()
ArrayDef
.ClassCastException
- if this is not an ArrayDef objectBinaryValue createBinary(byte[] value)
BinaryDef
.value
- the byte array to use for the new value object. Must not
be null.ClassCastException
- if this is not a BinaryDefIllegalArgumentException
- if the value is nullBooleanValue createBoolean(boolean value)
BooleanDef
.value
- the value to useClassCastException
- if this is not a BooleanDefDoubleValue createDouble(double value)
DoubleDef
.value
- the value to useClassCastException
- if this is not a DoubleDefIllegalArgumentException
- if the value is not valid for
the definitionEnumValue createEnum(String value)
EnumDef
.value
- the value to useClassCastException
- if this is not an EnumDefIllegalArgumentException
- if the value is not valid for
the definitionFixedBinaryValue createFixedBinary(byte[] value)
FixedBinaryDef
.value
- the value to use. It must not be null.ClassCastException
- if this is not a FixedBinaryDefIllegalArgumentException
- if the value is null or not
valid for the definitionFloatValue createFloat(float value)
FloatDef
.value
- the value to useClassCastException
- if this is not a FloatDefIllegalArgumentException
- if the value is not valid for
the definitionIntegerValue createInteger(int value)
IntegerDef
.value
- the value to useClassCastException
- if this is not an IntegerDefIllegalArgumentException
- if the value is not valid for
the definitionLongValue createLong(long value)
LongDef
.value
- the value to useClassCastException
- if this is not a LongDefIllegalArgumentException
- if the value is not valid for
the definitionMapValue createMap()
MapDef
.ClassCastException
- if this is not a MapDefRecordValue createRecord()
RecordDef
.ClassCastException
- if this is not a RecordDefStringValue createString(String value)
StringDef
.value
- the value to useClassCastException
- if this is not a StringDefIllegalArgumentException
- if the value is not valid for
the definition or it is nullboolean isValidKeyField()
boolean isValidIndexField()
boolean isBoolean()
BooleanDef
.boolean isBinary()
BinaryDef
.boolean isDouble()
DoubleDef
.boolean isEnum()
EnumDef
.boolean isFixedBinary()
FixedBinaryDef
.boolean isFloat()
FloatDef
.boolean isInteger()
IntegerDef
.boolean isLong()
LongDef
.boolean isString()
StringDef
.boolean isArray()
ArrayDef
.boolean isMap()
MapDef
.boolean isRecord()
RecordDef
.FieldDef clone()
BinaryDef asBinary()
ClassCastException
- if this is not a BinaryDefBooleanDef asBoolean()
ClassCastException
- if this is not a BooleanDefDoubleDef asDouble()
ClassCastException
- if this is not a DoubleDefEnumDef asEnum()
ClassCastException
- if this is not an EnumDefFixedBinaryDef asFixedBinary()
ClassCastException
- if this is not a FixedBinaryDefFloatDef asFloat()
ClassCastException
- if this is not a FloatDefIntegerDef asInteger()
ClassCastException
- if this is not an IntegerDefLongDef asLong()
ClassCastException
- if this is not a LongDefStringDef asString()
ClassCastException
- if this is not a StringDefArrayDef asArray()
ClassCastException
- if this is not an ArrayDefMapDef asMap()
ClassCastException
- if this is not a MapDefRecordDef asRecord()
ClassCastException
- if this is not a RecordDefCopyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.