LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyDateFieldInfo

java.lang.Object
  extended by leon.info.LyTag
      extended by leon.info.LyInfo
          extended by leon.info.LyObjectInfo
              extended by leon.info.LyFieldInfo
                  extended by leon.info.LyDateFieldInfo
All Implemented Interfaces:
java.lang.Cloneable, LyField, LyCommentInterface

public final class LyDateFieldInfo
extends LyFieldInfo

This class implements the description of a Date field.

A date fieldInfo is the implementation of a date attribute in a application class.

Types for this fieldInfo indicate how much information is shown to the user (year, month, day, hour, minute, seconds). Specific format may also be used. Supported types are declared as public static named TYPE_XXX

See also tag of leon.dtd


Nested Class Summary
static class LyDateFieldInfo.Type
          Date types.
 
Nested classes/interfaces inherited from class leon.info.LyTag
LyTag.Model
 
Field Summary
static java.lang.String __version
           
static java.lang.String DEFAULT_PEER_FORMAT
          Default peer date format when peer type is String.
static java.lang.String VALUE_DAY
          Value : day.
static java.lang.String VALUE_NOW
          Value : now.
static java.lang.String VALUE_TODAY
          Value : today.
 
Fields inherited from class leon.info.LyFieldInfo
MARK_APP_ID, MARK_AUTO_COMPLETION, MARK_CHART, MARK_COMPLEX_TABLE, MARK_CONSULT, MARK_CREATE, MARK_CREATE_CONSULT, MARK_DISABLE, MARK_FILTER, MARK_FIND, MARK_HIDDEN, MARK_ID, MARK_LOAD, MARK_LOCAL, MARK_MAIN, MARK_NAME, MARK_NEED_POST, MARK_NO_CAPTION, MARK_NOT_NULL, MARK_OPTIONAL, MARK_PRIVATE, MARK_PROVIDER_VALUE, MARK_READ_ONLY, MARK_SEARCH, MARK_SECRET, MARK_SET, MARK_SET_CONSULT, MARK_SORT, MARK_STATUS, MARK_TABLE, MARK_TRANSLATE, MARK_UNIQUE, SECRET_VALUE, STRONG_DEPENDENCY_VALUE, WEAK_DEPENDENCY_VALUE
 
Fields inherited from class leon.info.LyObjectInfo
__VERSION, NULL, PART_ALL, PART_BIND, PART_DATA, PART_GUI, PART_LABEL
 
Fields inherited from interface leon.data.LyField
__VERSION
 
Method Summary
 LyValue buildFieldValue(java.lang.Object value)
          Builds the appropriate LyValue corresponding to this field for the given value object.
static java.lang.String checkDate(java.lang.String val, java.text.SimpleDateFormat currentDateFormat)
          Checks the date value according to a date format.
 int compare(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Compare two values of this fieldInfo.
 java.lang.Object convertFromFieldUnit(java.lang.Object value, LyUnit unit)
          Convert a value to the field unit from another unit.
 java.lang.Object convertToFieldUnit(java.lang.Object value, LyUnit unit)
          Convert a value from the field unit to the given unit.
 java.text.DateFormat dateFormatFactory()
          Creates a new DateFormat instance of the given type.
static java.util.Date[] getDay(LyDateFieldInfo fieldInfo, java.lang.String value)
           
 java.lang.Object getDefaultValue()
          Gets default value for this date field.
 java.lang.String getDisplayFormat()
          Accessor for the display format property of this date field.
 LyFilterExpression.Condition[] getFilterConditions()
          Returns the filter conditions authorized on this field.
 java.lang.String getFormat()
          Gets the internal format as a string : the format used for selecting dates inside views.
 java.lang.String getInternalDefaultValue()
          Gets the raw default value as it is stored in the meta-model, without any translation or formatting.
 java.lang.Object getPeerValue(java.lang.Object value, java.lang.Class<?> objectClass, LyObject instance)
          Returns an object of the given class from a value of this fieldInfo.
 java.lang.String getStringDateFormat()
          Returns the string representing the date format of the given type.
static java.util.Date[] getTodayDate()
          Gets a table containing the begin and end date of the current day
 LyDateFieldInfo.Type getType()
          Accessor to the date type.
 java.lang.Class<?> getValueClass()
          Returns class of values for this field.
 java.lang.Object getValueFromObject(java.lang.Object object, LyObject instance)
          Constructs a value for this fieldInfo from an object for a given instance.
 boolean isWithTimeZone()
          Checks whether this date field is using time zone during input
 java.lang.Object parse(java.lang.String stringValue)
          Builds internal value for an instance of LyDateFieldInfo from a string (previously constructed by toString).
 java.lang.Object parse(java.lang.String stringValue, java.lang.String timeZone)
          Builds internal value for an instance of LyDateFieldInfo from a string (previously constructed by toString).
 java.lang.String toName(java.lang.Object fieldValue)
          Returns the specified value for this field as a "displayable" string.
 java.lang.String toShortName(java.lang.Object fieldValue)
          Returns the specified value for this field as a short "displayable" string (short string that can be shown to the end-user).
 java.lang.String toString(java.lang.Object fieldValue)
          Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse method).
 java.lang.String toString(java.lang.Object fieldValue, boolean ignoreFormat)
          Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse method).
 java.lang.String toString(java.lang.Object fieldValue, boolean ignoreFormat, java.lang.String timeZone)
          Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse method).
 
Methods inherited from class leon.info.LyFieldInfo
addConstraint, addDepend, addDepend, buildLyValue, checkJavaName, checkValue, compare, compute, compute, compute, compute, contains, contains, controlValue, encodeValue, endsWith, equals, equals, fromFieldTag, getBean, getBeans, getBehaviorClass, getBehaviorClassName, getBinding, getCaptionConstraint, getConstraint, getConstraint, getConstraints, getControl, getControlCount, getControls, getDefaultJavaName, getDepends, getDepends, getFieldBean, getFieldGroup, getFieldTab, getFieldUnit, getFilterModifiers, getFormula, getFormulaFields, getFormulaImports, getGenericMarks, getImport, getJavaName, getLabel, getLabel, getLabelCount, getLabels, getLyFormula, getMark, getMark, getMarkName, getMarks, getPath, getPeerValues, getSpecificMarks, getTab, getUnits, getUserLabel, getUserLabel, getUserLabelCount, hasMark, isCalculated, isComputed, isImported, isLocal, isMultiple, processValue, setImport, setPath, startsWith, toName
 
Methods inherited from class leon.info.LyObjectInfo
clone, getAlias, getData, getDataList, getDatas, getFilePrefix, getGroup, getInternalAlias, getInternalFilePrefix, getInternalName, getMarks, getName, getTemplate, getTip, getUserData, hasMark, hasMarks, hasTemplate, isTemplate, putData, putData, removeData, toName
 
Methods inherited from class leon.info.LyInfo
getApplication, getFile, getId, getInclude, isIncluded, isInternal, isInternal, isLoaded, isLocked, load, setApplication, setFile, toString
 
Methods inherited from class leon.info.LyTag
getCommentsEnd, getCommentsStart, getEnvironment, getModelType, getParent, getRootProject, hasAncestor, isExtern, setCommentsEnd, setCommentsStart, wasCloned
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface leon.data.LyField
getId
 
Methods inherited from interface leon.parser.LyCommentInterface
getCommentsEnd, getCommentsStart, setCommentsEnd, setCommentsStart
 

Field Detail

__version

public static final java.lang.String __version
See Also:
Constant Field Values

VALUE_NOW

public static java.lang.String VALUE_NOW
Value : now.


VALUE_TODAY

public static java.lang.String VALUE_TODAY
Value : today.


VALUE_DAY

public static java.lang.String VALUE_DAY
Value : day.


DEFAULT_PEER_FORMAT

public static java.lang.String DEFAULT_PEER_FORMAT
Default peer date format when peer type is String.

Method Detail

getValueClass

public java.lang.Class<?> getValueClass()
Returns class of values for this field. The value class corresponding to a date field is java.util.Date.

Specified by:
getValueClass in interface LyField
Specified by:
getValueClass in class LyFieldInfo
Returns:
Effective class of values built by this fieldInfo. This method is abstract, the real class depends on each type of field.
See Also:
LyObject.getValue(leon.info.LyFieldInfo)

buildFieldValue

public LyValue buildFieldValue(java.lang.Object value)
Builds the appropriate LyValue corresponding to this field for the given value object.

Specified by:
buildFieldValue in interface LyField
Overrides:
buildFieldValue in class LyFieldInfo
Parameters:
value - Value from which the LyValue is built.
Returns:
An instance of a class that inherits from LyValue corresponding the given value. Classes extending LyValue are given to ease data manipulations, they contain methods that encapsulate data conversions from and to the internal representation. There is one class for each type of field.
See Also:
LyDateValue

getTodayDate

public static java.util.Date[] getTodayDate()
Gets a table containing the begin and end date of the current day

Returns:
a table containing the begin and end date of the current day

getDay

public static java.util.Date[] getDay(LyDateFieldInfo fieldInfo,
                                      java.lang.String value)
Parameters:
_value -
Returns:

parse

public java.lang.Object parse(java.lang.String stringValue,
                              java.lang.String timeZone)
                       throws LyFieldInfoFormatException
Builds internal value for an instance of LyDateFieldInfo from a string (previously constructed by toString).

Parameters:
stringValue - the value to parse
timeZone - the reference timezone
Throws:
LyFieldInfoFormatException
See Also:
toString(java.lang.Object)

parse

public java.lang.Object parse(java.lang.String stringValue)
                       throws LyFieldInfoFormatException
Builds internal value for an instance of LyDateFieldInfo from a string (previously constructed by toString).

Specified by:
parse in class LyFieldInfo
Parameters:
stringValue - The value presented as a string as produced by the toString method.
Returns:
The value decoded from the given string.
Throws:
LyFieldInfoFormatException - If the string can't be parsed properly.
See Also:
toString(java.lang.Object)

compare

public int compare(java.lang.Object value1,
                   java.lang.Object value2,
                   java.util.BitSet modifiers)
Compare two values of this fieldInfo.

Specified by:
compare in class LyFieldInfo
Parameters:
value1 - First value.
value2 - Second value.
modifiers - Modifiers used for checking (see MOD_XXX constants of LyFilterExpression).
Returns:
0 If the two values are identical for the specified fieldInfo, a positive number if value1 is "greater" than value2. If value2 is "greater" than value1, a negative number is returned.
See Also:
LyFieldInfo.getValueClass()

getFilterConditions

public LyFilterExpression.Condition[] getFilterConditions()
Returns the filter conditions authorized on this field. The values must match the short constants defined in LyFilterExpression.

Overrides:
getFilterConditions in class LyFieldInfo
Returns:
An array of conditions corresponding to the authorized conditions on this field.
See Also:
LyFilterExpression

toShortName

public java.lang.String toShortName(java.lang.Object fieldValue)
Returns the specified value for this field as a short "displayable" string (short string that can be shown to the end-user). Default implementation consists of returning same result as toName.

Overrides:
toShortName in class LyFieldInfo
Parameters:
value - The internal value to convert to a short displayable string. The excepted class of this value is the one returned from the getValueClass method.
Returns:
The value presented as a short displayable String.
See Also:
LyFieldInfo.getValueClass(), LyFieldInfo.toName(java.lang.Object)

toName

public java.lang.String toName(java.lang.Object fieldValue)
Returns the specified value for this field as a "displayable" string.

Specified by:
toName in class LyFieldInfo
Returns:
The value presented as a displayable String.
See Also:
LyFieldInfo.getValueClass()

toString

public java.lang.String toString(java.lang.Object fieldValue)
Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse method).

Specified by:
toString in class LyFieldInfo
Returns:
the value as an internal String.
See Also:
parse(java.lang.String, java.lang.String)

toString

public java.lang.String toString(java.lang.Object fieldValue,
                                 boolean ignoreFormat)
Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse method).

See Also:
parse(java.lang.String, java.lang.String)

toString

public java.lang.String toString(java.lang.Object fieldValue,
                                 boolean ignoreFormat,
                                 java.lang.String timeZone)
Converts the specified value for this field to an "internal" string (string that enables reconstruction through parse method).

Parameters:
timeZone - the time zone to display

getValueFromObject

public java.lang.Object getValueFromObject(java.lang.Object object,
                                           LyObject instance)
Constructs a value for this fieldInfo from an object for a given instance. Supported conversions are the following :
Date, Long, String Date

Overrides:
getValueFromObject in class LyFieldInfo
Parameters:
object - The peer value.
instance - Instance containing the required value (could be null). This instance is provided to be able to construct a value for complex bindings (bindings involving other fields).
Returns:
The logical value that was built (instance of the class returned from getValueClass).
Throws:
LyUnsupportedFieldBindingException - If the requested conversion if none of the supported conversions.
See Also:
LyFieldInfo.getPeerValue(java.lang.Object, java.lang.Class, leon.data.LyObject), LyFieldBinding

getPeerValue

public java.lang.Object getPeerValue(java.lang.Object value,
                                     java.lang.Class<?> objectClass,
                                     LyObject instance)
Returns an object of the given class from a value of this fieldInfo. Supported conversions are the following :
Date Date, Long, String

Overrides:
getPeerValue in class LyFieldInfo
Parameters:
value - Value of this fieldInfo. This value is an instance of the class returned by getValueClass method.
objectClass - Expected class of the physical value.
instance - Instance containing the given value (could be null).
Throws:
LyUnsupportedFieldBindingException - If the requested conversion if none of the supported conversions.
See Also:
LyFieldInfo.getValueClass()

getType

public LyDateFieldInfo.Type getType()
Accessor to the date type.

Returns:
Date type.

getDefaultValue

public java.lang.Object getDefaultValue()
Gets default value for this date field.

Overrides:
getDefaultValue in class LyFieldInfo
Returns:
Default value for this date field. The returned value is an instance of the class returned by getValueClass.

getInternalDefaultValue

public java.lang.String getInternalDefaultValue()
Gets the raw default value as it is stored in the meta-model, without any translation or formatting. Method inserted for the needs of the meta-model editor.

Returns:
Default value for this date field as it was originally stored.

getDisplayFormat

public java.lang.String getDisplayFormat()
Accessor for the display format property of this date field.

Returns:
The display format, or null if no format was set.

getFormat

public java.lang.String getFormat()
Gets the internal format as a string : the format used for selecting dates inside views. This format is different from the display format. The meaning of this format depends on the date type.

Overrides:
getFormat in class LyFieldInfo
Returns:
the internal format and create it if it does not exists.

isWithTimeZone

public boolean isWithTimeZone()
Checks whether this date field is using time zone during input

Returns:
True if the date field is using time zone for input, false otherwise.

checkDate

public static java.lang.String checkDate(java.lang.String val,
                                         java.text.SimpleDateFormat currentDateFormat)
Checks the date value according to a date format.

Parameters:
val - string to parse as a date
currentDateFormat - expected for the date
Returns:
null if an error occured

dateFormatFactory

public java.text.DateFormat dateFormatFactory()
Creates a new DateFormat instance of the given type.

Returns:
a new DateFormat instance.
See Also:
LyEnvironment.dateFormatFactory(int)

getStringDateFormat

public java.lang.String getStringDateFormat()
Returns the string representing the date format of the given type.

Returns:
a string representing the format.
See Also:
LyEnvironment.dateFormatFactory(int)

convertToFieldUnit

public java.lang.Object convertToFieldUnit(java.lang.Object value,
                                           LyUnit unit)
Convert a value from the field unit to the given unit.

Overrides:
convertToFieldUnit in class LyFieldInfo
Parameters:
value - The value to convert.
unit - The new unit.
Returns:
The value converted from the reference unit.

convertFromFieldUnit

public java.lang.Object convertFromFieldUnit(java.lang.Object value,
                                             LyUnit unit)
Convert a value to the field unit from another unit.

Overrides:
convertFromFieldUnit in class LyFieldInfo
Parameters:
value - The value to convert.
unit - The old unit.
Returns:
The value converted to the field unit.

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com