oracle.kv.table

## Interface FieldDef

- All Known Subinterfaces:
    ArrayDef, BinaryDef, BooleanDef, DoubleDef, EnumDef, FixedBinaryDef, FloatDef, IntegerDef, LongDef, MapDef, RecordDef, StringDef

      public interface FieldDef

  FieldDef represents an immutable metadata object used to represent a single data type. Data types are either simple, represented by a single value, or complex types which can have more than one value and may also be nested.

  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:

  - type -- the type of the field
  - description -- an optional description used when defining the field
  FieldDefs are used to define the fields for other complex datatypes such as `Table`, `RecordDef`, etc.

  Since:
    3.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `FieldDef.Type`

  - ### Method Summary

    Methods
    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()`

- - ### Method Detail

    - #### getDescription

          String getDescription()

      Returns the description of the field.
      Returns:
        the description of the field if set, otherwise null

    - #### getType

          FieldDef.Type getType()

      Returns the type of the field.
      Returns:
        the type of the field

    - #### isType

          boolean isType(FieldDef.Type type)

      Returns true if the type of this field matches the parameter.
      Returns:
        true if the type of this field matches the parameter

    - #### createArray

          ArrayValue createArray()

      Creates an empty ArrayValue if this is an `ArrayDef`.
      Returns:
        an empty ArrayValue
      Throws:
        `ClassCastException` - if this is not an ArrayDef object

    - #### createBinary

          BinaryValue createBinary(byte[] value)

      Creates a BinaryValue instance based on the value if this is a `BinaryDef`.
      Parameters:
        `value` - the byte array to use for the new value object. Must not be null.
      Returns:
        a BinaryValue
      Throws:
        `ClassCastException` - if this is not a BinaryDef
        `IllegalArgumentException` - if the value is null

    - #### createBoolean

          BooleanValue createBoolean(boolean value)

      Creates a BooleanValue instance based on the value if this is a `BooleanDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a BooleanValue
      Throws:
        `ClassCastException` - if this is not a BooleanDef

    - #### createDouble

          DoubleValue createDouble(double value)

      Creates a DoubleValue instance based on the value if this is a `DoubleDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a DoubleValue
      Throws:
        `ClassCastException` - if this is not a DoubleDef
        `IllegalArgumentException` - if the value is not valid for the definition

    - #### createEnum

          EnumValue createEnum(String value)

      Creates an EnumValue instance based on the value if this is an `EnumDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a EnumValue
      Throws:
        `ClassCastException` - if this is not an EnumDef
        `IllegalArgumentException` - if the value is not valid for the definition

    - #### createFixedBinary

          FixedBinaryValue createFixedBinary(byte[] value)

      Creates a FixedBinaryValue instance based on the value if this is a `FixedBinaryDef`.
      Parameters:
        `value` - the value to use. It must not be null.
      Returns:
        a FixedBinaryValue
      Throws:
        `ClassCastException` - if this is not a FixedBinaryDef
        `IllegalArgumentException` - if the value is null or not valid for the definition

    - #### createFloat

          FloatValue createFloat(float value)

      Creates a FloatValue instance based on the value if this is `FloatDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a FloatValue
      Throws:
        `ClassCastException` - if this is not a FloatDef
        `IllegalArgumentException` - if the value is not valid for the definition

    - #### createInteger

          IntegerValue createInteger(int value)

      Creates an IntegerValue instance based on the value if this is an `IntegerDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a IntegerValue
      Throws:
        `ClassCastException` - if this is not an IntegerDef
        `IllegalArgumentException` - if the value is not valid for the definition

    - #### createLong

          LongValue createLong(long value)

      Creates a LongValue instance based on the value if this is a `LongDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a LongValue
      Throws:
        `ClassCastException` - if this is not a LongDef
        `IllegalArgumentException` - if the value is not valid for the definition

    - #### createMap

          MapValue createMap()

      Creates an empty MapValue if this is a `MapDef`.
      Returns:
        an empty MapValue
      Throws:
        `ClassCastException` - if this is not a MapDef

    - #### createRecord

          RecordValue createRecord()

      Creates an empty RecordValue if this is a `RecordDef`.
      Returns:
        an empty RecordValue
      Throws:
        `ClassCastException` - if this is not a RecordDef

    - #### createString

          StringValue createString(String value)

      Creates a StringValue instance based on the value if this is a `StringDef`.
      Parameters:
        `value` - the value to use
      Returns:
        a StringValue
      Throws:
        `ClassCastException` - if this is not a StringDef
        `IllegalArgumentException` - if the value is not valid for the definition or it is null

    - #### isValidKeyField

          boolean isValidKeyField()

      Returns:
        true if this type can participate in a primary key. Only simple, single-valued fields can be part of a key. Boolean is not allowed in keys.

    - #### isValidIndexField

          boolean isValidIndexField()

      Returns:
        true if this type can participate in an index. Only simple, single-valued fields and arrays of simple fields can be part of a key. Boolean is not allowed in indexes.

    - #### isBoolean

          boolean isBoolean()

      Returns true if this is a `BooleanDef`.
      Returns:
        true if this is a BooleanDef, false otherwise

    - #### isBinary

          boolean isBinary()

      Returns true if this is a `BinaryDef`.
      Returns:
        true if this is a BinaryDef, false otherwise

    - #### isDouble

          boolean isDouble()

      Returns true if this is a `DoubleDef`.
      Returns:
        true if this is a DoubleDef, false otherwise

    - #### isEnum

          boolean isEnum()

      Returns true if this is an `EnumDef`.
      Returns:
        true if this is an EnumDef, false otherwise

    - #### isFixedBinary

          boolean isFixedBinary()

      Returns true if this is a `FixedBinaryDef`.
      Returns:
        true if this is a FixedBinaryDef, false otherwise

    - #### isFloat

          boolean isFloat()

      Returns true if this is a `FloatDef`.
      Returns:
        true if this is a FloatDef, false otherwise

    - #### isInteger

          boolean isInteger()

      Returns true if this is an `IntegerDef`.
      Returns:
        true if this is an IntegerDef, false otherwise

    - #### isLong

          boolean isLong()

      Returns true if this is a `LongDef`.
      Returns:
        true if this is a LongDef, false otherwise

    - #### isString

          boolean isString()

      Returns true if this is a `StringDef`.
      Returns:
        true if this is a StringDef, false otherwise

    - #### isArray

          boolean isArray()

      Returns true if this is an `ArrayDef`.
      Returns:
        true if this is an ArrayDef, false otherwise

    - #### isMap

          boolean isMap()

      Returns true if this is a `MapDef`.
      Returns:
        true if this is a MapDef, false otherwise

    - #### isRecord

          boolean isRecord()

      Returns true if this is a `RecordDef`.
      Returns:
        true if this is a RecordDef, false otherwise

    - #### clone

          FieldDef clone()

      Perform a deep copy of this FieldDef instance.
      Returns:
        a new instance equal to this

    - #### asBinary

          BinaryDef asBinary()

      Casts to BinaryDef.
      Returns:
        a BinaryDef
      Throws:
        `ClassCastException` - if this is not a BinaryDef

    - #### asBoolean

          BooleanDef asBoolean()

      Casts to BooleanDef.
      Returns:
        a BooleanDef
      Throws:
        `ClassCastException` - if this is not a BooleanDef

    - #### asDouble

          DoubleDef asDouble()

      Casts to DoubleDef.
      Returns:
        a DoubleDef
      Throws:
        `ClassCastException` - if this is not a DoubleDef

    - #### asEnum

          EnumDef asEnum()

      Casts to EnumDef.
      Returns:
        an EnumDef
      Throws:
        `ClassCastException` - if this is not an EnumDef

    - #### asFixedBinary

          FixedBinaryDef asFixedBinary()

      Casts to FixedBinaryDef.
      Returns:
        a FixedBinaryDef
      Throws:
        `ClassCastException` - if this is not a FixedBinaryDef

    - #### asFloat

          FloatDef asFloat()

      Casts to FloatDef.
      Returns:
        a FloatDef
      Throws:
        `ClassCastException` - if this is not a FloatDef

    - #### asInteger

          IntegerDef asInteger()

      Casts to IntegerDef.
      Returns:
        an IntegerDef
      Throws:
        `ClassCastException` - if this is not an IntegerDef

    - #### asLong

          LongDef asLong()

      Casts to LongDef.
      Returns:
        a LongDef
      Throws:
        `ClassCastException` - if this is not a LongDef

    - #### asString

          StringDef asString()

      Casts to StringDef.
      Returns:
        a StringDef
      Throws:
        `ClassCastException` - if this is not a StringDef

    - #### asArray

          ArrayDef asArray()

      Casts to ArrayDef.
      Returns:
        an ArrayDef
      Throws:
        `ClassCastException` - if this is not an ArrayDef

    - #### asMap

          MapDef asMap()

      Casts to MapDef.
      Returns:
        a MapDef
      Throws:
        `ClassCastException` - if this is not a MapDef

    - #### asRecord

          RecordDef asRecord()

      Casts to RecordDef.
      Returns:
        a RecordDef
      Throws:
        `ClassCastException` - if this is not a RecordDef

Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.