Class CmsSelectWidgetOption
- java.lang.Object
-
- org.opencms.widgets.CmsSelectWidgetOption
-
public class CmsSelectWidgetOption extends java.lang.Object
An option of a select type widget.If options are passed from XML content schema definitions as widget configuration options, the following syntax is used for defining the option values:
value='{text}' default='{true|false}' option='{text}' help='{text}|{more option definitions}For example:
value='value1' default='true' option='option1' help='help1'|value='value2' option='option2' help='help2'The elements
default,optionandhelpare all optional, only avaluemust be present in the input. There should be only onedefaultset totruein the input, if more than one is detected, only the firstdefaultfound is actually used. If nooptionis given, the value ofoptiondefaults to the value of the givenvalue. If nohelpis given, the default isnull.Shortcut syntax options:
If you don't specify the
valuekey, the value is assumed to start at the first position of an option definition. In this case the value must not be surrounded by the'chars. Example:value='some value' default='true'can also be written assome value default='true'.Only if you use the short value definition as described above, a default value can be marked with a
*at the end of the value definition. Example:value='some value' default='true'can also be written assome value*.Only if you use the short value definition as described above, you can also append the
optionto thevalueusing a:. In this case no'must surround theoption. Please keep in mind that in this case the value itself can not longer contain a:char, since it would then be interpreted as a delimiter. Example:value='some value' option='some option'can also be written assome value:some option.Any combinations of the above described shortcuts are allowed in the configuration option String. Here are some more examples of valid configuration option Strings:
1*|2|3|4|5|6|7
1 default='true'|2|3|4|5|6|7
value='1' default='true'|value='2'|value='3'
value='1'|2*|value='3'
1*:option text|2|3|4
1* option='option text' help='some'|2|3|4Please note: If an entry in the configuration String is malformed, this error is silently ignored (but written to the log channel of this class at
INFOlevel.- Since:
- 6.0.0
-
-
Constructor Summary
Constructors Constructor Description CmsSelectWidgetOption(java.lang.String value)Creates a new select option for the given value.CmsSelectWidgetOption(java.lang.String value, boolean isDefault)Creates a new select option form the given values.CmsSelectWidgetOption(java.lang.String value, boolean isDefault, java.lang.String optionText)Creates a new select option form the given values.CmsSelectWidgetOption(java.lang.String value, boolean isDefault, java.lang.String optionText, java.lang.String helpText)Creates a new select option form the given values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcreateConfigurationString(java.util.List<CmsSelectWidgetOption> options)Returns a select widget configuration String created from the given list of select options.booleanequals(java.lang.Object obj)static CmsSelectWidgetOptiongetDefaultOption(java.util.List<CmsSelectWidgetOption> options)Returns the default option from the given list of select options, ornullin case there is no default option in the given list.static java.util.List<CmsSelectWidgetOption>getDefaultOptions(java.util.List<CmsSelectWidgetOption> options)Returns a list of default options from the given list of select options.java.lang.StringgetHelp()Returns the (optional) help text of this select option.java.lang.StringgetOption()Returns the option text of this select option.java.lang.StringgetValue()Returns the value of this select option.inthashCode()booleanisDefault()Returnstrueif this is the default value of the selection.static java.util.List<CmsSelectWidgetOption>parseOptions(java.lang.String input)Parses a widget configuration String for select option values.static java.lang.String[]splitOptions(java.lang.String input)Splits the options string at every unescaped input delimiter, i.e., every unescaped "|".java.lang.StringtoString()
-
-
-
Constructor Detail
-
CmsSelectWidgetOption
public CmsSelectWidgetOption(java.lang.String value)
Creates a new select option for the given value.- Parameters:
value- the value of this select option
-
CmsSelectWidgetOption
public CmsSelectWidgetOption(java.lang.String value, boolean isDefault)
Creates a new select option form the given values.- Parameters:
value- the value of this select optionisDefault- indicates if this is the default value of the selection (default isfalse)
-
CmsSelectWidgetOption
public CmsSelectWidgetOption(java.lang.String value, boolean isDefault, java.lang.String optionText)
Creates a new select option form the given values.- Parameters:
value- the value of this select optionisDefault- indicates if this is the default value of the selection (default isfalse)optionText- the (optional) display text of this select option
-
CmsSelectWidgetOption
public CmsSelectWidgetOption(java.lang.String value, boolean isDefault, java.lang.String optionText, java.lang.String helpText)
Creates a new select option form the given values.- Parameters:
value- the value of this select optionisDefault- indicates if this is the default value of the selection (default isfalse)optionText- the (optional) display text of this select optionhelpText- the (optional) help text of this select option
-
-
Method Detail
-
createConfigurationString
public static java.lang.String createConfigurationString(java.util.List<CmsSelectWidgetOption> options)
Returns a select widget configuration String created from the given list of select options.If an element found in the given list is not of type
, it is ignored.CmsSelectWidgetOption- Parameters:
options- the list of select options to create the configuration String for- Returns:
- a select widget configuration String created from the given list of select options
-
getDefaultOption
public static CmsSelectWidgetOption getDefaultOption(java.util.List<CmsSelectWidgetOption> options)
Returns the default option from the given list of select options, ornullin case there is no default option in the given list.If an element found in the given list is not of type
, this is ignored.CmsSelectWidgetOption- Parameters:
options- the list of select options to get the default from- Returns:
- the default option from the given list of select options, or
nullin case there is no default option
-
getDefaultOptions
public static java.util.List<CmsSelectWidgetOption> getDefaultOptions(java.util.List<CmsSelectWidgetOption> options)
Returns a list of default options from the given list of select options.If an element found in the given list is not of type
, this is ignored.CmsSelectWidgetOption- Parameters:
options- the list of select options to get the default from- Returns:
- a list of
objectsCmsSelectWidgetOption
-
parseOptions
public static java.util.List<CmsSelectWidgetOption> parseOptions(java.lang.String input)
Parses a widget configuration String for select option values.If the input is
nullor empty, ais returned.Collections.EMPTY_LISTPlease note: No exception is thrown in case the input is malformed, all malformed entries are silently ignored.
- Parameters:
input- the widget input string to parse- Returns:
- a List of
elementsCmsSelectWidgetOption
-
splitOptions
public static java.lang.String[] splitOptions(java.lang.String input)
Splits the options string at every unescaped input delimiter, i.e., every unescaped "|".- Parameters:
input- the options string- Returns:
- the array with the various options
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
getHelp
public java.lang.String getHelp()
Returns the (optional) help text of this select option.- Returns:
- the (optional) help text of this select option
-
getOption
public java.lang.String getOption()
Returns the option text of this select option.If this has not been set, the result of
is returned, there will always be a result other thangetValue()nullreturned.- Returns:
- the option text of this select option
-
getValue
public java.lang.String getValue()
Returns the value of this select option.- Returns:
- the value of this select option
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
isDefault
public boolean isDefault()
Returnstrueif this is the default value of the selection.- Returns:
trueif this is the default value of the selection
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
-