LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.info
Class LyChoiceFieldInfo

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

public final class LyChoiceFieldInfo
extends LyFieldInfo

This class implements the description of an enumerated field (choice with finite number of options) of a class info. Choice fields are defined with a set of options (LyChoiceOption).

Options are pairs of displayable values and internal value.

Choice fieldInfo may also accept "multiple" values : several options may be selected simultaneously.

See also tag of leon.dtd

See Also:
LyChoiceOption

Nested Class Summary
static class LyChoiceFieldInfo.SortBy
          "Sort by" values.
static class LyChoiceFieldInfo.Type
          Choice types.
 
Nested classes/interfaces inherited from class leon.info.LyTag
LyTag.Model
 
Field Summary
static java.lang.String __version
           
 
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.
 java.lang.String checkValue(LyEnvironment environment, java.lang.Object fieldValue)
          Checks the given value : the value must correspond to options of the choice.
 int compare(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Compare two values of this fieldInfo.
 boolean contains(java.lang.Object value1, java.lang.Object value2, java.util.BitSet modifiers)
          Checks if the second value is contained in the first one, for this field.
 boolean doGroupsHaveValue()
          Checks whether options groups have value or not.
 LyChoiceItem getChoiceItem(short index)
          Gets an item from the items list at a given position.
 LyChoiceItem getChoiceItem(java.lang.String string)
          Gets an item from the items list by its id, name or value.
 short getChoiceItemCount()
          Gets items count.
 LyChoiceOption getChoiceOption(short index)
          Gets an option from the option list at a given position.
 LyChoiceOption getChoiceOption(java.lang.String string)
          Gets an item from the items list by its id, name or value.
 LyChoiceOption getChoiceOptionByValue(java.lang.Object value)
          Gets an option from the option list from the internal value.
 short getChoiceOptionCount()
          Gets options count.
 LyChoiceOptionGroup getChoiceOptionGroup()
          Accessor to the choice option group associated with this choice field.
 LyInfoList<LyChoiceOptionGroup> getChoiceOptionGroups()
           
 LyInfoList<LyChoiceOptionGroup> getChoiceOptionGroups(boolean godown)
          Utility method to retrieve options group of this choice field.
 LyInfoList<LyChoiceOptionGroup> getChoiceOptionGroups(LyChoiceOption option)
          Get all groups where the given option is found.
 short getChoiceOptionIndex(java.lang.Object value)
          Gets the internal index (position) of an option from its internal value, its id or its name.
 LyInfoList<LyChoiceOption> getChoiceOptions()
          Returns the list of options available on this choice field.
 LyInfoList<LyChoiceOption> getChoiceOptions(boolean sorted)
          Returns the sorted list of options available on this choice field.
 LyChoiceFieldInfo getContextField()
          Gets the context field for this choice field info.
 LyFilterExpression.Condition[] getFilterConditions()
          Returns the filter conditions authorized on this field.
 short getIndex(LyChoiceItem item)
          Gets index of given item in the items list.
 short getIndex(LyChoiceOption option)
          Gets index of given option in the options list.
 int getNCols()
          Gets the preferred number of columns shown to the user at the same time.
 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.
 LyChoiceFieldInfo.SortBy getSortBy()
          Accessor to the type of sorting for this choice field.
 LyInfoList<LyChoiceOption> getTableOptions()
          Utility method to retrieve options with table attribute set.
 LyChoiceFieldInfo.Type getType()
          Accessor to the choice 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 isDictionary()
          Compute if the choice is a dictionary or not.
 boolean isMultiple()
          Accessor to the multiple property.
 boolean isNot()
          Accessor to the not property.
 java.lang.Object parse(java.lang.String stringValue)
          Builds internal value for an instance of LyChoiceFieldInfo 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 toName(java.lang.Object fieldValue, java.lang.String separator)
          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 This method is used when presenting values in tables.
 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).
 
Methods inherited from class leon.info.LyFieldInfo
addConstraint, addDepend, addDepend, buildLyValue, checkJavaName, compare, compute, compute, compute, compute, contains, controlValue, convertFromFieldUnit, convertToFieldUnit, 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, 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
Method Detail

getValueClass

public java.lang.Class<?> getValueClass()
Returns class of values for this field. The value class corresponding to a choice 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:
LyChoiceValue, LyBooleanValue

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 :
Short, String Short
BitSet, Number, boolean[], String[] BitSet

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 :
Short Number, String
BitSet BitSet, Long, Integer, boolean[], String[], Object[]

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

parse

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

toName

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

Parameters:
Object - fieldValue : The fieldValue to display.
String - separator : The value of separator between field values.
Returns:
String : Formated String.

toShortName

public java.lang.String toShortName(java.lang.Object fieldValue)
Returns 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 using aliases of the options.

Overrides:
toShortName in class LyFieldInfo
Returns:
The value presented as a short displayable String.
See Also:
LyFieldInfo.getValueClass(), LyFieldInfo.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 method).

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

checkValue

public java.lang.String checkValue(LyEnvironment environment,
                                   java.lang.Object fieldValue)
Checks the given value : the value must correspond to options of the choice.

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

contains

public boolean contains(java.lang.Object value1,
                        java.lang.Object value2,
                        java.util.BitSet modifiers)
Checks if the second value is contained in the first one, for this field.

Overrides:
contains in class LyFieldInfo
Parameters:
value1 - First value.
value2 - Second value.
modifiers - Modifiers used for checking (see MOD_XXX constants of LyFilterExpression).
Returns:
True if the second value is contained in the first one, else returns false.

getType

public LyChoiceFieldInfo.Type getType()
Accessor to the choice type.

Returns:
Choice type.

isMultiple

public boolean isMultiple()
Accessor to the multiple property.

Overrides:
isMultiple in class LyFieldInfo
Returns:
True if this field may have several values, false otherwise.

isNot

public boolean isNot()
Accessor to the not property.

Returns:
True if this field is inverted during user input (BOOLEAN only), false otherwise.

getSortBy

public LyChoiceFieldInfo.SortBy getSortBy()
Accessor to the type of sorting for this choice field.

Returns:
Type of sorting used for this choice field.

getChoiceOption

public LyChoiceOption getChoiceOption(short index)
Gets an option from the option list at a given position.

Parameters:
index - Index of the searched option.
Returns:
The option found, null otherwise.

getIndex

public short getIndex(LyChoiceOption option)
Gets index of given option in the options list.

Parameters:
option - Searched option.
Returns:
Index of the given option if found, -1 otherwise.

getChoiceOptionCount

public short getChoiceOptionCount()
Gets options count.

Returns:
Return the number of options in this choice.

getChoiceOptions

public LyInfoList<LyChoiceOption> getChoiceOptions()
Returns the list of options available on this choice field.

Returns:
List of options of this choice field.

getChoiceOptions

public LyInfoList<LyChoiceOption> getChoiceOptions(boolean sorted)
Returns the sorted list of options available on this choice field.

Parameters:
sorted - Boolean indicating if list must be sorted according to sortBy criterion.
Returns:
Sorted list of options of this choice field.

getChoiceOptionGroup

public LyChoiceOptionGroup getChoiceOptionGroup()
Accessor to the choice option group associated with this choice field.

Returns:
the choiceOptionGroup

getChoiceOptionGroups

public LyInfoList<LyChoiceOptionGroup> getChoiceOptionGroups(LyChoiceOption option)
Get all groups where the given option is found.


getChoiceItem

public LyChoiceItem getChoiceItem(short index)
Gets an item from the items list at a given position.

Parameters:
index - Index of the searched item.
Returns:
The item found, null otherwise.

getIndex

public short getIndex(LyChoiceItem item)
Gets index of given item in the items list.

Parameters:
item - Searched item.
Returns:
Index of the given item if found, -1 otherwise.

getChoiceItemCount

public short getChoiceItemCount()
Gets items count.

Returns:
Return the number of items in this choice.

getChoiceOption

public LyChoiceOption getChoiceOption(java.lang.String string)
Gets an item from the items list by its id, name or value. Search is made by item id, then by item name and finally using the internal value converted to a string.

Parameters:
string - Searched string (id, name or value transformed in String).
Returns:
The item found, or null if it could not be found.

getChoiceItem

public LyChoiceItem getChoiceItem(java.lang.String string)
Gets an item from the items list by its id, name or value. Search is made by item id, then by item name and finally using the internal value converted to a string.

Parameters:
string - Searched string (id, name or value transformed in String).
Returns:
The item found, or null if it could not be found.

getChoiceOptionByValue

public LyChoiceOption getChoiceOptionByValue(java.lang.Object value)
Gets an option from the option list from the internal value.

Parameters:
value - Internal value from which an option is searched.
Returns:
Option corresponding to the given value if found, or null if it could not be found.

getChoiceOptionIndex

public short getChoiceOptionIndex(java.lang.Object value)
Gets the internal index (position) of an option from its internal value, its id or its name.

Parameters:
value - Value (or id, or name) from which an option is searched.
Returns:
Index of the option corresponding to the given value (or id, or name).
Throws:
java.lang.IllegalArgumentException - if no option corresponds to the given value (or id, or name).

getNCols

public int getNCols()
Gets the preferred number of columns shown to the user at the same time.

Returns:
Number of columns, or -1 if no preference is given.

getContextField

public LyChoiceFieldInfo getContextField()
Gets the context field for this choice field info.

Returns:
the context field of this choice field info, null if none

getTableOptions

public LyInfoList<LyChoiceOption> getTableOptions()
Utility method to retrieve options with table attribute set.

Returns:
List of options shown in tables (all if no option is marked).

getChoiceOptionGroups

public LyInfoList<LyChoiceOptionGroup> getChoiceOptionGroups()

getChoiceOptionGroups

public LyInfoList<LyChoiceOptionGroup> getChoiceOptionGroups(boolean godown)
Utility method to retrieve options group of this choice field.

Returns:
List of options group.

isDictionary

public boolean isDictionary()
Compute if the choice is a dictionary or not.

Parameters:
choice - the choice
Returns:
true if the choice is a dictionary

doGroupsHaveValue

public boolean doGroupsHaveValue()
Checks whether options groups have value or not.


(c) January 2013 - W4 S.A.

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