LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyNumberFieldInfo

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.LyNumberFieldInfo
All Implemented Interfaces:
java.lang.Cloneable, LyField, LyCommentInterface

public final class LyNumberFieldInfo
extends LyFieldInfo

This class implements the description of numeric fields such as integers, floats, percent ...

The different types of numbers supported are represented as public, static attributes, named TYPE_XXX. Supported types are INT, SHORT, LONG, FLOAT, DOUBLE.

A NumbeFieldInfo is the implementation of a numeric attribute in an application class. In addition to standard fieldInfo properties, instances of LyNumberFieldInfo also implements a minimum and a maximum value. Moreover, it is possible to specify a pitch increment (or decrement) which may be used when editing the field.

When real numbers (FLOAT, DOUBLE) are used, the number of decimals can be specified.

A unit may also be associated to this kind of field, this unit is only used to be displayed to the end-user when values of number fields are shown.

A function may be associated to a number field. This function defines the method to calculate the value corresponding to a column of values when this field is shown in a table. Supported functions are given has public, static attributes, named Function.XXX. Accepted values are : SUM, AVERAGE, NONE (no function).

Finally, number fields may also have a formula. This formula is a simple mathematic expression involving other fields of the same application class, used to calculate values for the number field (for example : suppose that this field represents a tax, and that this tax is ration of a price, the formula could be "(price * 10)/100").

See also tag of leon.dtd


Nested Class Summary
static class LyNumberFieldInfo.Function
          Functions.
static class LyNumberFieldInfo.Type
          Number types.
 
Nested classes/interfaces inherited from class leon.info.LyTag
LyTag.Model
 
Field Summary
static java.lang.String __VERSION
           
static double LY_DOUBLE_MIN_VALUE
           
static float LY_FLOAT_MIN_VALUE
           
static boolean USE_PRECISION
          Indicates whether precision on numbers must be used to compare two values.
 
Fields inherited from class leon.info.LyFieldInfo
__version, 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
NULL, PART_ALL, PART_BIND, PART_DATA, PART_GUI, PART_LABEL
 
Method Summary
 void allowFormatAutomaticUpdate(boolean update)
          Sets the parameter indicating whether the format may be changed automatically.
 LyValue buildFieldValue(java.lang.Object value)
          Builds the appropriate LyValue corresponding to this field for the given value object.
 java.lang.String checkValue(LyEnvironment environment, java.lang.Object fieldValue)
          Checks the given value : - the value must be greater or equal to min value, - the value must be lower or equal to max value.
 int compare(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Compare two numeric values for the specified fieldInfo.
 java.lang.Object compute(LyObjectList objectList, boolean importField)
          Method for computing a value using function associated to this field for a given objects list.
 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.
 int getDecimals()
          Gets the number of digits displayed when shown to the user.
 java.lang.Number getDefault()
          Gets the default value.
 LyFilterExpression.Condition[] getFilterConditions()
          Returns the filter conditions authorized on this field.
 LyNumberFieldInfo.Function getFunction()
          Gets the function associated to this number field.
 java.lang.Number getMax()
          Gets the maximum value for this field, or null if no maximum value is specified.
 java.lang.Number getMin()
          Gets the minimum value for this field, or null if no minimum value is specified.
 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.Number getPitch()
          Gets the pitch (increment).
 java.lang.Number getPrecision()
          Gets the precision used for computing.
 LyNumberFieldInfo.Type getType()
          Accessor to the type of the field.
 java.lang.String getUnit()
          Deprecated. see getFieldUnit()
 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 isModulo()
          Checks if this number is a modulo.
 java.lang.Object parse(java.lang.String stringValue)
          Builds internal value for an instance of LyNumberFieldInfo from a string (previously constructed by toString).
 java.lang.Object processValue(java.lang.Object value)
          Processes the given value to get the right value before transmitting it to the peer layer.
 java.lang.String toName(java.lang.Object fieldValue)
          Return the specified value for this field as a "displayable" string.
 java.lang.String toShortName(java.lang.Object fieldValue)
          Return the specified value for this field as a short "displayable" string.
 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).
 
Methods inherited from class leon.info.LyFieldInfo
addConstraint, addDepend, addDepend, buildLyValue, checkJavaName, compare, compute, compute, compute, contains, contains, controlValue, encodeValue, endsWith, equals, equals, fromFieldTag, getBean, getBeans, getBehaviorClass, getBehaviorClassName, getBinding, getCaptionConstraint, getConstraint, getConstraint, getConstraints, getControl, getControlCount, getControls, getDefaultJavaName, getDefaultValue, getDepends, getDepends, getFieldBean, getFieldGroup, getFieldTab, getFieldUnit, getFilterModifiers, getFormat, 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, 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

LY_DOUBLE_MIN_VALUE

public static final double LY_DOUBLE_MIN_VALUE
See Also:
Constant Field Values

LY_FLOAT_MIN_VALUE

public static final float LY_FLOAT_MIN_VALUE
See Also:
Constant Field Values

USE_PRECISION

public static boolean USE_PRECISION
Indicates whether precision on numbers must be used to compare two values.

Method Detail

getType

public LyNumberFieldInfo.Type getType()
Accessor to the type of the field. Meaning of this property depends on the implementation in subclasses

Returns:
Type of this fieldInfo, or TYPE_DEFAULT if type is not set.

getValueClass

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

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:
LyNumberValue

processValue

public java.lang.Object processValue(java.lang.Object value)
Processes the given value to get the right value before transmitting it to the peer layer.

Overrides:
processValue in class LyFieldInfo
Parameters:
value - Value to process.
Returns:
The processed value.

parse

public java.lang.Object parse(java.lang.String stringValue)
                       throws LyFieldInfoFormatException
Builds internal value for an instance of LyNumberFieldInfo 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)

toName

public java.lang.String toName(java.lang.Object fieldValue)
Return 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()

toShortName

public java.lang.String toShortName(java.lang.Object fieldValue)
Return the specified value for this field as a short "displayable" string. This method is used when presenting values in tables. In that case, values are presented whithout unit.

Overrides:
toShortName in class LyFieldInfo
Returns:
The value presented as a short displayable String.
See Also:
toName(java.lang.Object)

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).

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

allowFormatAutomaticUpdate

public void allowFormatAutomaticUpdate(boolean update)
Sets the parameter indicating whether the format may be changed automatically. If true (default value), format of this number field will be computed automatically when the toShortName(Object) is called if it has not been set yet. Otherwise, format will not be set.

Parameters:
update - true if format must be changed automatically, false otherwise.

checkValue

public java.lang.String checkValue(LyEnvironment environment,
                                   java.lang.Object fieldValue)
Checks the given value : - the value must be greater or equal to min value, - the value must be lower or equal to max value.

Overrides:
checkValue in class LyFieldInfo
Parameters:
environment - Environment giving the user language if a message has to be produced.
Returns:
Returns an error message if the value is incorrect, null otherwise.
See Also:
LyFieldInfo.getValueClass()

compare

public int compare(java.lang.Object value1,
                   java.lang.Object value2,
                   java.util.BitSet modifiers)
Compare two numeric values for the specified fieldInfo. If a precision is specified on the fieldInfo, it is used for equality comparison.

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

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 :
Number, String, Character Short, Integer
Number, String Long, Double, Float

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 given object can't be converted to a value of this field.
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 :
Short, Integer, Long, Double, Float Number, String, Character

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()

compute

public java.lang.Object compute(LyObjectList objectList,
                                boolean importField)
Method for computing a value using function associated to this field for a given objects list. This method is called when this field is presented in a table that has a footer.

Overrides:
compute in class LyFieldInfo
Parameters:
objectList - List of objects for which a footer value is computed.
importField - True if calling comes on computing of a field import, false otherwise.
Returns:
Value computed with field function for the given objects. Returns null if this field has no associated function.

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.

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.

getMin

public java.lang.Number getMin()
Gets the minimum value for this field, or null if no minimum value is specified.

Returns:
Minimum value of this number field;

getMax

public java.lang.Number getMax()
Gets the maximum value for this field, or null if no maximum value is specified.

Returns:
Maximum value of this number field;

isModulo

public boolean isModulo()
Checks if this number is a modulo.

Returns:
True if this number is a modulo, false otherwise.

getPitch

public java.lang.Number getPitch()
Gets the pitch (increment).

Returns:
Current pitch or null if no pitch is specified.

getDecimals

public int getDecimals()
Gets the number of digits displayed when shown to the user.

Returns:
Number of digits or -1 if no limit is specified.

getPrecision

public java.lang.Number getPrecision()
Gets the precision used for computing.

Returns:
Precision used.

getDefault

public java.lang.Number getDefault()
Gets the default value. This default value if an instance of the class returned by getValueClass.

Returns:
Default value for this fieldInfo, null if no default value was set.

getUnit

public java.lang.String getUnit()
Deprecated. see getFieldUnit()

Gets the unit string. If the unit is not null, this symbol is shown after the value when displayed to the user.

Returns:
Current unit, or null if none is specified.

getFunction

public LyNumberFieldInfo.Function getFunction()
Gets the function associated to this number field. The function is used for computing the value displayed to the end-user when presenting a table view that contains a column with a footer showing values corresponding to this number field.

Returns:
Current function or null if no function is set.

(c) January 2013 - W4 S.A.

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