public class DataElementList extends ListDataElement<DataElement<?>>
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 |
DataElementList()
Default constructor for serialization.
|
|
DataElementList(java.lang.String sName,
java.util.Collection<? extends DataElement<?>> rElements)
Creates a new instance that is initialized from a certain set of data
elements.
|
|
DataElementList(java.lang.String sName,
java.lang.String sResourceId,
java.util.Collection<? extends DataElement<?>> rElements,
java.util.Set<DataElement.Flag> rFlags)
Creates a new instance that is initialized from a certain set of data
elements.
|
|
DataElementList(java.lang.String sName,
java.lang.String sResourceId,
DataElement<?>... rElements)
Creates a new instance with certain data elements and without a validator
and flags.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String sName,
boolean bValue)
Shortcut method to add a new
BooleanDataElement with a certain
name and value. |
void |
add(java.lang.String sName,
java.util.Date rValue)
Shortcut method to add a new
DateDataElement with a certain name
and Date value. |
void |
add(java.lang.String sName,
int nValue)
Shortcut method to add a new
IntegerDataElement with a certain
name and value. |
void |
add(java.lang.String sName,
java.lang.String sValue)
Shortcut method to add a new
StringDataElement with a certain
name and string value. |
void |
addElement(int nIndex,
DataElement<?> rElement)
Overridden to modify the parent reference of the argument data element.
|
DataElementList |
copy(DataElement.CopyMode eMode,
de.esoco.lib.property.PropertyName<?>... rCopyProperties)
Returns a copy of this data element that contains all or a subset of it's
current state.
|
protected void |
copyValue(DataElement<java.util.List<DataElement<?>>> aCopy)
Overridden to to nothing as the copying of the child data elements is
handled in
DataElement.copy(CopyMode, PropertyName...) . |
DataElement<?> |
findChild(java.lang.String sName)
Searches for a child data element in the full hierarchy of this instance
and returns it if found.
|
static DataElement<?> |
findDataElement(java.lang.String sName,
java.util.Collection<DataElement<?>> rElements)
Searches for a data element with a certain name in a collection of data
elements.
|
boolean |
getBoolean(java.lang.String sName)
Returns the boolean value of a certain data element.
|
DataElementList |
getChildList(java.lang.String sElementPath)
A convenience method that casts the return value of the name-based method
getElementAt(String) to a data element list. |
protected java.lang.String |
getChildResourceIdPrefix()
Can be overridden by subclasses to return a resource id prefix for child
elements.
|
java.util.List<DataElement<?>> |
getDataElements()
Returns the list of data elements in this instance.
|
java.util.Date |
getDate(java.lang.String sName)
Returns the date value of a certain data element.
|
DataElement<?> |
getElement(java.lang.String sElementName)
Returns the first element with a certain name from this list.
|
DataElement<?> |
getElementAt(java.lang.String sElementPath)
Returns a particular data element from the hierarchy of this list.
|
java.lang.String |
getElementHierarchy(java.lang.String sIndent)
Returns a formatted multi-line string that describes the data element
hierarchy of this instance.
|
int |
getInt(java.lang.String sName)
Returns the integer value of a certain data element.
|
protected java.util.List<DataElement<?>> |
getList()
Returns the list of values of this data element.
|
java.lang.String |
getString(java.lang.String sName)
Returns the string value of a certain data element.
|
static void |
init()
This method should be invoked to initialize the property name constants
for de-serialization.
|
void |
markAsChanged()
Overridden to also mark the child hierarchy as modified.
|
protected DataElementList |
newInstance()
Returns a new instance of the respective data element sub-type on which
it is invoked.
|
void |
removeElement(DataElement<?> rElement)
Overridden to modify the parent reference of the argument data element.
|
boolean |
replaceElement(DataElement<?> rNewElement)
Replaces the first data element in this list with a new element with the
same name.
|
void |
set(java.lang.String sName,
java.lang.String sValue)
Shortcut method to set a
StringDataElement with a certain name
and string value. |
void |
setElement(DataElement<?> rElement)
Sets an element in this instance.
|
java.lang.String |
toDebugString(java.lang.String sIndent,
boolean bIncludeProperties)
Creates a string that describes this element for debugging purposes.
|
java.lang.String |
toHierarchyString()
Returns the full hierarchy of this data element list as a string.
|
protected void |
updateValue(java.util.List<DataElement<?>> rNewElements)
Updates the element value.
|
addAll, addAllowedValues, addElement, clear, containsElement, getAllowedValues, getElement, getElementCount, getElementIndex, getElements, getElementValidator, getValue, getValueHashCode, hasEqualValueAs, iterator, toString
checkImmutable, checkValidValue, copyAttributes, createItemName, createItemResource, createResourceId, equals, getName, getParent, getPath, getResourceId, getRoot, getSimpleName, getValidator, hashCode, isImmutable, isModified, isOptional, isSelected, isValidValue, readFrom, removeProperty, setModified, setProperty, setSelected, setStringValue, setValidator, setValue, 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 DataElementList(java.lang.String sName, java.util.Collection<? extends DataElement<?>> rElements)
sName
- The name of this elementrElements
- A collection containing the initial elements of this
list element (may be NULL)public DataElementList(java.lang.String sName, java.lang.String sResourceId, DataElement<?>... rElements)
sName
- The name of this elementsResourceId
- A resource ID or NULL for the defaultrElements
- The child data elementspublic DataElementList(java.lang.String sName, java.lang.String sResourceId, java.util.Collection<? extends DataElement<?>> rElements, java.util.Set<DataElement.Flag> rFlags)
sName
- The name of this elementsResourceId
- A resource ID or NULL for the defaultrElements
- A collection containing the initial elements of this
list element (may be NULL)rFlags
- The optional flags for this data elementprotected DataElementList()
public static DataElement<?> findDataElement(java.lang.String sName, java.util.Collection<DataElement<?>> rElements)
data element
lists
these will be searched recursively.sName
- The name of the data elementrElements
- The elements to searchpublic static void init()
public void add(java.lang.String sName, java.lang.String sValue)
StringDataElement
with a certain
name and string value. See ListDataElement.addElement(Object)
for
more information.sName
- The name of the data element to addsValue
- The value of the new data elementpublic void add(java.lang.String sName, java.util.Date rValue)
DateDataElement
with a certain name
and Date
value.sName
- The name of the data element to addrValue
- The value of the new data elementpublic void add(java.lang.String sName, int nValue)
IntegerDataElement
with a certain
name and value.sName
- The name of the data element to addnValue
- The value of the new data elementpublic void add(java.lang.String sName, boolean bValue)
BooleanDataElement
with a certain
name and value.sName
- The name of the data element to addbValue
- The value of the new data elementpublic void addElement(int nIndex, DataElement<?> rElement)
addElement
in class ListDataElement<DataElement<?>>
nIndex
- The position indexrElement
- The element value to addListDataElement.addElement(int, Object)
public DataElementList copy(DataElement.CopyMode eMode, de.esoco.lib.property.PropertyName<?>... rCopyProperties)
flags
. Never
copied is the parent reference because upon copying typically a reference
to a copied parent needs to be set. The further data the copy contains
depends on the copy mode:
DataElement.CopyMode.FULL
: The copy contains all data (except the
parent reference).DataElement.CopyMode.FLAT
: like DataElement.CopyMode.FULL
but without
sub-ordinate data elements.DataElement.CopyMode.PROPERTIES
: The copy contains only the properties
but not the element value and attributes.DataElement.CopyMode.PLACEHOLDER
: The copy contains only the element
name to serve as a placeholder.The copy instance is created by invoking DataElement.newInstance()
which
has the recommendation to overwrite the return type to the concrete
subtype to prevent the need for casting by the invoking code. For the
same reason it is recommended that subclasses also override this method
with the concrete return type and cast the result of
super.copy()
to that type.
copy
in class DataElement<java.util.List<DataElement<?>>>
eMode
- The copy moderCopyProperties
- An optional list of properties to copy. If not
provided all properties will be copied (unless
the mode is DataElement.CopyMode.PLACEHOLDER
)public DataElement<?> findChild(java.lang.String sName)
findDataElement(String,
Collection)
to perform the search.sName
- The name of the data element to searchpublic boolean getBoolean(java.lang.String sName)
Boolean.booleanValue()
on the
type-casted value of the data element with the given name if such exists.
If not, FALSE will be returned. If the data element's value is not of
type Boolean
an exception will occur.sName
- The name of the data element to return as a boolean valuepublic DataElementList getChildList(java.lang.String sElementPath)
getElementAt(String)
to a data element list. If the type of the
named element is not DataElementList
or if no such element exists
NULL will be returned.sElementPath
- The path of the element list to returnpublic java.util.List<DataElement<?>> getDataElements()
public java.util.Date getDate(java.lang.String sName)
Date
an exception will occur.sName
- The name of the data element to return as a date valuepublic DataElement<?> getElement(java.lang.String sElementName)
sElementName
- The name of the element to returnpublic DataElement<?> getElementAt(java.lang.String sElementPath)
DataElement.PATH_SEPARATOR_CHAR
.
If the path start with a separator it is considered to be absolute with the name of this list as the first path element. Without a leading separator it must be relative to this instance, i.e. the first element in the path must be the name of a child data element of this instance. The path must never end with a separator. Examples:
sElementPath
- The path of the element to returnpublic java.lang.String getElementHierarchy(java.lang.String sIndent)
sIndent
- The initial indent of the hierarchy (empty for none)public int getInt(java.lang.String sName)
Number.intValue()
on the
type-casted value of the data element with the given name if such exists.
If not, 0 (zero) will be returned. If the data element's value is not of
type Number
an exception will occur.sName
- The name of the data element to return as an integer valuepublic java.lang.String getString(java.lang.String sName)
Object.toString()
on the value of
the data element with the given name if such exists. If not, NULL will be
returned.sName
- The name of the data element to return the string value ofpublic void markAsChanged()
markAsChanged
in class DataElement<java.util.List<DataElement<?>>>
public void removeElement(DataElement<?> rElement)
removeElement
in class ListDataElement<DataElement<?>>
rElement
- The element to removeListDataElement.removeElement(Object)
public boolean replaceElement(DataElement<?> rNewElement)
rNewElement
- The element to replace another with the same namepublic void set(java.lang.String sName, java.lang.String sValue)
StringDataElement
with a certain name
and string value. See setElement(DataElement)
for more
information.sName
- The name of the data element to addsValue
- The value of the new data elementpublic void setElement(DataElement<?> rElement)
rElement
- The element to setpublic java.lang.String toDebugString(java.lang.String sIndent, boolean bIncludeProperties)
toDebugString
in class DataElement<java.util.List<DataElement<?>>>
sIndent
- The indentation of the returned stringbIncludeProperties
- TRUE to include the properties, FALSE to omitpublic java.lang.String toHierarchyString()
protected void copyValue(DataElement<java.util.List<DataElement<?>>> aCopy)
DataElement.copy(CopyMode, PropertyName...)
.copyValue
in class ListDataElement<DataElement<?>>
aCopy
- The copied data element to copy the value intoListDataElement.copyValue(DataElement)
protected java.lang.String getChildResourceIdPrefix()
protected java.util.List<DataElement<?>> getList()
ListDataElement
getList
in class ListDataElement<DataElement<?>>
ListDataElement.getList()
protected DataElementList newInstance()
DataElement.copy(CopyMode, PropertyName...)
for cloning an instance.
Implementations should overwrite the return type with their concrete type
to prevent the need for casting by the invoking code.newInstance
in class DataElement<java.util.List<DataElement<?>>>
protected void updateValue(java.util.List<DataElement<?>> rNewElements)
DataElement.setValue(Object)
to store a new value after validation. If a subclass wants to reject
certain values it should do so in the DataElement.isValidValue(Validator,
Object)
method. Subclasses that are always immutable should implement an
assertion because if the element has been initialized correctly
(validator = NULL) this method should then be reached.updateValue
in class DataElement<java.util.List<DataElement<?>>>
rNewElements
- The new value for this element