org.imixs.workflow
Class ItemCollection

java.lang.Object
  extended by org.imixs.workflow.ItemCollection
All Implemented Interfaces:
Serializable

public class ItemCollection
extends Object
implements Serializable

This Class defines a ValueObject to be used to exchange Datastructures used by the org.imixs.workflow Framework. Every component of this framework should use this wrapper class to easy transport workflowrelevant data between the different workflow modules. ValueObjects, particular in J2EE Applications, have the advantage to improve perfomance of remote methode calls and also enables a flexibly datastructure. A ItemCollection contains various Items (attributes). Every Item exist of a Name and a Value. Internal every Value is stored inside a Vector Class. So it is also possible to store multivalueobjects. The ItemCollection wraps the java.util.Hashtable Class and implements the java.io.Serializable Interface, so the ValeOject can also be serialised inside a remote methode call.

Version:
2.0
Author:
Ralph Soika
See Also:
WorkflowManager, Serialized Form

Constructor Summary
ItemCollection()
          Creates a empty ItemCollection
ItemCollection(Map map)
          Creates a new ItemCollection and transfers all Objects of map as new values.
 
Method Summary
 void addFile(byte[] data, String fileName, String contentType)
          This method adds a single file to the ItemCollection. files will be stored into the property $file.
 void appendItemValue(String itemName, Object itemValue)
          Appends a value to an existing item.
 boolean equals(Object o)
           
 Map getAllItems()
          returns all Items of the Collection as a Map
 String[] getFiles()
          Returns a list of file names attached to the current BlobWorkitem.
 Map getItem()
           
 Map getItemList()
           
 Map getItemListArray()
           
 List getItemValue(String aName)
          returns the Value of a single Item inside the ItemCollection.
 boolean getItemValueBoolean(String aName)
          Returns the boolean value of an item.
 Date getItemValueDate(String aName)
          Returns the value of an item with a single Date value.
 double getItemValueDouble(String aName)
          Returns the value of an item with a single numeric value.
 int getItemValueInteger(String aName)
          Returns the value of an item with a single numeric value.
 String getItemValueString(String aName)
          Returns the value of an item with a single text value.
 boolean hasItem(String aName)
          Indicates whether an item exists in the document.
 void removeFile(String aFilename)
          This method removes a single file attachment from the BlobWorkitem
 void removeItem(String name)
          removes a attribute from the item collection
 void replaceAllItems(Map 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 setAllItems(Map aHash)
          replaces the current map object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemCollection

public ItemCollection()
Creates a empty ItemCollection


ItemCollection

public ItemCollection(Map map)
Creates a new ItemCollection and transfers all Objects of map as new values.

Parameters:
map -
Method Detail

equals

public boolean equals(Object o)
Overrides:
equals in class Object

getItemValue

public List getItemValue(String aName)
returns the Value of a single Item inside the ItemCollection. If the item has no value, this method returns an empty vector. If no item with the specified name exists, this method returns an empty vector. It does not throw an exception. The ItemName is not case sensitive. Use hasItem to verify the existence of an item.

Parameters:
aName - The name of an item.
Returns:
The value or values contained in the item. The data type of the value depends on the data type of the item.

getItemValueString

public String getItemValueString(String aName)
Returns the value of an item with a single text value. If the item has no value or the value is numeric or non text, this method returns an empty String. If no item with the specified name exists, this method returns an empty String. It does not throw an exception. 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:
aName - The name of an item.
Returns:
The value of the item

getItemValueInteger

public int getItemValueInteger(String aName)
Returns the value of an item with a single numeric value. If the item has no value or the value is no Integer, or empty, this method returns 0. If no item with the specified name exists, this method returns 0. It does not throw an exception. 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:
aName -
Returns:
integer value

getItemValueDate

public Date getItemValueDate(String aName)
Returns the value of an item with a single Date value. If the item has no value or the value is no Date, or empty, this method returns null. If no item with the specified name exists, this method returns null. It does not throw an exception. 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:
aName -
Returns:
Date value

getItemValueDouble

public double getItemValueDouble(String aName)
Returns the value of an item with a single numeric value. If the item has no value or the value is no Double, or empty, this method returns 0.0. If no item with the specified name exists, this method returns 0.0. It does not throw an exception. If the item has multiple values, this method returns the first value. The Itemname is not case sensetive. Use hasItem to verify the existence of an item.

Parameters:
aName -
Returns:
double value

getItemValueBoolean

public boolean getItemValueBoolean(String aName)
Returns the boolean value of an item. If the item has no value or the value is no boolean, or empty, this method returns false. If no item with the specified name exists, this method returns false. It does not throw an exception. 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:
aName -
Returns:
boolean value

hasItem

public boolean hasItem(String aName)
Indicates whether an item exists in the document.

Parameters:
aName - The name of an item.
Returns:
true if an item with name exists in the document, false if no item with name exists in the document

getAllItems

public Map getAllItems()
returns all Items of the Collection as a Map

Returns:
Map with all Items

setAllItems

public void setAllItems(Map aHash)
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 -

replaceItemValue

public void replaceItemValue(String itemName,
                             Object itemValue)
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.

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.

appendItemValue

public void appendItemValue(String itemName,
                            Object itemValue)
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.

replaceAllItems

public void replaceAllItems(Map map)
Replaces all items specified in the map with new items, which are assigned to the specified values inside the map

Parameters:
map -

removeItem

public void removeItem(String name)
removes a attribute from the item collection

Parameters:
name -

addFile

public void addFile(byte[] data,
                    String fileName,
                    String contentType)
This method adds a single file to the ItemCollection. files will be stored into the property $file.

Parameters:
data - - byte array with file data
fileName - - name of the file attachment
contentType - - the contenttype (e.g. 'Text/HTML')

removeFile

public void removeFile(String aFilename)
This method removes a single file attachment from the BlobWorkitem


getFiles

public String[] getFiles()
Returns a list of file names attached to the current BlobWorkitem. File Attachments can be added using the method addFile().

Returns:

getItem

public Map getItem()

getItemList

public Map getItemList()

getItemListArray

public Map getItemListArray()


Copyright © 2006-2012 Imixs Software Solutions GmbH. All Rights Reserved.