org.millstone.base.data
Interface Container

All Known Subinterfaces:
Container.Hierarchical, Container.Indexed, Container.Ordered
All Known Implementing Classes:
ContainerHierarchicalWrapper, ContainerOrderedWrapper, FilesystemContainer, HierarchicalContainer, IndexedContainer, Select, Tree

public 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:

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.

Since:
3.0
Version:
3.0.3
Author:
IT Mill Ltd

Nested Class Summary
static interface Container.Editor
          Interface implemented by the editor classes supporting editing the Container.
static interface Container.Hierarchical
          Interface for Container classes whose Items can be arranged hierarchically.
static interface Container.Indexed
          Interface for Container classes whose Items can be indexed.
static interface Container.ItemSetChangeEvent
          An Event object specifying the Container whose Item set has changed.
static interface Container.ItemSetChangeListener
          Container Item set change listener interface.
static interface Container.ItemSetChangeNotifier
          The interface for adding and removing ItemSetChangeEvent listeners.
static interface Container.Ordered
          Interface for Container classes whose Items can be traversed in order.
static interface Container.PropertySetChangeEvent
          An Event object specifying the Container whose Property set has changed.
static interface Container.PropertySetChangeListener
          The listener interface for receiving PropertySetChangeEvent objects.
static interface Container.PropertySetChangeNotifier
          The interface for adding and removing PropertySetChangeEvent listeners.
static interface Container.Viewer
          Interface implemented by viewer classes capable of using a Container as a data source.
 
Field Summary
static java.lang.Object NULL_ITEM_ID
           
 
Method Summary
 boolean addContainerProperty(java.lang.Object propertyId, java.lang.Class type, java.lang.Object defaultValue)
          Adds a new Property to all Items in the Container.
 java.lang.Object addItem()
          Creates a new Item into the Container, and assign it an automatic ID.
 Item addItem(java.lang.Object itemId)
          Creates a new Item with the given ID into the Container.
 boolean containsId(java.lang.Object itemId)
          Tests if the Container contains the specified Item
 Property getContainerProperty(java.lang.Object itemId, java.lang.Object propertyId)
          Gets the Property identified by the given itemId and propertyId from the Container.
 java.util.Collection getContainerPropertyIds()
          Gets the ID's of all Properties stored in the Container.
 Item getItem(java.lang.Object itemId)
          Gets the Item with the given Item ID from the Container.
 java.util.Collection getItemIds()
          Gets the ID's of all Items stored in the Container.
 java.lang.Class getType(java.lang.Object propertyId)
          Gets the data type of all Properties identified by the given Property ID.
 boolean removeAllItems()
          Removes all Items from the Container.
 boolean removeContainerProperty(java.lang.Object propertyId)
          Removes a Property specified by the given Property ID from the Container.
 boolean removeItem(java.lang.Object itemId)
          Removes the Item identified by ItemId from the Container.
 int size()
          Gets the number of Items in the Container.
 

Field Detail

NULL_ITEM_ID

public static final java.lang.Object NULL_ITEM_ID
Method Detail

getItem

public Item getItem(java.lang.Object itemId)
Gets the Item with the given Item ID from the Container. If the Container does not contain the requested Item, null is returned.

Parameters:
itemId - ID of the Item to retrieve
Returns:
the Item with the given ID or null if the Item is not found in the Container

getContainerPropertyIds

public java.util.Collection getContainerPropertyIds()
Gets the ID's of all Properties stored in the Container. The ID's are returned as a unmodifiable collection.

Returns:
unmodifiable collection of Property IDs

getItemIds

public java.util.Collection getItemIds()
Gets the ID's of all Items stored in the Container. The ID's are returned as a unmodifiable collection.

Returns:
unmodifiable collection of Item IDs

getContainerProperty

public Property getContainerProperty(java.lang.Object itemId,
                                     java.lang.Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container. If the Container does not contain the Property, null is returned.

Parameters:
itemId - ID of the Item which contains the Property
propertyId - ID of the Property to retrieve
Returns:
Property with the given ID or null

getType

public java.lang.Class getType(java.lang.Object propertyId)
Gets the data type of all Properties identified by the given Property ID.

Parameters:
propertyId - ID identifying the Properties
Returns:
data type of the Properties

size

public int size()
Gets the number of Items in the Container.

Returns:
number of Items in the Container

containsId

public boolean containsId(java.lang.Object itemId)
Tests if the Container contains the specified Item

Parameters:
itemId - ID the of Item to be tested
Returns:
boolean indicating if the Container holds the specified Item

addItem

public Item addItem(java.lang.Object itemId)
             throws java.lang.UnsupportedOperationException
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.

Parameters:
itemId - ID of the Item to be created
Returns:
Created new Item, or null in case of a failure
java.lang.UnsupportedOperationException

addItem

public java.lang.Object addItem()
                         throws java.lang.UnsupportedOperationException
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 getItem method to fetch the Item.

This functionality is optional.

Returns:
ID of the newly created Item, or null in case of a failure
java.lang.UnsupportedOperationException

removeItem

public boolean removeItem(java.lang.Object itemId)
                   throws java.lang.UnsupportedOperationException
Removes the Item identified by ItemId from the Container. This functionality is optional.

Parameters:
itemId - ID of the Item to remove
Returns:
true if the operation succeeded, false if not
java.lang.UnsupportedOperationException

addContainerProperty

public boolean addContainerProperty(java.lang.Object propertyId,
                                    java.lang.Class type,
                                    java.lang.Object defaultValue)
                             throws java.lang.UnsupportedOperationException
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.

Parameters:
propertyId - ID of the Property
type - Data type of the new Property
defaultValue - The value all created Properties are initialized to
Returns:
true if the operation succeeded, false if not
java.lang.UnsupportedOperationException

removeContainerProperty

public boolean removeContainerProperty(java.lang.Object propertyId)
                                throws java.lang.UnsupportedOperationException
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.

Parameters:
propertyId - ID of the Property to remove
Returns:
true if the operation succeeded, false if not
java.lang.UnsupportedOperationException

removeAllItems

public boolean removeAllItems()
                       throws java.lang.UnsupportedOperationException
Removes all Items from the Container.

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

Returns:
true if the operation succeeded, false if not
java.lang.UnsupportedOperationException


Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.