public abstract class ListDataElement<E> extends DataElement<java.util.List<E>> implements de.esoco.lib.model.DataModel<E>
getList()
to return the list of values. The standard data
element methods DataElement.updateValue(Object)
and getValue()
are
overridden to throw a runtime exception. Access to the list data must be done
through the corresponding methods like getElement(int)
.DataElement.CopyMode, DataElement.Flag
ALLOWED_VALUES_CHANGED, ANONYMOUS_ELEMENT_PREFIX, DISPLAY_FLAGS, HIDDEN_URL, INPUT_FLAGS, INTERACTION_URL, ITEM_ALL_RESOURCE, ITEM_NEW_RESOURCE, ITEM_RESOURCE_PREFIX, PATH_SEPARATOR_CHAR, SERVER_PROPERTIES
Modifier | Constructor and Description |
---|---|
protected |
ListDataElement()
Default constructor for serialization.
|
|
ListDataElement(java.lang.String sName,
Validator<? super E> rElementValidator,
java.util.Set<DataElement.Flag> rFlags) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(java.util.Collection<E> rNewElements)
Adds a collection of new elements to this instance.
|
void |
addAllowedValues(java.util.Collection<E> rValues)
Adds allowed values to the element validator.
|
void |
addElement(E rElement)
Adds a new element value to this instance.
|
void |
addElement(int nIndex,
E rElement)
Adds a new element value at a certain position of this instance.
|
void |
clear()
Removes all element values from this instance.
|
boolean |
containsElement(E rElement)
Checks whether this instance contains a certain value.
|
protected void |
copyValue(DataElement<java.util.List<E>> aCopy)
Copies the value of this data element into another data element of the
same type.
|
java.util.List<?> |
getAllowedValues()
Overridden to return the values from the element validator instead.
|
E |
getElement(int nIndex)
Returns an element value of this instance.
|
int |
getElementCount()
Returns the number of element values in this instance.
|
int |
getElementIndex(E rElement)
Returns the index of a certain data element of this instance.
|
java.util.List<E> |
getElements()
Returns a new list containing the elements of this instance.
|
Validator<? super E> |
getElementValidator()
Returns the validator for single elements of subclasses with composite
values.
|
protected abstract java.util.List<E> |
getList()
Returns the list of values of this data element.
|
java.util.List<E> |
getValue()
//~ Methods
----------------------------------------------------------------
/*************************************** Returns the value of this
element.
|
protected int |
getValueHashCode()
Returns the value hash code.
|
protected boolean |
hasEqualValueAs(DataElement<?> rOther)
Checks whether this element has a value that is equal to that of another
element.
|
java.util.Iterator<E> |
iterator() |
void |
removeElement(E rElement)
Removes a certain element from this instance.
|
java.lang.String |
toString()
Returns a string representation of this element.
|
checkImmutable, checkValidValue, copy, copyAttributes, createItemName, createItemResource, createResourceId, equals, getName, getParent, getPath, getResourceId, getRoot, getSimpleName, getValidator, hashCode, init, isImmutable, isModified, isOptional, isSelected, isValidValue, markAsChanged, newInstance, readFrom, removeProperty, setModified, setProperty, setSelected, setStringValue, setValidator, setValue, toDebugString, updateValue, valuesEqual, writeTo
clearFlag, clearProperties, setFlag, setProperties, setProperty, setProperty
convertCollection, convertMap, convertValue, ensurePropertyMapExists, findValue, getIntProperty, getProperty, getPropertyCount, getPropertyMap, getPropertyNames, hasEqualProperties, hasFlag, hasProperty, parseCollection, parseMap, parseValue, setPropertyMap
public ListDataElement(java.lang.String sName, Validator<? super E> rElementValidator, java.util.Set<DataElement.Flag> rFlags)
protected ListDataElement()
public void addAll(java.util.Collection<E> rNewElements)
rNewElements
- The element value to addpublic void addAllowedValues(java.util.Collection<E> rValues)
rValues
- The values to addpublic final void addElement(E rElement)
rElement
- The element value to addpublic void addElement(int nIndex, E rElement)
nIndex
- The position indexrElement
- The element value to addpublic void clear()
public boolean containsElement(E rElement)
rElement
- The element value to checkpublic java.util.List<?> getAllowedValues()
getAllowedValues
in class DataElement<java.util.List<E>>
DataElement.getAllowedValues()
public E getElement(int nIndex)
getElement
in interface de.esoco.lib.model.DataModel<E>
nIndex
- The indexpublic int getElementCount()
getElementCount
in interface de.esoco.lib.model.DataModel<E>
public int getElementIndex(E rElement)
rElement
- The data element to return the index ofpublic java.util.List<E> getElements()
public Validator<? super E> getElementValidator()
DataElement.getValidator()
.getElementValidator
in class DataElement<java.util.List<E>>
public final java.util.List<E> getValue()
getValue
in class DataElement<java.util.List<E>>
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
public void removeElement(E rElement)
rElement
- The element to removepublic java.lang.String toString()
toString
in class DataElement<java.util.List<E>>
Object.toString()
protected abstract java.util.List<E> getList()
protected void copyValue(DataElement<java.util.List<E>> aCopy)
DataElement.copy(CopyMode, PropertyName...)
method and by default uses DataElement.updateValue(Object)
to set the value
in the target element. Subclasses that don't support updating the value
(e.g. because they manage a collection) need to override this method and
implement the copying as needed. They can assume that the target object
is of exactly the same type as their own.copyValue
in class DataElement<java.util.List<E>>
aCopy
- The copied data element to copy the value intoprotected int getValueHashCode()
getValueHashCode
in class DataElement<java.util.List<E>>
protected boolean hasEqualValueAs(DataElement<?> rOther)
hasEqualValueAs
in class DataElement<java.util.List<E>>
rOther
- The other data element which will always be of the same
type as this instance