it.biobytes.ammentos
Class Field

java.lang.Object
  extended by it.biobytes.ammentos.Field
All Implemented Interfaces:
java.lang.Comparable

public class Field
extends java.lang.Object
implements java.lang.Comparable

Represents an iformation field of a persistent object

Author:
davide

Field Summary
protected  int position
           
 
Constructor Summary
Field(java.lang.String name, java.lang.String description, FieldType type, java.lang.reflect.Field classMember)
          Creates a new instance of PersistentField
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object obj)
           
 java.lang.String formatValue(java.lang.Object value)
           
 java.lang.Object generateValue()
          Generates an automatic value for this field in according with the field type.
 java.lang.Object get(java.lang.Object obj)
           
 java.lang.String getDescription()
           
 java.lang.Class getMappedClass()
           
 java.lang.String getName()
           
 java.lang.Object[] getPossibleValues()
           
 FieldType getType()
           
 int hashCode()
           
 boolean isAutomatic()
          Indicates if this field is automatic
 boolean isDynamic()
          Indicates if this field is calculated at runtime.
 boolean isExternal()
          Indicates if this field is external.
 boolean isVisible()
           
 java.lang.Object loadValue(java.sql.ResultSet rs)
           
 java.lang.Object loadValue(java.lang.String str)
           
 java.lang.Object parseValue(java.lang.String str)
           
 void set(java.lang.Object obj, java.lang.Object value)
          Sets the value of this field for the object obj to the provided value
 void setAutomatic(boolean isAutomatic)
          Sets the field to be automatic or not.
 void setDynamic(boolean b)
          Sets this field to be dynamically calculated or not.
 void setExternal(boolean isExternallyManaged)
          Sets the field to be external (f.e.
 void setParamValue(java.lang.Object fieldValue, java.sql.PreparedStatement pstmt, int paramIndex)
           
 void setVisible(boolean visible)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

position

protected int position
Constructor Detail

Field

public Field(java.lang.String name,
             java.lang.String description,
             FieldType type,
             java.lang.reflect.Field classMember)
Creates a new instance of PersistentField

Method Detail

setExternal

public void setExternal(boolean isExternallyManaged)
Sets the field to be external (f.e. from a different table) or not. An external field of a persistent object will not be updatable into the database. By default a field is not external.


isExternal

public boolean isExternal()
Indicates if this field is external.

See Also:
com.biobytes.sql.PersistentField.setExternallyManaged()

setAutomatic

public void setAutomatic(boolean isAutomatic)
Sets the field to be automatic or not. An automatic field is a field which values are automatically generated from the framework (like a sequence in a database). Automatic field values are generated the first time a SqlPersistentObject is saved on the database and once created are not updatable. An automatic field can be used as primary key for a SqlPersistentObject because its value is guarantee to be unique. By default a field is not automatic.

Parameters:
isAutomatic -

isAutomatic

public boolean isAutomatic()
Indicates if this field is automatic

Returns:

setVisible

public void setVisible(boolean visible)

isVisible

public boolean isVisible()

getName

public java.lang.String getName()

getDescription

public java.lang.String getDescription()

getType

public FieldType getType()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

formatValue

public java.lang.String formatValue(java.lang.Object value)

parseValue

public java.lang.Object parseValue(java.lang.String str)
                            throws PersistenceException
Throws:
PersistenceException

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isDynamic

public boolean isDynamic()
Indicates if this field is calculated at runtime. A dynamic field is never loaded nor saved on the database.

Returns:

setDynamic

public void setDynamic(boolean b)
Sets this field to be dynamically calculated or not.

Parameters:
b -

loadValue

public java.lang.Object loadValue(java.sql.ResultSet rs)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

loadValue

public java.lang.Object loadValue(java.lang.String str)
                           throws PersistenceException
Throws:
PersistenceException

setParamValue

public void setParamValue(java.lang.Object fieldValue,
                          java.sql.PreparedStatement pstmt,
                          int paramIndex)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

generateValue

public java.lang.Object generateValue()
                               throws PersistenceException
Generates an automatic value for this field in according with the field type.

Returns:
the generated value. Cannot be null.
Throws:
java.sql.SQLException - If the field is not automatic or its type cannot be automatized.
PersistenceException

getPossibleValues

public java.lang.Object[] getPossibleValues()

getMappedClass

public java.lang.Class getMappedClass()

set

public void set(java.lang.Object obj,
                java.lang.Object value)
Sets the value of this field for the object obj to the provided value


get

public java.lang.Object get(java.lang.Object obj)