Class TableFieldValue

java.lang.Object
org.silverpeas.components.mydb.model.TableFieldValue
All Implemented Interfaces:
Comparable<TableFieldValue>

public class TableFieldValue extends Object implements Comparable<TableFieldValue>
The value of a field in a table row with its type (and associated type name) in the database.
Author:
mmoquillon
  • Method Details

    • fromString

      public static TableFieldValue fromString(String value, int sqlType)
      Constructs a TableFieldValue instance from the specified value represented as a String object and according to the specified SQL type (a value among Types). If the specified value doesn't match the SQL type of this field value, then an IllegalArgumentException exception is thrown.
      Parameters:
      value - the String representation of a value. Null value shouldn't be null but the String "null".
      sqlType - the SQL type as defined in Types.
      Returns:
      a TableFieldValue instance.
    • getType

      public int getType()
      Gets the code of the SQL type of this value.
      Returns:
      the SQL type of this value as defined in Types.
      See Also:
    • isText

      public boolean isText()
      Is this value a text?
      Returns:
      true if the type of this value is a text, false otherwise.
    • isEmpty

      public boolean isEmpty()
      Is this value an empty text?
      Returns:
      true if this value is a text and it is empty. False otherwise.
    • update

      public void update(String value)
      Updates this value with the textual representation of the new value. If the specified value doesn't match the SQL type of this field value, then an IllegalArgumentException exception is thrown.
      Parameters:
      value - a String representation of the value. Null value shouldn't be null but the String "null".
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(TableFieldValue o)
      Compares this TableFieldValue with the specified one. The comparing is actually done on the wrapped values themselves. If the wrapped values satisfy the Comparable interface then the Comparable.compareTo(Object) method is used, otherwise both of them are converted in String objects and these String instances are then compared between themselves.
      Specified by:
      compareTo in interface Comparable<TableFieldValue>
      Parameters:
      o - another TableFieldValue with which this one is compared.
      Returns:
      the comparing distance between the two TableFieldValue instances.
    • toString

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

      public TableFieldValue getCopy()