Interface Container

A specialized set of identified Items. Basically the Container is a set of Items, but it imposes certain constraints on its contents. These constraints state the following:

  • All Items in the Container must include the same number of Properties

  • All Items in the Container must include the same Property ID sets (see getItemPropertyIds() ).

  • all Properties in the Items corresponding to the same Property ID must have the same data type.

The Container can be visualized as a representation of a relational database table. Each Item in the Container represents a row in the table, and all cells in a column (identified by a Property ID) have the same data type. Note that as with the cells in a database table, no Property in a Container may be empty, though they may contain null values.

Note that though uniquely identified, the Items in a Container are not neccessarily ordered or indexed .

The Container interface is split to several subinterfaces so that a class can implement only the ones it needs.

Synopsis

Inheritance Path.  com.itmill.toolkit.data.Container

addContainerProperty(Object, Class, Object)

Parameters

propertyId

ID of the Property

type

Data type of the new Property

defaultValue

The value all created Properties are initialized to

return

true if the operation succeeded, false if not

Adds a new Property to all Items in the Container. The Property ID, data type and default value of the new Property are given as parameters. This functionality is optional.

addItem()

Parameters

return

ID of the newly created Item, or null in case of a failure

Creates a new Item into the Container, and assign it an automatic ID.

The new ID is returned, or null if the operation fails. After a successful call you can use the <javadoc:link ref="METHOD-11-1" name=" getItem "> getItem method to fetch the Item.

This functionality is optional.

addItem(Object)

Parameters

itemId

ID of the Item to be created

return

Created new Item, or null in case of a failure

Creates a new Item with the given ID into the Container. The new

Item is returned, and it is ready to have its Properties modified. Returns null if the operation fails or the Container already contains a Item with the given ID.

This functionality is optional.

containsId(Object)

Parameters

itemId

ID the of Item to be tested

return

boolean indicating if the Container holds the specified Item

Tests if the Container contains the specified Item

getContainerProperty(Object, Object)

Parameters

itemId

ID of the Item which contains the Property

propertyId

ID of the Property to retrieve

return

Property with the given ID or null

Gets the Property identified by the given itemId and propertyId from the Container. If the Container does not contain the Property, null is returned.

getContainerPropertyIds()

Parameters

return

unmodifiable collection of Property IDs

Gets the ID's of all Properties stored in the Container. The ID's are returned as a unmodifiable collection.

getItem(Object)

Parameters

itemId

ID of the Item to retrieve

return

the Item with the given ID or null if the Item is not found in the Container

Gets the Item with the given Item ID from the Container. If the Container does not contain the requested Item, null is returned.

getItemIds()

Parameters

return

unmodifiable collection of Item IDs

Gets the ID's of all Items stored in the Container. The ID's are returned as a unmodifiable collection.

getType(Object)

Parameters

propertyId

ID identifying the Properties

return

data type of the Properties

Gets the data type of all Properties identified by the given Property ID.

removeAllItems()

Parameters

return

true if the operation succeeded, false if not

Removes all Items from the Container.

Note that Property ID and type information is preserved. This functionality is optional.

removeContainerProperty(Object)

Parameters

propertyId

ID of the Property to remove

return

true if the operation succeeded, false if not

Removes a Property specified by the given Property ID from the Container. Note that the Property will be removed from all Items in the Container. This functionality is optional.

removeItem(Object)

Parameters

itemId

ID of the Item to remove

return

true if the operation succeeded, false if not

Removes the Item identified by ItemId from the Container. This functionality is optional.

size()

Parameters

return

number of Items in the Container

Gets the number of Items in the Container.