org.xins.common.types
Class ItemList

java.lang.Object
  extended byorg.xins.common.types.ItemList
Direct Known Subclasses:
List.Value, Set.Value

public class ItemList
extends Object

Item in a list or a set type.

Since:
XINS 1.0.0
Version:
$Revision: 1.19 $ $Date: 2008/07/04 10:22:40 $
Author:
Anthony Goubard
See Also:
List

Constructor Summary
ItemList()
          Creates a new ItemList.
ItemList(boolean setType)
          Creates a new ItemList.
 
Method Summary
 void add(Collection items)
          Adds a list of items to the list or set.
protected  void addItem(Object value)
          Adds an item to the list.
 Collection get()
          Gets the list of items as a collection.
protected  Object getItem(int index)
          Gets the item at the specified index as an Object.
 int getSize()
          Gets the number of items included in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemList

public ItemList()
Creates a new ItemList. The list will be able to contain several instances of an object.


ItemList

public ItemList(boolean setType)
Creates a new ItemList.

Parameters:
setType - if true an object can be added only once in the list, if false an object can be added several times in the list.
Method Detail

add

public final void add(Collection items)
               throws IllegalArgumentException
Adds a list of items to the list or set. The items are added at the end of the list.

Parameters:
items - the collection of items to add in the list, cannot be null.
Throws:
IllegalArgumentException - if items == null.
Since:
XINS 2.0.

get

public final Collection get()
Gets the list of items as a collection. A java.util.Set or a java.util.List is returned depending on the type of this list.

Returns:
a List or a Set containing the items, never null. the collection returned cannot be modified.
Since:
XINS 2.0.

addItem

protected final void addItem(Object value)
                      throws IllegalArgumentException
Adds an item to the list. The item is added at the end of the list.

Parameters:
value - the value of the item to add in the list, cannot be null.
Throws:
IllegalArgumentException - if value == null.

getItem

protected final Object getItem(int index)
Gets the item at the specified index as an Object.

Parameters:
index - the position of the required item, it should be >= 0 and < getSize().
Returns:
the item, not null.

getSize

public int getSize()
Gets the number of items included in the list.

Returns:
the size of the list.


See http://www.xins.org/.