Package db

Class StringField

java.lang.Object
db.Field
db.StringField
All Implemented Interfaces:
Comparable<Field>

public final class StringField extends Field
StringField provides a wrapper for variable length String data which is read or written to a Record. Strings are always encoded as UTF-8.
  • Field Details

    • NULL_VALUE

      public static final StringField NULL_VALUE
      Null string field value
    • INSTANCE

      public static final StringField INSTANCE
      Instance intended for defining a Table Schema
  • Constructor Details

    • StringField

      public StringField()
      Construct a String field with an initial value of null.
    • StringField

      public StringField(String str)
      Construct a String field with an initial value of s.
      Parameters:
      str - initial string value or null
  • Method Details

    • isNull

      public boolean isNull()
      Description copied from class: Field
      Determine if the field has been set to a null-state or value.
      Specified by:
      isNull in class Field
      Returns:
      true if field has been set to a null state or value, else false
    • getString

      public String getString()
      Description copied from class: Field
      Get field as a String value.
      Overrides:
      getString in class Field
      Returns:
      String value
    • setString

      public void setString(String str)
      Description copied from class: Field
      Set field's String value.
      Overrides:
      setString in class Field
      Parameters:
      str - String value
    • isVariableLength

      public boolean isVariableLength()
      Overrides:
      isVariableLength in class Field
      Returns:
      true if a Field instance is variable length, else false.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getValueAsString

      public String getValueAsString()
      Description copied from class: Field
      Get field value as a formatted string
      Specified by:
      getValueAsString in class Field
      Returns:
      field value string
    • equals

      public boolean equals(Object obj)
      Description copied from class: Field
      Determine if the specified Object is another Field which has the same type and value as this Field. When comparing a PrimitiveField, with a null state, a value of zero (0) is used.
      Specified by:
      equals in class Field
      Parameters:
      obj - another object
      Returns:
      true if this field equals obj
    • getBinaryData

      public byte[] getBinaryData()
      Description copied from class: Field
      Get data as a byte array.
      Specified by:
      getBinaryData in class Field
      Returns:
      byte[]
    • setBinaryData

      public void setBinaryData(byte[] bytes)
      Description copied from class: Field
      Set data from binary byte array. All variable-length fields must implement this method.
      Specified by:
      setBinaryData in class Field
      Parameters:
      bytes - field data
    • compareTo

      public int compareTo(Field o)
      Description copied from class: Field
      Compares this Field with another Field for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified Field.
      NOTE: Field objects do not fully comply with the Comparable interface. Only the same Field implementations may be compared. In addition, the null state is not considered when comparing PrimitiveFields which have a zero (0) value.
      Specified by:
      compareTo in interface Comparable<Field>
      Specified by:
      compareTo in class Field
      Parameters:
      o - another Field which is the same type as this Field
      Returns:
      field comparison result (see Comparable.compareTo(Object)).
    • copyField

      public StringField copyField()
      Description copied from class: Field
      Create new instance of this field with the same value.
      Specified by:
      copyField in class Field
      Returns:
      new field instance with same value
    • newField

      public StringField newField()
      Description copied from class: Field
      Create new instance of this field type.
      Specified by:
      newField in class Field
      Returns:
      new field instance with undefined initial value
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class Field