Package com.xpn.xwiki.objects.classes
Class ListClass
- java.lang.Object
-
- com.xpn.xwiki.objects.BaseElement<R>
-
- com.xpn.xwiki.objects.BaseCollection<ClassPropertyReference>
-
- com.xpn.xwiki.objects.classes.PropertyClass
-
- com.xpn.xwiki.objects.classes.ListClass
-
- All Implemented Interfaces:
PropertyClassInterface
,ElementInterface
,ObjectInterface
,PropertyInterface
,Serializable
,Cloneable
,Comparable<PropertyClass>
- Direct Known Subclasses:
DBListClass
,GroupsClass
,LevelsClass
,StaticListClass
,UsersClass
public abstract class ListClass extends PropertyClass
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ListClass.MapComparator
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SEPARATOR
Default separator/delimiter to use to split or join a list stored as a string.static String
DISPLAYTYPE_CHECKBOX
static String
DISPLAYTYPE_INPUT
static String
DISPLAYTYPE_RADIO
static String
DISPLAYTYPE_SELECT
static String
FREE_TEXT_ALLOWED
static String
FREE_TEXT_DISCOURAGED
static String
FREE_TEXT_FORBIDDEN
static char
SEPARATOR_ESCAPE
Used to escape a separator character inside a string serialized list item.-
Fields inherited from class com.xpn.xwiki.objects.classes.PropertyClass
cachedCustomDisplayer
-
Fields inherited from class com.xpn.xwiki.objects.BaseCollection
currentReferenceDocumentReferenceResolver, fields, fieldsToRemove, number, relativeEntityReferenceResolver
-
Fields inherited from class com.xpn.xwiki.objects.BaseElement
documentReference, ownerDocument, referenceCache
-
-
Constructor Summary
Constructors Constructor Description ListClass()
ListClass(PropertyMetaClass wclass)
ListClass(String name, String prettyname, PropertyMetaClass wclass)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
void
displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
protected void
displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
protected void
displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
void
displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
void
fromList(BaseProperty<?> property, List<String> list)
Set the passedList
into the passed property.protected void
fromList(BaseProperty<?> property, List<String> list, boolean filterEmptyValues)
Set the passedList
into the passed property.BaseProperty
fromString(String value)
BaseProperty
fromStringArray(String[] strings)
String
getDefaultValue()
String
getDisplayType()
protected String
getDisplayValue(Object rawvalue, String name, Map<String,ListItem> map, XWikiContext context)
Search for an internationalizable display text for the current value.String
getDisplayValue(String value, String name, Map<String,ListItem> map, XWikiContext context)
Search for an internationalizable display text for the current value.protected String
getElementValue(Object rawvalue)
If the list is populated with value=name pairs selected from the database, then return only the value.protected String
getFirstSeparator()
String
getFreeText()
abstract List<String>
getList(XWikiContext context)
static List<String>
getListFromString(String value)
Convenience method, using "|" as separator and parsing key=value items.static List<String>
getListFromString(String value, String separators, boolean withMap)
protected static List<String>
getListFromString(String value, String separators, boolean withMap, boolean filterEmptyValues)
abstract Map<String,ListItem>
getMap(XWikiContext context)
static Map<String,ListItem>
getMapFromString(String value)
String
getSeparator()
String
getSeparators()
int
getSize()
String
getSort()
static String
getStringFromList(List<String> list)
Convenience method, using "|" as separator.static String
getStringFromList(List<String> list, String separators)
boolean
isCache()
boolean
isLargeStorage()
boolean
isMultiSelect()
boolean
isPicker()
boolean
isRelationalStorage()
protected <T extends EntityReference>
voidmergeNotOrderedListProperty(BaseProperty<T> currentProperty, BaseProperty<T> previousProperty, BaseProperty<T> newProperty, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
<T extends EntityReference>
voidmergeProperty(BaseProperty<T> currentProperty, BaseProperty<T> previousProperty, BaseProperty<T> newProperty, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
Apply a 3 ways merge on passed current, previous and new version of the same property.BaseProperty
newProperty()
BaseProperty
newPropertyfromXML(org.dom4j.Element ppcel)
void
setCache(boolean cache)
void
setDefaultValue(String separator)
void
setDisplayType(String type)
void
setFreeText(String type)
void
setLargeStorage(boolean largeStorage)
void
setMultiSelect(boolean multiSelect)
void
setPicker(boolean picker)
void
setRelationalStorage(boolean relationalStorage)
void
setSeparator(String separator)
void
setSeparators(String separators)
void
setSize(int size)
void
setSort(String sort)
String
toFormString(BaseProperty property)
List<String>
toList(BaseProperty<?> property)
ListClass
does not produce onlyListProperty
s and this method allows to access the value asList
whatever property is actually storing it.-
Methods inherited from class com.xpn.xwiki.objects.classes.PropertyClass
clone, compareTo, createReference, displayCustom, displayEdit, displayEdit, displayHidden, displayHidden, displayView, displayView, flushCache, fromValue, fromXML, getCachedDefaultCustomDisplayer, getClassName, getClassType, getCustomDisplay, getDefaultCustomDisplayer, getFieldFullName, getFullQueryPropertyName, getHint, getId, getName, getNumber, getObject, getPrettyName, getPrettyName, getTooltip, getTooltip, getTranslatedPrettyName, getValidationMessage, getValidationRegExp, getXClass, getxWikiClass, initLazyCollections, isCustomDisplayed, isDisabled, isUnmodifiable, isValidColumnTypes, renderContentInContext, renderContentInContext, setClassType, setCustomDisplay, setDisabled, setHint, setId, setName, setNumber, setObject, setPrettyName, setTooltip, setUnmodifiable, setValidationMessage, setValidationRegExp, setxWikiClass, toFormString, toString, toXML, toXML, validateProperty
-
Methods inherited from class com.xpn.xwiki.objects.BaseCollection
addField, addPropertyForRemoval, apply, equals, get, getCurrentReferenceDocumentReferenceResolver, getCustomMappingMap, getDateValue, getDiff, getDoubleValue, getField, getFieldList, getFieldsToRemove, getFloatValue, getIntValue, getIntValue, getLargeStringValue, getListValue, getLongValue, getProperties, getPropertyList, getPropertyNames, getRelativeEntityReferenceResolver, getRelativeXClassReference, getSetValue, getSortedIterator, getStringValue, getXClassReference, merge, merge, mergeField, put, removeField, safeget, safeput, setClassName, setDateValue, setDBStringListValue, setDocumentReference, setDoubleValue, setFields, setFieldsToRemove, setFloatValue, setIntValue, setLargeStringValue, setLongValue, setOwnerDocument, setSetValue, setStringListValue, setStringValue, setXClassReference, toXMLString
-
Methods inherited from class com.xpn.xwiki.objects.BaseElement
fromXML, getDocumentReference, getLocalEntityReferenceSerializer, getLocalization, getLocalKey, getLocalUidStringEntityReferenceSerializer, getMergeManager, getOwnerDocument, getReference, getXWikiContext, hashCode, localizePlain, localizePlainOrKey, merge, toString, toXMLString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.xpn.xwiki.objects.ElementInterface
apply, getDocumentReference, getReference, merge, merge, setDocumentReference, toString
-
Methods inherited from interface com.xpn.xwiki.objects.ObjectInterface
get, put, safeget, safeput
-
Methods inherited from interface com.xpn.xwiki.objects.classes.PropertyClassInterface
displayView
-
-
-
-
Field Detail
-
DISPLAYTYPE_INPUT
public static final String DISPLAYTYPE_INPUT
- Since:
- 6.2RC1
- See Also:
- Constant Field Values
-
DISPLAYTYPE_RADIO
public static final String DISPLAYTYPE_RADIO
- Since:
- 6.2RC1
- See Also:
- Constant Field Values
-
DISPLAYTYPE_CHECKBOX
public static final String DISPLAYTYPE_CHECKBOX
- Since:
- 6.2RC1
- See Also:
- Constant Field Values
-
DISPLAYTYPE_SELECT
public static final String DISPLAYTYPE_SELECT
- Since:
- 6.2RC1
- See Also:
- Constant Field Values
-
DEFAULT_SEPARATOR
public static final String DEFAULT_SEPARATOR
Default separator/delimiter to use to split or join a list stored as a string. Not to be confused withgetSeparator()
andgetSeparator()
which are used only for UI view and edit operations.- Since:
- 7.0M2
- See Also:
- Constant Field Values
-
SEPARATOR_ESCAPE
public static final char SEPARATOR_ESCAPE
Used to escape a separator character inside a string serialized list item.- Since:
- 7.0M2
- See Also:
- Constant Field Values
-
FREE_TEXT_DISCOURAGED
public static final String FREE_TEXT_DISCOURAGED
- Since:
- 10.11RC1
- See Also:
- Constant Field Values
-
FREE_TEXT_FORBIDDEN
public static final String FREE_TEXT_FORBIDDEN
- Since:
- 10.11RC1
- See Also:
- Constant Field Values
-
FREE_TEXT_ALLOWED
public static final String FREE_TEXT_ALLOWED
- Since:
- 10.11RC1
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ListClass
public ListClass(String name, String prettyname, PropertyMetaClass wclass)
-
ListClass
public ListClass(PropertyMetaClass wclass)
-
ListClass
public ListClass()
-
-
Method Detail
-
getSeparators
public String getSeparators()
- Returns:
- a string of separator characters used to split/deserialize an input string coming from the UI (filled by the user) that represents a serialized list
- See Also:
displayEdit(StringBuffer, String, String, BaseCollection, XWikiContext)
,fromString(String)
-
setSeparators
public void setSeparators(String separators)
- Parameters:
separators
- a string of characters used to split/deserialize an input string coming from the UI (filled by the user) that represents a serialized list
-
getDisplayType
public String getDisplayType()
-
setDisplayType
public void setDisplayType(String type)
-
getSort
public String getSort()
-
setSort
public void setSort(String sort)
-
getSize
public int getSize()
-
setSize
public void setSize(int size)
-
isCache
public boolean isCache()
-
setCache
public void setCache(boolean cache)
-
isMultiSelect
public boolean isMultiSelect()
-
setMultiSelect
public void setMultiSelect(boolean multiSelect)
-
isRelationalStorage
public boolean isRelationalStorage()
-
setRelationalStorage
public void setRelationalStorage(boolean relationalStorage)
- Parameters:
relationalStorage
- if false, the list items will be concatenated into a VARCHAR column on a single row. Otherwise, items are stored in their own entries in the database. In most cases, this property should have the same value as themultiSelect
property
-
isPicker
public boolean isPicker()
-
setPicker
public void setPicker(boolean picker)
-
isLargeStorage
public boolean isLargeStorage()
- Since:
- 11.5RC1
-
setLargeStorage
public void setLargeStorage(boolean largeStorage)
- Since:
- 11.5RC1
-
getSeparator
public String getSeparator()
- Returns:
- a string (usually just 1 character long) used to join this list's items when displaying it in the UI in view mode.
- See Also:
displayView(StringBuffer, String, String, BaseCollection, XWikiContext)
-
setSeparator
public void setSeparator(String separator)
- Parameters:
separator
- a string (usually just 1 character long) used to join this list's items when displaying it in the UI in view mode.
-
getDefaultValue
public String getDefaultValue()
- Returns:
- the default value used in the select editor
- Since:
- 10.9, 10.8.1
-
setDefaultValue
public void setDefaultValue(String separator)
- Parameters:
separator
- the default value used in the select editor- Since:
- 10.9, 10.8.1
-
getFreeText
public String getFreeText()
- Returns:
- the value of freeText (forbidden, discouraged or allowed)
- Since:
- 10.11RC1
-
setFreeText
public void setFreeText(String type)
- Parameters:
type
- the value of freeText (forbidden, discouraged or allowed)- Since:
- 10.11RC1
-
getListFromString
public static List<String> getListFromString(String value)
Convenience method, using "|" as separator and parsing key=value items.- Parameters:
value
- the string holding a serialized list- Returns:
- the list that was stored in the input string
- See Also:
getListFromString(String, String, boolean)
-
getFirstSeparator
protected String getFirstSeparator()
- Returns:
- the first separator of the list of separators, or fallback on
DEFAULT_SEPARATOR
. - Since:
- 14.2RC1
-
getListFromString
public static List<String> getListFromString(String value, String separators, boolean withMap)
- Parameters:
value
- the string holding a serialized listseparators
- the separator characters (given as a string) used to delimit the list's items inside the input string. These separators can also be present, in escaped (92) form, inside list itemswithMap
- set to true if the list's values contain map entries (key=value pairs) that should also be parsed. Only the keys are extracted from such list items- Returns:
- the list that was stored in the input string
-
getListFromString
protected static List<String> getListFromString(String value, String separators, boolean withMap, boolean filterEmptyValues)
- Parameters:
value
- the string holding a serialized listseparators
- the separator characters (given as a string) used to delimit the list's items inside the input string. These separators can also be present, in escaped (92) form, inside list itemswithMap
- set to true if the list's values contain map entries (key=value pairs) that should also be parsed. Only the keys are extracted from such list itemsfilterEmptyValues
-true
if the result should not contain any empty values.- Returns:
- the list that was stored in the input string
-
getStringFromList
public static String getStringFromList(List<String> list)
Convenience method, using "|" as separator.- Parameters:
list
- the list to serialize- Returns:
- a string representing a serialized list, delimited by the first separator character (from the ones inside the separators string). Separators inside list items are safely escaped (92).
- See Also:
getStringFromList(List, String)
-
getStringFromList
public static String getStringFromList(List<String> list, String separators)
- Parameters:
list
- the list to serializeseparators
- the separator characters (given as a string) used when the list was populated with values. The list's items can contain these separators in plain/unescaped form. The first separator character will be used to join the list in the output.- Returns:
- a string representing a serialized list, delimited by the first separator character (from the ones inside the separators string). Separators inside list items are safely escaped (92).
-
toFormString
public String toFormString(BaseProperty property)
- Parameters:
property
- a property to be used in an form input- Returns:
- the text value to be used in an form input. If a
ListProperty
is passed, the list's separators defined bygetSeparators()
are escaped for each list item and the items are joined by the first separator - See Also:
getStringFromList(List, String)
-
newProperty
public BaseProperty newProperty()
- Specified by:
newProperty
in interfacePropertyClassInterface
- Overrides:
newProperty
in classPropertyClass
-
fromString
public BaseProperty fromString(String value)
- Specified by:
fromString
in interfacePropertyClassInterface
- Overrides:
fromString
in classPropertyClass
-
fromStringArray
public BaseProperty fromStringArray(String[] strings)
- Overrides:
fromStringArray
in classPropertyClass
-
newPropertyfromXML
public BaseProperty newPropertyfromXML(org.dom4j.Element ppcel)
- Overrides:
newPropertyfromXML
in classPropertyClass
-
getDisplayValue
public String getDisplayValue(String value, String name, Map<String,ListItem> map, XWikiContext context)
Search for an internationalizable display text for the current value. The search process is:- let V = the internal value of the option, used as the "value" attribute of the
<option>
element, and D = the displayed value - if a message with the key
<fieldFullName>_<V>
exists, return it as D - else, if a message with the key
option_<fieldName>_<V>
exists, return it as D - else, if a message with the key
option_<V>
exists, return it as D - else, D can be specified in the values parameter of the property by using V=D
- else return V
- Parameters:
value
- The internal value.name
- The name of the ListProperty.map
- The value=name mapping specified in the "values" parameter of the property.context
- The request context.- Returns:
- The text that should be displayed, representing a human-understandable name for the internal value.
- Since:
- 13.10RC1
- let V = the internal value of the option, used as the "value" attribute of the
-
getDisplayValue
protected String getDisplayValue(Object rawvalue, String name, Map<String,ListItem> map, XWikiContext context)
Search for an internationalizable display text for the current value. The value can be either a simple string, or a value=name pair selected from the database.- Parameters:
rawvalue
- The internal value, or a value=name pair.name
- The name of the ListProperty.map
- The value=name mapping specified in the "values" parameter of the property.context
- The request context.- Returns:
- The text that should be displayed, representing a human-understandable name for the internal value.
- See Also:
getDisplayValue(String, String, Map, XWikiContext)
-
getElementValue
protected String getElementValue(Object rawvalue)
If the list is populated with value=name pairs selected from the database, then return only the value. Otherwise, it is a simple value.- Parameters:
rawvalue
-- Returns:
- The list value
-
displayHidden
public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayHidden
in interfacePropertyClassInterface
- Overrides:
displayHidden
in classPropertyClass
-
displayView
public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayView
in interfacePropertyClassInterface
- Overrides:
displayView
in classPropertyClass
-
displayEdit
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayEdit
in interfacePropertyClassInterface
- Overrides:
displayEdit
in classPropertyClass
-
displayRadioEdit
protected void displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
-
displaySelectEdit
protected void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
-
getList
public abstract List<String> getList(XWikiContext context)
-
getMap
public abstract Map<String,ListItem> getMap(XWikiContext context)
-
toList
public List<String> toList(BaseProperty<?> property)
ListClass
does not produce onlyListProperty
s and this method allows to access the value asList
whatever property is actually storing it.There is no guarantees the returned
List
will be modifiable.- Parameters:
property
- the property created by this class- Returns:
- the
List
representation of this property - Since:
- 6.2M1
-
fromList
public void fromList(BaseProperty<?> property, List<String> list)
Set the passedList
into the passed property.- Parameters:
property
- the property to modifylist
- the list to set- Since:
- 6.2M1
-
fromList
protected void fromList(BaseProperty<?> property, List<String> list, boolean filterEmptyValues)
Set the passedList
into the passed property.- Parameters:
property
- the property to modifylist
- the list to setfilterEmptyValues
- iftrue
filter out the empty values from the list.- Since:
- 14.2RC1
-
mergeProperty
public <T extends EntityReference> void mergeProperty(BaseProperty<T> currentProperty, BaseProperty<T> previousProperty, BaseProperty<T> newProperty, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
Description copied from class:PropertyClass
Apply a 3 ways merge on passed current, previous and new version of the same property. The passed current version is modified as result of the merge.- Overrides:
mergeProperty
in classPropertyClass
- Parameters:
currentProperty
- the current version of the element and the one to modifypreviousProperty
- the previous version of the elementnewProperty
- the new version of the propertyconfiguration
- the configuration of the merge Indicate how to deal with some conflicts use cases, etc.context
- the XWiki contextmergeResult
- the merge report
-
mergeNotOrderedListProperty
protected <T extends EntityReference> void mergeNotOrderedListProperty(BaseProperty<T> currentProperty, BaseProperty<T> previousProperty, BaseProperty<T> newProperty, MergeConfiguration configuration, XWikiContext context, MergeResult mergeResult)
-
-