FairCom.CtreeDb
Class CTField

java.lang.Object
  extended by FairCom.CtreeDb.CTBase
      extended by FairCom.CtreeDb.CTField

public class CTField
extends CTBase

The CTField class deals with the field concept. The field is the basic component of the table. Any table may be composed of as many fields as one needs. It uses CTBase as the base class, and implements the constructor/destructor allocating/freeing memory to the field operations.

See Also:
CTBase, CTTable, CTRecord, CTIndex, CTSegment

Field Summary
 
Fields inherited from class FairCom.CtreeDb.CTBase
m_handle
 
Constructor Summary
CTField()
          Creates a new CTField Object
CTField(CTField Field)
          Creates a new CTField Object
 
Method Summary
 void ClearFieldDefaultValue()
          Clear the default value associalted with a field.
 void CTFieldSetFieldDefaultDateTimeType()
          Set the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values.
 int GetCTType()
           
 int GetFieldDefaultDateType()
          Retrieve the default value date type used when converting strings to dates.
 int GetFieldDefaultTimeType()
          Retrieve the default value time type used when converting String to time.
 java.lang.String GetFieldDefaultValue()
          Retrieve the current field default value.
 int GetLength()
          Retrieve the field length
 java.lang.String GetName()
          Retrieve the field name
 boolean GetNullFlag()
          Retrieve the field nul flag
 int GetNumber()
          Retrieve the field position index in the table field list
 int GetPrecision()
          Retrieve the field precision
 int GetScale()
          Retrieve the field scale
 int GetStatus()
          Retrieve the status of a field handle.
 int GetType()
          Retrieve the field type.
 boolean IsFieldDefaultValueSet()
          Check if a field default value has been set or not.
 boolean IsNumeric()
          Indicate if the field represents a numeric value
 void SetFieldDefaultDateTimeType(int DateType, int TimeType)
          Set the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values.
 void SetFieldDefaultValue(java.lang.String Value)
          Set the field default value.
 void SetLength(int FieldLength)
          Set Field length
 void SetName(java.lang.String FieldName)
          Set the field name
 void SetNullFlag(boolean flag)
          Set Nul Flag
 void SetPrecision(int precision)
          Set the field precision
 void SetScale(int scale)
          Set the field scale value
 void SetType(int FieldType, int FieldLength)
          Set the field type
 
Methods inherited from class FairCom.CtreeDb.CTBase
Abort, Begin, Commit, GetAutoCommit, GetHandle, GetKeepLock, GetLockMode, GetOperation, GetTransactionMode, IsLockActive, IsTransActive, IsUnicodeLib, Lock, RestoreSavePoint, SetAutoCommit, SetHandle, SetKeepLock, SetOperation, SetSavePoint, SetTransactionMode, Unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CTField

public CTField()
Creates a new CTField Object


CTField

public CTField(CTField Field)
Creates a new CTField Object

Method Detail

GetName

public java.lang.String GetName()
Retrieve the field name

Returns:
Return the field name
See Also:
SetName(java.lang.String), GetType(), GetLength()

GetType

public int GetType()
Retrieve the field type. GetCTType is maintained for backward compatibility both return the field type

Returns:
Return the field type (FIELD_TYPE)
See Also:
SetType(int, int), GetName(), GetLength()

GetCTType

public int GetCTType()

GetLength

public int GetLength()
Retrieve the field length

Returns:
Return the field length
See Also:
SetLength(int), GetPrecision(), GetScale(), GetName(), GetType()

SetName

public void SetName(java.lang.String FieldName)
             throws CTException
Set the field name

Parameters:
FieldName - The new name for the Field
Throws:
CTException
See Also:
GetName(), SetType(int, int), SetLength(int)

SetType

public void SetType(int FieldType,
                    int FieldLength)
             throws CTException
Set the field type

Parameters:
FieldType - The new type for the Field
FieldLength - The new length for the Field
Throws:
CTException
See Also:
GetType(), SetName(java.lang.String), SetLength(int)

SetLength

public void SetLength(int FieldLength)
               throws CTException
Set Field length

Parameters:
FieldLength - The new length for the Field
Throws:
CTException
See Also:
GetLength(), SetPrecision(int), SetScale(int), SetName(java.lang.String), SetType(int, int)

GetNumber

public int GetNumber()
              throws CTException
Retrieve the field position index in the table field list

Returns:
Return the field number
Throws:
CTException
See Also:
GetName(), GetName()

GetNullFlag

public boolean GetNullFlag()
Retrieve the field nul flag

Returns:
Return the field nul flag setting
See Also:
GetNumber(), GetName()

GetPrecision

public int GetPrecision()
Retrieve the field precision

Returns:
Return the field precision value
See Also:
SetPrecision(int), GetLength(), GetScale()

GetScale

public int GetScale()
Retrieve the field scale

Returns:
Return the field scale value
See Also:
SetPrecision(int), GetLength(), GetPrecision()

SetNullFlag

public void SetNullFlag(boolean flag)
                 throws CTException
Set Nul Flag

Parameters:
flag - new null flag value
Throws:
CTException
See Also:
GetNullFlag(), SetPrecision(int), SetScale(int), SetName(java.lang.String), SetType(int, int)

SetPrecision

public void SetPrecision(int precision)
                  throws CTException
Set the field precision

Parameters:
precision - precision value
Throws:
CTException
See Also:
GetPrecision(), SetNullFlag(boolean), SetScale(int), SetName(java.lang.String), SetType(int, int)

SetScale

public void SetScale(int scale)
              throws CTException
Set the field scale value

Parameters:
scale - Field scale value
Throws:
CTException
See Also:
SetScale(int), SetNullFlag(boolean), SetPrecision(int), SetName(java.lang.String), SetType(int, int)

IsNumeric

public boolean IsNumeric()
Indicate if the field represents a numeric value

Returns:
return YES if field is numeric
See Also:
GetType(), GetLength()

SetFieldDefaultValue

public void SetFieldDefaultValue(java.lang.String Value)
                          throws CTException
Set the field default value. The default value of a field is used during an alter table operation when a full table rebuild is performed. During a full alter table rebuild, and after the old record buffer data is moved to the new record buffer, the new record buffer is scanned and if a NULL field is found and that NULL field has a default value, the default value is copied to the field buffer. The field default value is kept as a String representation of the data. It is recommended that numeric data should be converted to String using one of the rich set of c-treeDB data conversion functions. Date values should be converted to String using the default date type value. The default date type value can be retrieved by calling GetFieldDefaultDateType method. By default, the date type is CTDATE_MDCY. Time values should be converted to String using the default time type value. The default time type value can be retrieved by calling GetFieldDefaultTimeType function. By default, the time type is CTTIME_HMS. Time stamp values should be converted to String using the default date type and time type values as described above.

Parameters:
Value - new Field default value
Throws:
CTException
See Also:
GetFieldDefaultValue(), ClearFieldDefaultValue(), SetFieldDefaultDateTimeType(int, int)

GetFieldDefaultValue

public java.lang.String GetFieldDefaultValue()
Retrieve the current field default value. If no default value is set GetFieldDefaultValue return zero. You can use IsFieldDefaultValueSet method to check if a field default value is set or not.

Returns:
Return the field default value
See Also:
SetFieldDefaultValue(java.lang.String), ClearFieldDefaultValue(), SetFieldDefaultDateTimeType(int, int)

ClearFieldDefaultValue

public void ClearFieldDefaultValue()
                            throws CTException
Clear the default value associalted with a field. The default date and time types are also reset to their default values of CTDATE_MDCY and CTTIME_HMS respectively.

Throws:
CTException
See Also:
SetFieldDefaultValue(java.lang.String), ClearFieldDefaultValue(), SetFieldDefaultDateTimeType(int, int)

CTFieldSetFieldDefaultDateTimeType

public void CTFieldSetFieldDefaultDateTimeType()
                                        throws CTException
Set the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values. By default the date type is CTDATE_MDCY and the time type is CTTIME_HMS. Use this method to modify the default values.

Throws:
CTException
See Also:
SetFieldDefaultValue(java.lang.String), ClearFieldDefaultValue(), SetFieldDefaultDateTimeType(int, int)

SetFieldDefaultDateTimeType

public void SetFieldDefaultDateTimeType(int DateType,
                                        int TimeType)
                                 throws CTException
Set the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values. By default the date type is CTDATE_MDCY and the time type is CTTIME_HMS. Use this method to modify the default values. SetFieldDefaultDateTimeType method modifies both the date and time types. If you wish to change only the default date time, but keep the current time type, use the following example: hField.SetFieldDefaultDateTimeType(CTDATE_YMD, hField.GetFieldDefaultTimeType()); You can use the same approach to change only the time type, keeping the current date type: hField.SetFieldDefaultDateTimeType( ctdbGetFieldDefaultDateType(), CTIME_HMP);

Parameters:
DateType - The date type to be used for converting values between dates and strings. The possible values are: CTDATE_MDCY - Date format is mm/dd/ccyy CTDATE_MDY - Date format is mm/dd/yy CTDATE_DMCY - Date format is dd/mm/ccy CTDATE_DMY - Date format is dd/mm/yy CTDATE_CYMD - Date format is ccyymmdd CTDATE_YMD - Date format is yymmdd timeType [IN] The time type to be used for converting values between time and strings. The possible values are: CTTIME_HMSP - Time format is hh:mm:ss am or pm CTTIME_HMP - Time format is hh:mm am or pm CTTIME_HMS - Time format is hh:mm:ss (24 hour) CTTIME_HM - Time format is hh:mm (24 hour) CTTIME_MIL - Time format is hhmm (military)
Throws:
CTException
See Also:
SetFieldDefaultValue(java.lang.String), ClearFieldDefaultValue(), SetFieldDefaultDateTimeType(int, int)

IsFieldDefaultValueSet

public boolean IsFieldDefaultValueSet()
Check if a field default value has been set or not.

Returns:
Return YES if a field default value was set
See Also:
GetFieldDefaultValue(), ClearFieldDefaultValue(), SetFieldDefaultDateTimeType(int, int)

GetFieldDefaultDateType

public int GetFieldDefaultDateType()
Retrieve the default value date type used when converting strings to dates.

Returns:
Return the default value date type (DATE_TYPE).
See Also:
GetFieldDefaultTimeType(), GetFieldDefaultValue(), ClearFieldDefaultValue(), SetFieldDefaultValue(java.lang.String)

GetFieldDefaultTimeType

public int GetFieldDefaultTimeType()
Retrieve the default value time type used when converting String to time.

Returns:
Return the default value time type (TIME_TYPE).
See Also:
GetFieldDefaultDateType(), GetFieldDefaultValue(), ClearFieldDefaultValue(), SetFieldDefaultValue(java.lang.String)

GetStatus

public int GetStatus()
Retrieve the status of a field handle. The status of a field handle is a bit map describing one or more of the following FIELD_STATUS values: OLD Original field as read from table NEW Field added or inserted DEL Original field deleted MOVED Original field moved NAME Field name changed TYPE Field type changed LEN Field length changed RESOURCE Field resource changed

Returns:
Return the object handle status (FIELD_STATUS).