LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.data
Class LyChoiceValue

java.lang.Object
  extended by leon.data.LyValue
      extended by leon.data.LyFieldInfoValue
          extended by leon.data.LyChoiceValue

public final class LyChoiceValue
extends LyFieldInfoValue

This class offers methods for constructing, accessing and modifying values corresponding to a LyChoiceFieldInfo.

See Also:
LyChoiceFieldInfo, LyObject

Field Summary
static java.lang.String __VERSION
          File version.
 
Constructor Summary
LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo)
          Constructs an empty choice value for the given choice field.
LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo, java.util.BitSet value)
          Constructs a choice value for the given choice field from a BitSet.
LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo, int value)
          Constructs a choice value for the given choice field from an int.
LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo, short value)
          Constructs a choice value for the given choice field from a short.
LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo, java.lang.Short value)
          Constructs a choice value for the given choice field from a Short object.
LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo, java.lang.String value)
          Constructs a choice value for the given choice field from a string.
 
Method Summary
 void checkIndex(int index)
          Method for checking if index passed to methods is valid or not.
 void clearOption(short index)
          Clears an option in this choice value.
 java.util.BitSet getBitSetValue()
          Gets value of this choice value as a BitSet.
 java.lang.String getName(int index)
          Gets the name of the specified selected option in this choice value.
 java.lang.Object getOptionValue(int index)
          Gets the value of the specified selected option in this choice value.
 java.lang.Short getShortValue()
          Gets value of this choice value as a Short.
 java.lang.String getString(int index)
          Gets the id of the specified selected option in this choice value.
 java.lang.String getValue(int level)
          Return the value for a given level.
 java.lang.String getValue(int level, int index)
          Return the value for a specific index at the given level.
 short getValueCount()
          Gets number of selected options in this choice value.
 boolean isSelected(java.lang.Object value)
          Checks an option with the given value, id or name is selected in this choice value.
 boolean isSelected(short index)
          Checks if the option at the given index is selected or not in this choice value.
 void setOption(short index)
          Sets an option in this choice value.
 short shortValue()
          Gets value of this choice value as a short.
 
Methods inherited from class leon.data.LyFieldInfoValue
compare, contains, equals, equals, getFieldInfo, getName, getName, getShortName, getString
 
Methods inherited from class leon.data.LyValue
getField, getValue, isNull, setValue, toString
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version.

See Also:
Constant Field Values
Constructor Detail

LyChoiceValue

public LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo)
Constructs an empty choice value for the given choice field.

Parameters:
choiceFieldInfo - Choice fieldInfo for which a value is created.

LyChoiceValue

public LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo,
                     java.lang.String value)
Constructs a choice value for the given choice field from a string.

Parameters:
choiceFieldInfo - Choice fieldInfo for which a value is created.
value - String value. If the choice field is multiple, several options may be selected from the same string, in that case, the different sub-strings corresponding to each option must be separated by LyApplication.VALUE_SEP. For one option, the given string can be (in this order) : the internal value of the option, its id or its the name (untranslated).
See Also:
LyChoiceFieldInfo.parse(java.lang.String)

LyChoiceValue

public LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo,
                     short value)
Constructs a choice value for the given choice field from a short.

Parameters:
choiceFieldInfo - Choice fieldInfo for which a value is created.
value - Value passed as a short. This short value represents the position of the chosen option in options list (0 is the firs one).
Throws:
java.lang.IllegalArgumentException - If the value is negative.
java.lang.IllegalArgumentException - If the value is greater or equal to number of options in the given choice.

LyChoiceValue

public LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo,
                     int value)
Constructs a choice value for the given choice field from an int.

Parameters:
choiceFieldInfo - Choice fieldInfo for which a value is created.
value - Value passed as an int. This integer value represents the position of the chosen option in options list (0 is the firs one).
Throws:
java.lang.IllegalArgumentException - If the value is negative.
java.lang.IllegalArgumentException - If the value is greater or equal to number of options in the given choice.

LyChoiceValue

public LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo,
                     java.lang.Short value)
Constructs a choice value for the given choice field from a Short object.

Parameters:
choiceFieldInfo - Choice fieldInfo for which a value is created.
value - Value passed as a Short. This Short value represents the position of the chosen option in options list (0 is the firs one).
Throws:
java.lang.IllegalArgumentException - If the value is negative.
java.lang.IllegalArgumentException - If the value is greater or equal to number of options in the given choice.

LyChoiceValue

public LyChoiceValue(LyChoiceFieldInfo choiceFieldInfo,
                     java.util.BitSet value)
Constructs a choice value for the given choice field from a BitSet. Each bit of the given BitSet indicates if the option at the same position in choice options list is selected.

Parameters:
choiceFieldInfo - Choice fieldInfo for which a value is created.
value - Value passed as a BitSet.
Throws:
java.lang.IllegalStateException - If the choice field is not multiple.
Method Detail

checkIndex

public void checkIndex(int index)
Method for checking if index passed to methods is valid or not.

Parameters:
index - index to check
Throws:
java.lang.IllegalArgumentException - If the given index is negative.
java.lang.IllegalArgumentException - If the given index is greater or equal to the number of options of the choice field.

shortValue

public short shortValue()
Gets value of this choice value as a short.

Returns:
A short corresponding to this value.

getShortValue

public java.lang.Short getShortValue()
Gets value of this choice value as a Short.

Returns:
A Short corresponding to this value.
Throws:
java.lang.IllegalStateException - If the choice field is multiple.

getBitSetValue

public java.util.BitSet getBitSetValue()
Gets value of this choice value as a BitSet.

Returns:
A BitSet corresponding to this value.
Throws:
java.lang.IllegalStateException - If the choice field is not multiple.

getValueCount

public short getValueCount()
Gets number of selected options in this choice value.

Returns:
Number of selected options (0 if no option is selected in this value, can't be greater than 1 if the corresponding choice field is not multiple).

getString

public java.lang.String getString(int index)
Gets the id of the specified selected option in this choice value.

Parameters:
index - Index of requested option id.
Returns:
the id of the option
Throws:
java.lang.IllegalArgumentException - If index is negative.
java.lang.IllegalArgumentException - If index is greater than the number of options selected in this value.

getName

public java.lang.String getName(int index)
Gets the name of the specified selected option in this choice value.

Parameters:
index - Index of requested option name.
Returns:
the name of the option
Throws:
java.lang.IllegalArgumentException - If index is negative.
java.lang.IllegalArgumentException - If index is greater than the number of options selected in this value.

getValue

public java.lang.String getValue(int level)
Return the value for a given level. If the choice is multiple, the result is the concatenation of the ids of all selected option(s) for the given level

Parameters:
level - the requested level
Returns:
the value

getValue

public java.lang.String getValue(int level,
                                 int index)
Return the value for a specific index at the given level.

Parameters:
level - the requested level
index - the index of the requested option id
Returns:
the resulting id

isSelected

public boolean isSelected(short index)
Checks if the option at the given index is selected or not in this choice value. If the choice field is multiple, several choices may be selected simultaneously.

Parameters:
index - Index of the tested option. The given index is checked by method checkIndex, this method may throw exceptions.
Returns:
True if selected, false otherwise.
See Also:
checkIndex(int)

isSelected

public boolean isSelected(java.lang.Object value)
Checks an option with the given value, id or name is selected in this choice value. If the choice field is multiple, several choices may be selected simultaneously.

Parameters:
value - Value, id or name of the tested option.
Returns:
True if selected, false otherwise.
Throws:
java.lang.IllegalArgumentException - if no option corresponds to the given value, id or name.
See Also:
checkIndex(int)

setOption

public void setOption(short index)
Sets an option in this choice value. Does nothing if the corresponding option was already selected. If the choice field is not multiple, deselects the previous selected one.

Parameters:
index - Index of the set option. The given index is checked by method checkIndex, this method may throw exceptions.
See Also:
checkIndex(int)

clearOption

public void clearOption(short index)
Clears an option in this choice value. Does nothing if the corresponding option was not selected.

Parameters:
index - Index of the cleared option. The given index is checked by method checkIndex, this method may throw exceptions.
See Also:
checkIndex(int)

getOptionValue

public java.lang.Object getOptionValue(int index)
Gets the value of the specified selected option in this choice value.

Parameters:
index - Index of requested option id.
Returns:
the value of the selected option
Throws:
java.lang.IllegalArgumentException - If index is negative.
java.lang.IllegalArgumentException - If index is greater than the number of options selected in this value.

(c) January 2013 - W4 S.A.

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