Package de.esoco.data.element
Klasse DataElementList
java.lang.Object
de.esoco.lib.property.AbstractStringProperties
de.esoco.lib.property.StringProperties
- Alle implementierten Schnittstellen:
de.esoco.lib.model.DataModel<DataElement<?>>
,de.esoco.lib.property.HasProperties
,de.esoco.lib.property.MutableProperties
,Serializable
,Iterable<DataElement<?>>
- Bekannte direkte Unterklassen:
EntityDataElement
A data element implementation that contains a hierarchical structure of data
elements.
- Siehe auch:
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen de.esoco.data.element.DataElement
DataElement.CopyMode, DataElement.Flag
-
Feldübersicht
Von Klasse geerbte Felder de.esoco.data.element.DataElement
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
-
Konstruktorübersicht
ModifiziererKonstruktorBeschreibungprotected
Default constructor for serialization.DataElementList
(String name, String resourceId, DataElement<?>... elements) Creates a new instance with certain data elements and without a validator and flags.DataElementList
(String name, String resourceId, Collection<? extends DataElement<?>> elements, Set<DataElement.Flag> flags) Creates a new instance that is initialized from a certain set of data elements.DataElementList
(String name, Collection<? extends DataElement<?>> elements) Creates a new instance that is initialized from a certain set of data elements. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
Shortcut method to add a newBooleanDataElement
with a certain name and value.void
Shortcut method to add a newIntegerDataElement
with a certain name and value.void
Shortcut method to add a newStringDataElement
with a certain name and string value.void
Shortcut method to add a newDateDataElement
with a certain name andDate
value.void
addElement
(int index, DataElement<?> element) Overridden to modify the parent reference of the argument data element.copy
(DataElement.CopyMode mode, de.esoco.lib.property.PropertyName<?>... copyProperties) Returns a copy of this data element that contains all or a subset of it's current state.protected void
copyValue
(DataElement<List<DataElement<?>>> copy) Overridden to to nothing as the copying of the child data elements is handled incopy(CopyMode, PropertyName...)
.DataElement
<?> Searches for a child data element in the full hierarchy of this instance and returns it if found.static DataElement
<?> findDataElement
(String name, Collection<DataElement<?>> elements) Searches for a data element with a certain name in a collection of data elements.boolean
getBoolean
(String name) Returns the boolean value of a certain data element.getChildList
(String elementPath) A convenience method that casts the return value of the name-based methodgetElementAt(String)
to a data element list.protected String
Can be overridden by subclasses to return a resource id prefix for child elements.List
<DataElement<?>> Returns the list of data elements in this instance.Returns the date value of a certain data element.DataElement
<?> getElement
(String elementName) Returns the first element with a certain name from this list.DataElement
<?> getElementAt
(String elementPath) Returns a particular data element from the hierarchy of this list.getElementHierarchy
(String indent) Returns a formatted multi-line string that describes the data element hierarchy of this instance.int
Returns the integer value of a certain data element.protected List
<DataElement<?>> getList()
Returns the list of values of this data element.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
Overridden to also mark the child hierarchy as modified.protected DataElementList
Returns a new instance of the respective data element sub-type on which it is invoked.void
removeElement
(DataElement<?> element) Overridden to modify the parent reference of the argument data element.boolean
replaceElement
(DataElement<?> newElement) Replaces the first data element in this list with a new element with the same name.void
Shortcut method to set aStringDataElement
with a certain name and string value.void
setElement
(DataElement<?> element) Sets an element in this instance.toDebugString
(String indent, boolean includeProperties) Creates a string that describes this element for debugging purposes.Returns the full hierarchy of this data element list as a string.protected void
updateValue
(List<DataElement<?>> newElements) Updates the element value.Von Klasse geerbte Methoden de.esoco.data.element.ListDataElement
addAll, addAllowedValues, addElement, clear, containsElement, getAllowedValues, getElement, getElementCount, getElementIndex, getElements, getElementValidator, getValue, getValueHashCode, hasEqualValueAs, iterator, toString
Von Klasse geerbte Methoden de.esoco.data.element.DataElement
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
Von Klasse geerbte Methoden de.esoco.lib.property.StringProperties
clearFlag, clearProperties, setFlag, setProperties, setProperty, setProperty
Von Klasse geerbte Methoden de.esoco.lib.property.AbstractStringProperties
convertCollection, convertMap, convertValue, ensurePropertyMapExists, findValue, getIntProperty, getProperty, getPropertyCount, getPropertyMap, getPropertyNames, hasEqualProperties, hasFlag, hasProperty, parseCollection, parseMap, parseValue, setPropertyMap
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden de.esoco.lib.property.HasProperties
getIntProperty, getProperty, getPropertyCount, getPropertyNames, hasFlag, hasProperty
Von Schnittstelle geerbte Methoden java.lang.Iterable
forEach, spliterator
-
Konstruktordetails
-
DataElementList
Creates a new instance that is initialized from a certain set of data elements. The contents of the collection argument will be copied into this list element but not the collection itself.- Parameter:
name
- The name of this elementelements
- A collection containing the initial elements of this list element (may be NULL)
-
DataElementList
Creates a new instance with certain data elements and without a validator and flags.- Parameter:
name
- The name of this elementresourceId
- A resource ID or NULL for the defaultelements
- The child data elements
-
DataElementList
public DataElementList(String name, String resourceId, Collection<? extends DataElement<?>> elements, Set<DataElement.Flag> flags) Creates a new instance that is initialized from a certain set of data elements. The contents of the collection argument will be copied into this list element but not the collection itself.- Parameter:
name
- The name of this elementresourceId
- A resource ID or NULL for the defaultelements
- A collection containing the initial elements of this list element (may be NULL)flags
- The optional flags for this data element
-
DataElementList
protected DataElementList()Default constructor for serialization.
-
-
Methodendetails
-
findDataElement
Searches for a data element with a certain name in a collection of data elements. If the collection containsdata element lists
these will be searched recursively.- Parameter:
name
- The name of the data elementelements
- The elements to search- Gibt zurück:
- The matching data element or NULL if no such element exists
-
init
public static void init()This method should be invoked to initialize the property name constants for de-serialization. -
add
Shortcut method to add a newStringDataElement
with a certain name and string value. SeeListDataElement.addElement(Object)
for more information.- Parameter:
name
- The name of the data element to addvalue
- The value of the new data element
-
add
Shortcut method to add a newDateDataElement
with a certain name andDate
value.- Parameter:
name
- The name of the data element to addvalue
- The value of the new data element
-
add
Shortcut method to add a newIntegerDataElement
with a certain name and value.- Parameter:
name
- The name of the data element to addvalue
- The value of the new data element
-
add
Shortcut method to add a newBooleanDataElement
with a certain name and value.- Parameter:
name
- The name of the data element to addvalue
- The value of the new data element
-
addElement
Overridden to modify the parent reference of the argument data element.- Setzt außer Kraft:
addElement
in KlasseListDataElement<DataElement<?>>
- Parameter:
index
- The position indexelement
- The element value to add- Siehe auch:
-
copy
public DataElementList copy(DataElement.CopyMode mode, de.esoco.lib.property.PropertyName<?>... copyProperties) Returns a copy of this data element that contains all or a subset of it's current state. Always copied are the name andflags
. 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
: likeDataElement.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 ofsuper.copy()
to that type.- Setzt außer Kraft:
copy
in KlasseDataElement<List<DataElement<?>>>
- Parameter:
mode
- The copy modecopyProperties
- An optional list of properties to copy. If not provided all properties will be copied (unless the mode isDataElement.CopyMode.PLACEHOLDER
)- Gibt zurück:
- The copied instance
-
findChild
Searches for a child data element in the full hierarchy of this instance and returns it if found. InvokesfindDataElement(String, Collection)
to perform the search.- Parameter:
name
- The name of the data element to search- Gibt zurück:
- The child data element with the given name or NULL for none
-
getBoolean
Returns the boolean value of a certain data element. The returned value will be the result of invokingBoolean.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 typeBoolean
an exception will occur.- Parameter:
name
- The name of the data element to return as a boolean value- Gibt zurück:
- The boolean value of the data element or FALSE if none could be found
-
getChildList
A convenience method that casts the return value of the name-based methodgetElementAt(String)
to a data element list. If the type of the named element is notDataElementList
or if no such element exists NULL will be returned.- Parameter:
elementPath
- The path of the element list to return- Gibt zurück:
- The element list at the given path or NULL if no list with the given name exists
-
getDataElements
Returns the list of data elements in this instance. The list must not be modified by the invoking code.- Gibt zurück:
- The list of data elements
-
getDate
Returns the date value of a certain data element. The returned value will be the type-casted value of the data element with the given name if such exists. If not, NULL will be returned. If the data element's value is not of typeDate
an exception will occur.- Parameter:
name
- The name of the data element to return as a date value- Gibt zurück:
- The date value of the data element or NULL if none could be found
-
getElement
Returns the first element with a certain name from this list.- Parameter:
elementName
- The name of the element to return- Gibt zurück:
- The element or NULL if no element with the given name exists
-
getElementAt
Returns a particular data element from the hierarchy of this list. The element path argument can either be a simple element name of a path to an element in the hierarchy of this list's sub-lists. The path separator is a forward slash as defined byDataElement.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:
- 'Test': returns the element 'Test' from this list
- '/Data/Preferences/Setting1': returns the element 'Setting1' from the sub-list 'Preferences' of this element which is called 'Data'
- 'Preferences/Setting1': returns the element 'Setting1' from the sub-list 'Preferences'
- 'Preferences': returns the sub-list named 'Preferences'
- Parameter:
elementPath
- The path of the element to return- Gibt zurück:
- The element with the given path or NULL if no such element exists
-
getElementHierarchy
Returns a formatted multi-line string that describes the data element hierarchy of this instance.- Parameter:
indent
- The initial indent of the hierarchy (empty for none)- Gibt zurück:
- The data element hierarchy string
-
getInt
Returns the integer value of a certain data element. The returned value will be the result of invokingNumber.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 typeNumber
an exception will occur.- Parameter:
name
- The name of the data element to return as an integer value- Gibt zurück:
- The integer value of the data element or 0 if none could be found
-
getString
Returns the string value of a certain data element. The returned value will be the result of invokingObject.toString()
on the value of the data element with the given name if such exists. If not, NULL will be returned.- Parameter:
name
- The name of the data element to return the string value of- Gibt zurück:
- The string value of the data element or NULL if none could be found
-
markAsChanged
public void markAsChanged()Overridden to also mark the child hierarchy as modified.- Setzt außer Kraft:
markAsChanged
in KlasseDataElement<List<DataElement<?>>>
-
removeElement
Overridden to modify the parent reference of the argument data element.- Setzt außer Kraft:
removeElement
in KlasseListDataElement<DataElement<?>>
- Parameter:
element
- The element to remove- Siehe auch:
-
replaceElement
Replaces the first data element in this list with a new element with the same name.- Parameter:
newElement
- The element to replace another with the same name- Gibt zurück:
- TRUE if an element has been replaced
-
set
Shortcut method to set aStringDataElement
with a certain name and string value. SeesetElement(DataElement)
for more information.- Parameter:
name
- The name of the data element to addvalue
- The value of the new data element
-
setElement
Sets an element in this instance. If an element with the given name already exists it will be replaced. Otherwise a new element will be added to the end of the list.- Parameter:
element
- The element to set
-
toDebugString
Creates a string that describes this element for debugging purposes.- Setzt außer Kraft:
toDebugString
in KlasseDataElement<List<DataElement<?>>>
- Parameter:
indent
- The indentation of the returned stringincludeProperties
- TRUE to include the properties, FALSE to omit- Gibt zurück:
- The debug description
-
toHierarchyString
Returns the full hierarchy of this data element list as a string.- Gibt zurück:
- The hierarchy string
-
copyValue
Overridden to to nothing as the copying of the child data elements is handled incopy(CopyMode, PropertyName...)
.- Setzt außer Kraft:
copyValue
in KlasseListDataElement<DataElement<?>>
- Parameter:
copy
- The copied data element to copy the value into- Siehe auch:
-
getChildResourceIdPrefix
Can be overridden by subclasses to return a resource id prefix for child elements. This default implementation returns an empty string.- Gibt zurück:
- The child resource id prefix
-
getList
Beschreibung aus Klasse kopiert:ListDataElement
Returns the list of values of this data element. Must be implemented by subclasses to return the type-specific value list.- Angegeben von:
getList
in KlasseListDataElement<DataElement<?>>
- Gibt zurück:
- The list of values for this instance (must not be NULL)
- Siehe auch:
-
newInstance
Returns a new instance of the respective data element sub-type on which it is invoked. This is needed for GWT which doesn't support reflection. Used byDataElement.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.- Angegeben von:
newInstance
in KlasseDataElement<List<DataElement<?>>>
- Gibt zurück:
- The new instance
-
updateValue
Updates the element value. Will be invoked byDataElement.setValue(Object)
to store a new value after validation. If a subclass wants to reject certain values it should do so in theDataElement.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.- Angegeben von:
updateValue
in KlasseDataElement<List<DataElement<?>>>
- Parameter:
newElements
- The new value for this element
-