Class ItemCollection
- All Implemented Interfaces:
Cloneable
A ItemCollection contains various Items (attributes). Every Item exist of a Name (String) and a list of values (List of Object). Internal every Value is stored inside a Vector Class. All values are stored internally in a Map containing key values pairs.
NOTE: An ItemCollection is not serializable and can not be stored into another ItemCollection. To serialize a ItemCollection use the XMLItemCollection. @see XMLItemCollectionAdapter.
- Version:
- 2.1
- Author:
- Ralph Soika
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a new empty ItemCollectionItemCollection
(Map<String, List<Object>> map) Creates a new ItemCollection and makes a deep copy from a given value MapItemCollection
(ItemCollection itemCol) Creates a new ItemCollection and makes a deep copy from a given ItemCollection -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.void
addFileData
(FileData filedata) This method adds a fileData object to the ItemCollection.appendItemValue
(String itemName, Object itemValue) Appends a value to an existing item.appendItemValueUnique
(String itemName, Object itemValue) Appends a value to an existing item.clone()
This method clones the current ItemCollection.This method clones the current ItemCollection with a subset of items.void
cloneItem
(String itemName, ItemCollection source) This method makes a deep copy of a single item value from a given source ItemCollection.void
copy
(ItemCollection source) Copies all items of a source ItemCollection.static ItemCollection
createByReference
(Map<String, List<Object>> map) Creates a new ItemCollection by a reference to a given value Map.boolean
This method compares the values of two item collections by comparing the hash maps.event
(int eventID) Set the $eventID for a workitem.int
Deprecated.returns all Items of the Collection as a Mapint
Deprecated.Returns a list of all FileData objects.getFileData
(String filename) Returns a FileData object for an attached file.Returns a list of file names attached to the current workitem.getFiles()
Deprecated.getItem()
Returns an ItemAdapter for this instance.Returns an ItemListAdapter for this instance.Returns an ItemListArrayAdapter for this instance.Returns a sorted list of all item names stored in the current ItemCollection.getItemValue
(String itemName) Returns the value list for the specified Item.<T> T
getItemValue
(String itemName, Class<T> itemType) Returns the resolved item value of the specified type.boolean
getItemValueBoolean
(String itemName) Returns the resolved Boolean value of the specified item.getItemValueDate
(String aName) Returns the resolved Date value of the specified item.double
getItemValueDouble
(String itemName) Returns the resolved Double value of the specified item.float
getItemValueFloat
(String itemName) Returns the resolved Float value of the specified item.int
getItemValueInteger
(String itemName) Returns the resolved Integer value of the specified item.<T> List<T>
getItemValueList
(String itemName, Class<T> itemType) Returns the resolved list of item values of the specified type.getItemValueLocalDate
(String aName) Returns the resolved LocalDate value of the specified item.getItemValueLocalDateTime
(String aName) Returns the resolved LocalDateTime value of the specified item.long
getItemValueLong
(String itemName) Returns the resolved Long value of the specified item.getItemValueString
(String itemName) Returns the resolved String value of the specified item.int
Deprecated.int
getType()
boolean
Indicates whether an item exists in the document.boolean
isItemEmpty
(String itemName) Returns true if the given itemname does not exist or no value is assigned to.boolean
isItemValueDate
(String aName) Returns true if the value of an item is from type 'Date'boolean
isItemValueDouble
(String aName) Returns true if the value of an item with a single numeric value is from type 'Double'boolean
isItemValueFloat
(String aName) Returns true if the value of an item with a single numeric value is from type 'Float'boolean
isItemValueInteger
(String aName) Returns true if the value of an item with a single numeric value is from type 'Integer'boolean
isItemValueLong
(String aName) Returns true if the value of an item with a single numeric value is from type 'Long'boolean
isItemValueNumeric
(String aName) Returns true if the value of an item is a numeric value (e.g.void
mergeItems
(Map<String, List<Object>> map) Merges all items from a source map into the current instance.void
purgeItemValue
(String itemName) This method removes duplicates and null or empty values from an item listvoid
removeFile
(String aFilename) This method removes a single file attachment from the workitemvoid
removeItem
(String name) removes a attribute from the item collectionvoid
replaceAllItems
(Map<String, List<Object>> map) Replaces all items specified in the map with new items, which are assigned to the specified values inside the map.void
replaceItemValue
(String itemName, Object itemValue) Replaces the value of an item.void
setActivityID
(int activityID) Deprecated.void
setAllItems
(Map<String, List<Object>> aHash) replaces the current map object.void
setEventID
(int eventID) Set the $eventID for a workitem.setItemValue
(String itemName, Object itemValue) Set the value of an item.setItemValueUnique
(String itemName, Object itemValue) Set the value of an item.void
setModelVersion
(String modelversion) set the $ModelVersionvoid
setTaskID
(int taskID) set $taskIDvoid
set typevoid
setWorkflowGroup
(String group) set the $ModelVersiontask
(int taskID) workflowGroup
(String group)
-
Constructor Details
-
ItemCollection
public ItemCollection()Creates a new empty ItemCollection -
ItemCollection
Creates a new ItemCollection and makes a deep copy from a given value Map- Parameters:
map
- - with item values
-
ItemCollection
Creates a new ItemCollection and makes a deep copy from a given ItemCollection- Parameters:
itemCol
- - ItemCollection with values
-
-
Method Details
-
createByReference
Creates a new ItemCollection by a reference to a given value Map. This method does not make a deep copy of the given map and sets the value map by reference. This method can be used in cases where values are only read. In all other cases, the constructor method 'ItemCollection(map)' should be used.- Parameters:
map
- - reference with item values- Returns:
- new reference
-
clone
This method clones the current ItemCollection. The method makes a deep copy of the current instance. -
clone
This method clones the current ItemCollection with a subset of items. The method makes a deep copy of the current instance and removes items not defined by the list of itemNames.The list of itemNames can contain exact names or a regular expression.
A itemName can also be mapped into a new itemName by separating the target name with a | (e.g. name|parentName)
- Parameters:
itemNames
- - list of items to be copied into the clone- Returns:
- new ItemCollection
-
cloneItem
This method makes a deep copy of a single item value from a given source ItemCollection. The method can be used in cases the item to copy represents a complex data structure and can not be copied by reference. See also deepCopyOfMap.- Parameters:
itemvalue
-
-
equals
This method compares the values of two item collections by comparing the hash maps. This did not garantie that also embedded arrays are equal. -
setItemValue
Set the value of an item. If the ItemCollection does not contain an item with the specified name, the method creates a new item and adds it to the ItemCollection. The ItemName is not case sensitive. Use hasItem to verify the existence of an item. All item names will be lower cased.Each item can contain a list of values (multivalue item). If a single value is provided the method creates a List with one single value (singlevalue item).
If the value is null the method will remove the item. This is equal to the method call removeItem()
If the ItemValue is not serializable the item will be removed.
- Parameters:
itemName
- The name of the item or items you want to replace.itemValue
- The value of the new item. The data type of the item depends upon the data type of value, and does not need to match the data type of the old item.- Returns:
- current instance
-
setItemValueUnique
Set the value of an item. If the ItemCollection does not contain an item with the specified name, the method creates a new item and adds it to the ItemCollection. The ItemName is not case sensitive. Use hasItem to verify the existence of an item. All item names will be lower cased.Each item can contain a list of values (multivalue item). If a single value is provided the method creates a List with one single value (singlevalue item).
If the value is null the method will remove the item. This is equal to the method call removeItem()
If the ItemValue is not serializable the item will be removed.
This method ensures that all values are unique and null or empty values will be removed
- Parameters:
itemName
- The name of the item or items you want to replace.itemValue
- The value of the new item. The data type of the item depends upon the data type of value, and does not need to match the data type of the old item.- Returns:
- current instance
-
appendItemValue
Appends a value to an existing item. If the ItemCollection does not contain an item with the specified name, the method creates a new item and adds it to the ItemCollection. The ItemName is not case sensitive. Use hasItem to verify the existence of an item. All item names will be lower cased.If a value list is provided the method appends each single value.
If the value is null the method will remove the item. This is equal to the method call removeItem()
If the ItemValue is not serializable the item will be removed.
- Parameters:
itemName
- The name of the item or items you want to replace.itemValue
- The value of the new item. The data type of the item depends upon the data type of value, and does not need to match the data type of the old item.- Returns:
- current instance
-
appendItemValueUnique
Appends a value to an existing item. If the ItemCollection does not contain an item with the specified name, the method creates a new item and adds it to the ItemCollection. The ItemName is not case sensitive. Use hasItem to verify the existence of an item. All item names will be lower cased.If a value list is provided the method appends each single value.
If the value is null the method will remove the item. This is equal to the method call removeItem()
If the ItemValue is not serializable the item will be removed.
This method ensures that all values are unique and null or empty values will be removed
- Parameters:
itemName
- The name of the item or items you want to replace.itemValue
- The value of the new item. The data type of the item depends upon the data type of value, and does not need to match the data type of the old item.- Returns:
- current instance
-
getItemValue
Returns the value list for the specified Item. The returned list is untyped and the values contained in the list are not converted to a specific type. The values have the same object type as set by calling the methodsetItemValue(String itemName, Object itemValue)
. To get a typed value list, see the methodgetItemValue(itemName, itemType)
.If the item does not exist or has no values, the method returns an empty List.
The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- an untyped list of values contained by the item.
-
getItemValue
Returns the resolved item value of the specified type. The method converts the value to the specified type if possible, otherwise the method returns null. If the item has multiple values, this method returns the first value.If the item isn't present in the itemCollection the method returns null.
If the specified type is int, float, long, double, Integer, Float, Long or Double, the method returns 0 instead of null
If the item contains no value with the specified type, the method returns null. The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The item Name.itemType
- The type into which the resolve item value should get converted- Returns:
- the resolved item value as an object of the requested type.
-
getItemValueList
Returns the resolved list of item values of the specified type. The method converts the values of the list to the specified type if possible.If the item isn't present in the itemCollection the method returns an empty list.
The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The item Name.itemType
- The type into which the resolved item values should get converted- Returns:
- the resolved list of item values of the requested type.
-
removeItem
removes a attribute from the item collection- Parameters:
name
- - item name
-
hasItem
Indicates whether an item exists in the document.- Parameters:
aName
- - item name- Returns:
- true if an item with name exists in the document, false if no item with name exists in the document
-
isItemEmpty
Returns true if the given itemname does not exist or no value is assigned to. This includes empty strings.- Parameters:
itemName
- - the item to be verified- Returns:
- - true if no value is assigned.
-
isItemValueInteger
Returns true if the value of an item with a single numeric value is from type 'Integer'- Parameters:
aName
- - item name- Returns:
- boolean true if object is from type Double
-
isItemValueLong
Returns true if the value of an item with a single numeric value is from type 'Long'- Parameters:
aName
- - item name- Returns:
- boolean true if object is from type Double
-
isItemValueDouble
Returns true if the value of an item with a single numeric value is from type 'Double'- Parameters:
aName
- - item name- Returns:
- boolean true if object is from type Double
-
isItemValueFloat
Returns true if the value of an item with a single numeric value is from type 'Float'- Parameters:
aName
- - item name- Returns:
- boolean true if object is from type Double
-
isItemValueNumeric
Returns true if the value of an item is a numeric value (e.g. float,double,int,long)- Parameters:
aName
-- Returns:
-
isItemValueDate
Returns true if the value of an item is from type 'Date'- Parameters:
aName
- - item name- Returns:
- boolean true if object is from type Double
-
getAllItems
returns all Items of the Collection as a Map- Returns:
- Map with all Items
-
setAllItems
replaces the current map object. In different to the method replaceAllItems this method overwrites the hash object and did not copy the values- Parameters:
aHash
-
-
getItemNames
Returns a sorted list of all item names stored in the current ItemCollection.- Returns:
- sorted list of item names
-
replaceItemValue
Replaces the value of an item. If the ItemCollection does not contain an item with the specified name, the method creates a new item and adds it to the ItemCollection. The ItemName is not case sensitive. Use hasItem to verify the existence of an item. All item names will be lower cased.Each item can contain a list of values (multivalue item). If a single value is provided the method creates a List with one single value (singlevalue item).
If the value is null the method will remove the item. This is equal to the method call removeItem()
If the ItemValue is not serializable the item will be removed. This method is deprecated and should be replaced by the method setItemvValue.
- Parameters:
itemName
- The name of the item or items you want to replace.itemValue
- The value of the new item. The data type of the item depends upon the data type of value, and does not need to match the data type of the old item.- See Also:
-
setItemValue.
-
getItemValueString
Returns the resolved String value of the specified item. The method converts the stored value to a String. If the item has no value, the method returns an empty String. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the String value of the item
-
getItemValueInteger
Returns the resolved Integer value of the specified item. The method converts the stored value to an Integer. If the item has no value or the value is not convertible to an Integer, the method returns 0. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the integer value of the item
-
getItemValueLong
Returns the resolved Long value of the specified item. The method converts the stored value to long. If the item has no value or the value is not convertible to a Long, the method returns 0. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the Long value of the item
-
getItemValueDate
Returns the resolved Date value of the specified item. If the item has no value or the value is not of the type Date, the method returns null. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the Date value of the item
-
getItemValueLocalDateTime
Returns the resolved LocalDateTime value of the specified item. The method converts a Date object into a LocalDateTime object using the ZoneId.systemDefault().Note: internally the ItemCollection store LocalDateTime values as Date objects!
If the item has no value or the value is not of the type Date, the method returns null. If the item has multiple values, this method returns the first value.
The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the Date value of the item
-
getItemValueLocalDate
Returns the resolved LocalDate value of the specified item. The method converts a Date object into a LocalDate object using the ZoneId.systemDefault().Note: internally the ItemCollection store LocalDateTime values as Date objects!
If the item has no value or the value is not of the type Date, the method returns null. If the item has multiple values, this method returns the first value.
The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the Date value of the item
-
getItemValueDouble
Returns the resolved Double value of the specified item. The method converts the stored value to double. If the item has no value or the value is not convertible to a Double, the method returns 0.0. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the double value of the item
-
getItemValueFloat
Returns the resolved Float value of the specified item. The method converts the stored value to float. If the item has no value or the value is not convertible to a Float, the method returns 0.0. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the float value of the item
-
getItemValueBoolean
Returns the resolved Boolean value of the specified item. The method converts the stored value to Boolean. If the item has no value or the value is not convertible to a Boolean, the method returns false. If the item has multiple values, this method returns the first value.The ItemName is not case sensitive. Use hasItem to verify the existence of an item.
- Parameters:
itemName
- The name of an item.- Returns:
- the boolean value of the item
-
replaceAllItems
Replaces all items specified in the map with new items, which are assigned to the specified values inside the map. The method makes a deep copy of the source map using serialization. This is to make sure, that no object reference is copied. Other wise for example embedded arrays are not cloned. This is also important for JPA to avoid changes of attached entity beans with references in the data of an ItemCollection.- Parameters:
map
-- See Also:
-
deepCopyOfMap(java.util.Map<java.lang.String,java.util.List<java.lang.Object>>)
-
copy
Copies all items of a source ItemCollection.The method makes a deep copy of the source map using serialization. This is to make sure, that no object reference is copied. Other wise for example embedded arrays are not cloned. This is also important for JPA to avoid changes of attached entity beans with references in the data of an ItemCollection.
- Parameters:
map
-- See Also:
-
deepCopyOfMap(java.util.Map<java.lang.String,java.util.List<java.lang.Object>>)
-
mergeItems
Merges all items from a source map into the current instance. Only Items will be copied if the current instance does not have an item with the same name. If you want to copy all item values, use the method replaceAllItems instead.The method makes a deep copy of the source map using serialization. This is to make sure, that no object reference is copied. Other wise for example embedded arrays are not cloned. This is also important for JPA to avoid changes of attached entity beans with references in the data of an ItemCollection.
- Parameters:
map
-- See Also:
-
deepCopyOfMap(java.util.Map<java.lang.String,java.util.List<java.lang.Object>>)
-
purgeItemValue
This method removes duplicates and null or empty values from an item list- Parameters:
itemName
- - item to be processed
-
addFileData
This method adds a fileData object to the ItemCollection. The item '$file' stores all data objects.- Parameters:
filedata
- - a file data object- See Also:
-
addFile
Deprecated.This method adds a single file to the ItemCollection. files will be stored into the property $file.Method is deprecated. Use addFileData instead!
- Parameters:
data
- - byte array with file datafileName
- - name of the file attachmentcontentType
- - the content type (e.g. 'Text/HTML')
-
getFile
Deprecated.Returns a data object for an attached file. The data object is a list containing the contentType (String) and the content (byte[])- Parameters:
filename
-- Returns:
- file data contentType (String) and the content (byte[])
-
getFileData
Returns a FileData object for an attached file.- Parameters:
filename
-- Returns:
- FileData object
-
getFileData
Returns a list of all FileData objects.FileData objects are stored in the attribute '$file'.
- Returns:
- list of FileData objects
-
removeFile
This method removes a single file attachment from the workitem -
getFiles
Deprecated.Returns files stored in the property '$file'. The files are returned in a Map interface where the key is the filename and the value is a list with two elements - the ContenType and the file content (byte[]). s Files can be added into a ItemCollection using the method addFile().- Returns:
-
getFileNames
Returns a list of file names attached to the current workitem. File Attachments can be added using the method addFile().- Returns:
-
getItem
Returns an ItemAdapter for this instance.- Returns:
-
getItemList
Returns an ItemListAdapter for this instance.- Returns:
-
getItemListArray
Returns an ItemListArrayAdapter for this instance.- Returns:
-
getType
- Returns:
- current type
-
setType
set type- Parameters:
type
-
-
getTaskID
public int getTaskID()- Returns:
- current $TaskID
-
setTaskID
public void setTaskID(int taskID) set $taskID- Parameters:
taskID
-
-
task
-
getEventID
public int getEventID()- Returns:
- current $EventID
-
setEventID
public void setEventID(int eventID) Set the $eventID for a workitem.- Parameters:
eventID
-
-
event
Set the $eventID for a workitem.- Parameters:
eventID
-- Returns:
-
getModelVersion
- Returns:
- current $ModelVersion
-
setModelVersion
set the $ModelVersion -
model
-
getWorkflowGroup
- Returns:
- current $ModelVersion
-
setWorkflowGroup
set the $ModelVersion -
workflowGroup
-
getUniqueID
- Returns:
- $UniqueID
-
getProcessID
Deprecated.This method is deprecated. Use instead getTaskID()- Returns:
- current $processID
-
getActivityID
Deprecated.This method is deprecated. Use instead getEventID()- Returns:
- current $ActivityID
-
setActivityID
Deprecated.set $ActivityID. This method is deprecated. Use instead setEventID()- Parameters:
activityID
-
-