planetj.database.field
Class DateField

java.lang.Object
  extended byplanetj.database.Field
      extended byplanetj.database.field.DateField
All Implemented Interfaces:
java.lang.Cloneable, IActionObject, ICSVField, ICurrentValueField, IDateField, IExternallyNamed, IFDFObject, IGuarded, INamed, IPDFField, IXMLObject, java.io.Serializable
Direct Known Subclasses:
TimeField

public class DateField
extends Field
implements java.lang.Cloneable, java.io.Serializable, IDateField, ICurrentValueField

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class planetj.database.Field
Field.FieldLocation
 
Field Summary
static java.lang.String ISO_FORMAT
           
static java.lang.String LENIENT
           
 
Fields inherited from class planetj.database.Field
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_UNKNOWN
 
Fields inherited from interface planetj.database.field.ICurrentValueField
CURRENT_VALUE
 
Fields inherited from interface planetj.dataengine.security.IGuarded
TYPE_ID_UNKNOWN, TYPE_NAME_FIELD, TYPE_NAME_SQLOPERATION, TYPE_SECURED_BY_LEVEL, TYPE_SECURED_BY_OPERATION, TYPE_UNSECURED
 
Constructor Summary
DateField()
           
 
Method Summary
 Field cloneField()
          Returns a clone of the Field.
static java.util.Date createDate(java.lang.String format, java.lang.String value)
          Create a java.util.Date from the given format and String.
 java.lang.Object createObject(java.lang.String pStringValue)
          Create an object for this Field type using the given String.
static int getCentury(java.util.Date date)
          Get the century for the given date.
 java.lang.Object getCopiedValue()
          Gets an independent copy of this field's value.
 java.lang.String getCSVField()
          Returns the String value of the Object, that will be written to the CSV file.
 java.lang.String getCSVFormat()
          Returns the CSV Format Creation date: (5/11/2002 7:56:58 PM)
 java.lang.Object getCurrentValue(ExecutingContext ec)
          Gets the default current value for this field as a String.
 java.lang.String getCurrentValueAsString(ExecutingContext ec)
          Gets the default current value for this field as a String.
 java.lang.String getDefaultDatabaseValue()
          Subclass must override this method and return a default value to be placed in the database when this field is Not-nullable and not required.
 java.lang.String getDefaultFormat()
          Get the default format for this date field from its system.
 java.lang.String getDisplayFormat()
          Returns the Default Format Creation date: (5/11/2002 7:56:58 PM)
protected  java.lang.String getDisplayValue(java.lang.Object value)
          Gets the display value for this date field.
 java.lang.String getISOFormat()
          Returns the CSV Format Creation date: (5/11/2002 7:56:58 PM)
 java.lang.String getJulianFormat()
           
 java.lang.String getOldValueAsString()
          Gets this date field's old value as a string.
 java.lang.String getPossibleFormats()
          This method should be overriden by subclasses that want to display possible or valid values to a user Example PhoneNumber would return "Examples: (123) 456-7890, 1234567890, 123-456-78890" Creation date: (4/5/2002 2:52:46 PM)
 java.lang.Object getSQLObject()
          Gets this field's value as an Object in SQL format.
 java.lang.String getSQLValue(boolean useOriginalValue)
          Returns the Field's name and value in SQL format.
static java.lang.String getSQLValue(java.util.Date date, java.lang.String format, int sqlType, boolean allowsNull)
          Returns the field's value in the proper SQL format.
 java.lang.String getValidValuesString()
          This method should be overriden by subclasses that want to display possible or valid values to a user Example PhoneNumber would return "Examples: (123) 456-7890, 1234567890, 123-456-78890" Creation date: (4/5/2002 2:52:46 PM)
 java.lang.Object getValue()
          Get the date field's value
 boolean getValueAsBoolean()
          Subclasses must override this to detirmine what their boolean value is.
 java.lang.String getValueAsString()
          Gets this date field's value as a string.
static java.lang.String getYear(int c, java.lang.String yy)
          Get the 4 digit year 'yyyy' for the given century and two digit year 'cyy'.
static short guessFieldClassProbability(FieldDescriptorRow pFDRow, RowCollection pSampleData)
          Subclasses will override to take an educated guess at what the Field Class will be for this FD Row.
 boolean isDate()
          Subclasses should override to change the value
 boolean isValidLength(ExecutingContext ec)
          Validate this Field based on its max length attribute.
 boolean isValidValue(ExecutingContext ec)
          Validate this Field value.
 boolean isValueEqual(java.lang.Object obj)
          Returns a boolean indicating if this field is equal to the supplied object.
 boolean isValueGreaterThan(java.lang.Object obj)
          Returns a boolean indicating if this field is greater than the supplied object.
 boolean isValueLessThan(java.lang.Object obj)
          Returns a boolean indicating if this field is less then the supplied object.
 void setValue(long millis)
          Sets the current value of the Field to the specified value, and also sets the old value to the previous value.
 void setValue(java.lang.Object value)
          Sets the current value of the Field to the specified value, and also sets the old value to the previous value.
 
Methods inherited from class planetj.database.Field
addFieldClassForDataClass, addPropertyChangeListener, appendSQLColumnDefinition, appendSQLNameAndValue, appendSQLNameAndValue, clearTable, clearValidationExceptions, clearValue, cloneFD, commitValue, concat, correctSQLLiteral, correctValue, create, create, createAction, createFromDataType, createInternal, divide, equals, executeGetterMethod, executeSetterMethod, firePropertyChange, getActionDefaultLocation, getActionDescriptor, getActionRequest, getActionRequest, getActions, getAssociationOperation, getAttribute, getAutoUpdateValue, getBackgroundColor, getBackgroundColor, getColumnSpan, getConfigProperty, getCSVDisplayField, getDataSQLOperation, getDate, getDefaultExternalName, getDefaultUsageId, getDefaultValue, getDisplayComponent, getDisplayHeight, getDisplayLength, getDisplayOrder, getDisplayValue, getDisplayWidth, getExternalName, getExternalValidationKey, getFDFData, getFieldClassForDataClass, getFieldClassParameters, getFieldDescriptor, getFieldDescriptorSource, getFieldHandledActionNames, getFieldIncrementor, getFieldSetName, getFormatter, getHorizontalAlignment, getIndex, getLibrary, getLibraryName, getMaxLength, getMaxLength, getMetaDataSystemAlias, getName, getOldValue, getPDFValue, getPossibleValueClass, getPossibleValues, getPossibleValues, getPossibleValuesKey, getPossibleValuesOperation, getPossibleValuesSQLOperation, getPreferredDisplayLength, getPreferredJavaDataType, getPVPage, getRow, getSearchDefaultValue, getSecuredTypeId, getSecuredTypeName, getSecurityType, getSQLColumnDefinition, getSQLColumnDefinition, getSQLNameAndDefaultValue, getSQLNameAndValue, getSQLNameAndValue, getSQLNullValue, getSQLType, getSQLType, getSQLTypeName, getSQLTypeName, getSQLValue, getSQLValue, getStaticAttribute, getStaticAttributes, getStatusChange, getStyleClass, getStyleClass, getSystem, getSystemAlias, getSystemURL, getTable, getTableName, getUsageId, getUsageId, getUsageIds, getValidationExceptions, getValidationInvalidLengthString, getValidationInvalidMinLengthString, getValidationInvalidValueString, getValidationInvalidValueString, getValidationRequiredString, getValueAsByte, getValueAsDate, getValueAsDouble, getValueAsFloat, getValueAsFullLengthString, getValueAsInt, getValueAsLong, getValueAsNumber, getValueAsShort, getXMLData, getXMLTag, handleAction, handlePossibleValueOperation, hasAssociationOperation, hasMultipleStyleClasses, hasOldValue, hasPossibleValuesKeyClassOrOp, hasPossibleValuesOperation, hasPossibleValuesOperation, hasUsageId, hasUsageId, hasValue, incrementValue, isActionApplicable, isApplicable, isAuthorizedForEdit, isAuthorizedForRead, isAutoIncrement, isAutoIncrementDatabaseDriven, isAutoIncrementWOWDriven, isAutoUpdateValue, isBoolean, isChanged, isContainsValue, isCurrentValueField, isCurrentValueString, isDecimalSQLType, isDecimalSQLType, isDefaultValue, isDerived, isDisplayable, isFieldContentDisplayable, isFieldValueDatabaseDefault, isFieldValueNotBlank, isFieldValueNull, isFieldValuePossibleValue, isFieldValuesEqual, isFileUpload, isGuarded, isHelpTextPresent, isInitialized, isNumeric, isNumericSQLType, isNumericSQLType, isPassword, isPhysical, isPossibleValuesSearch, isPrepareFieldValue, isReadOnly, isReadOnly, isReadOnlyOnSearch, isRequired, isRequired, isRequiredOnSearch, isSkeleton, isStatusChange, isString, isStringSQLType, isStringSQLType, isTime, isTimestamp, isUpdateable, isValidationRequiredForAutoPopulate, isValidLength, isValidMinLength, isValidRequired, isValidRequired, isValidValue, isValueEqualToString, lessThan, removePropertyChangeListener, resetDisplayValue, rollbackChanges, setAttribute, setChanged, setClonedValues, setDate, setFieldContentDisplayable, setFieldDescriptor, setHasValue, setIndex, setInitialValue, setInitialValueAsString, setMaxLength, setName, setPVPage, setRow, setSavepoint, setSkeleton, setSQLType, setSQLTypeName, setStaticAttribute, setTable, setValue, setValueAsString, setValueToDefault, statusChanged, toString, toUpperCase, validate, validate, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface planetj.database.field.ICurrentValueField
getAutoUpdateValue, getDefaultValue
 

Field Detail

ISO_FORMAT

public static java.lang.String ISO_FORMAT

LENIENT

public static final java.lang.String LENIENT
See Also:
Constant Field Values
Constructor Detail

DateField

public DateField()
Method Detail

createDate

public static java.util.Date createDate(java.lang.String format,
                                        java.lang.String value)
                                 throws java.text.ParseException
Create a java.util.Date from the given format and String.

Throws:
java.text.ParseException

getSQLValue

public static java.lang.String getSQLValue(java.util.Date date,
                                           java.lang.String format,
                                           int sqlType,
                                           boolean allowsNull)
Returns the field's value in the proper SQL format.

Returns:
String

cloneField

public Field cloneField()
                 throws CMException
Returns a clone of the Field. Overriding is necessary so we can clone the old and current values of the Field.

Overrides:
cloneField in class Field
Throws:
CMException

createObject

public java.lang.Object createObject(java.lang.String pStringValue)
                              throws ValidationException
Create an object for this Field type using the given String.

Specified by:
createObject in class Field
Parameters:
pStringValue - String
Throws:
ValidationException

getCopiedValue

public java.lang.Object getCopiedValue()
Gets an independent copy of this field's value. If the value is immutable, then this method can simply return the value. Otherwise, a clone of the value should be returned.

Specified by:
getCopiedValue in class Field

getCSVField

public java.lang.String getCSVField()
Returns the String value of the Object, that will be written to the CSV file. If the toString method of any Object already does this, then there is no need to implement this interface.

Character string in the format MM/DD/YYYY where MM and DD have leading zeros for values less than ten. If this is a TimeField the format is HH:mm:ss where HH, mm, and ss have leading zeros for values less than ten. The string is not enclosed by double quotation marks.

In a CMException was thrown, or there were problems, then [Invalid Field] will be returned Creation date: (4/22/2002 2:28:48 PM)

Specified by:
getCSVField in interface ICSVField
Overrides:
getCSVField in class Field
Returns:
String

getCSVFormat

public java.lang.String getCSVFormat()
Returns the CSV Format Creation date: (5/11/2002 7:56:58 PM)

Returns:
java.lang.String

getCurrentValue

public java.lang.Object getCurrentValue(ExecutingContext ec)
Gets the default current value for this field as a String.

Specified by:
getCurrentValue in interface ICurrentValueField
Overrides:
getCurrentValue in class Field

getCurrentValueAsString

public java.lang.String getCurrentValueAsString(ExecutingContext ec)
Gets the default current value for this field as a String.

Specified by:
getCurrentValueAsString in interface ICurrentValueField
Overrides:
getCurrentValueAsString in class Field

getDefaultDatabaseValue

public java.lang.String getDefaultDatabaseValue()
                                         throws CMException
Subclass must override this method and return a default value to be placed in the database when this field is Not-nullable and not required.

Example: A SS# is not required to be filled in by users, but the database does not allow nulls in that field. SocialSecurityField must override this method and return a default value like -1; Creation date: (4/9/2002 4:51:06 PM)

Specified by:
getDefaultDatabaseValue in class Field
Throws:
CMException

getDefaultFormat

public java.lang.String getDefaultFormat()
Get the default format for this date field from its system.

Specified by:
getDefaultFormat in interface IDateField

getDisplayFormat

public java.lang.String getDisplayFormat()
Returns the Default Format Creation date: (5/11/2002 7:56:58 PM)

Returns:
java.lang.String

getDisplayValue

protected java.lang.String getDisplayValue(java.lang.Object value)
Gets the display value for this date field.


getISOFormat

public java.lang.String getISOFormat()
Returns the CSV Format Creation date: (5/11/2002 7:56:58 PM)

Returns:
java.lang.String

getCentury

public static int getCentury(java.util.Date date)
Get the century for the given date.


getYear

public static java.lang.String getYear(int c,
                                       java.lang.String yy)
Get the 4 digit year 'yyyy' for the given century and two digit year 'cyy'.


getJulianFormat

public java.lang.String getJulianFormat()

getOldValueAsString

public java.lang.String getOldValueAsString()
Gets this date field's old value as a string.

Overrides:
getOldValueAsString in class Field
Returns:
String

getPossibleFormats

public java.lang.String getPossibleFormats()
This method should be overriden by subclasses that want to display possible or valid values to a user Example PhoneNumber would return "Examples: (123) 456-7890, 1234567890, 123-456-78890" Creation date: (4/5/2002 2:52:46 PM)


getSQLObject

public java.lang.Object getSQLObject()
                              throws CMException
Gets this field's value as an Object in SQL format.

Overrides:
getSQLObject in class Field
Throws:
CMException

getSQLValue

public java.lang.String getSQLValue(boolean useOriginalValue)
                             throws CMException
Returns the Field's name and value in SQL format.

Specified by:
getSQLValue in class Field
Parameters:
useOriginalValue - If this is true then the value used will be this field's original value as it was read from the database. Otherwise its current value is used.
Returns:
String
Throws:
CMException

getValidValuesString

public java.lang.String getValidValuesString()
This method should be overriden by subclasses that want to display possible or valid values to a user Example PhoneNumber would return "Examples: (123) 456-7890, 1234567890, 123-456-78890" Creation date: (4/5/2002 2:52:46 PM)

Overrides:
getValidValuesString in class Field

getValue

public java.lang.Object getValue()
Get the date field's value

Specified by:
getValue in interface INamed
Overrides:
getValue in class Field
Returns:
Object

getValueAsBoolean

public boolean getValueAsBoolean()
Subclasses must override this to detirmine what their boolean value is. Returns a primitive that represents the value in the specified field.

Specified by:
getValueAsBoolean in class Field
Returns:
boolean

getValueAsString

public java.lang.String getValueAsString()
Gets this date field's value as a string.

Overrides:
getValueAsString in class Field
Returns:
String

guessFieldClassProbability

public static short guessFieldClassProbability(FieldDescriptorRow pFDRow,
                                               RowCollection pSampleData)
Subclasses will override to take an educated guess at what the Field Class will be for this FD Row. Each subclass will examin fields such as : {DECIMAL_DIGITS, COLUMN_NAME, COLUMN_SIZE, REMARKS, DATA_TYPE, TYPE_NAME} Each subclass will detirmine the probability that it should be the field class for this FD Row. -1 will be returned if there is no chance (0%)this field is the fieldClass for pFDRow. 100 or greater will be returned if this is absolutely 100% the field class for pFDRow


isDate

public boolean isDate()
Subclasses should override to change the value

Overrides:
isDate in class Field
Returns:
boolean

isValidLength

public boolean isValidLength(ExecutingContext ec)
Validate this Field based on its max length attribute. If the value is is too big, the return false

Overrides:
isValidLength in class Field
Parameters:
ec - The current executing context, which may be null
Returns:
boolean true if valid

isValidValue

public boolean isValidValue(ExecutingContext ec)
Validate this Field value. If the field value is valid, return true,

Overrides:
isValidValue in class Field
Parameters:
ec - The executing context, which may be null
Returns:
boolean true if valid

isValueEqual

public boolean isValueEqual(java.lang.Object obj)
Returns a boolean indicating if this field is equal to the supplied object. the Row the Field belongs to. Subclasses should override and return the appropriate response.

Specified by:
isValueEqual in class Field
Returns:
boolean

isValueGreaterThan

public boolean isValueGreaterThan(java.lang.Object obj)
Returns a boolean indicating if this field is greater than the supplied object. the Row the Field belongs to. Subclasses should override and implement as appropriate.

Specified by:
isValueGreaterThan in class Field
Returns:
boolean

isValueLessThan

public boolean isValueLessThan(java.lang.Object obj)
Returns a boolean indicating if this field is less then the supplied object. the Row the Field belongs to. Subclasses should override and return the appropriate response.

Specified by:
isValueLessThan in class Field
Returns:
boolean

setValue

public void setValue(long millis)
              throws CMException
Description copied from class: Field
Sets the current value of the Field to the specified value, and also sets the old value to the previous value. NOTE: This method will take int types also. If called and the Field is not updatable a CMException is thrown.

Overrides:
setValue in class Field
Throws:
CMException

setValue

public void setValue(java.lang.Object value)
              throws CMException
Sets the current value of the Field to the specified value, and also sets the old value to the previous value. If called and the Field is not updatable a CMException is thrown.

Overrides:
setValue in class Field
Throws:
CMException