|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dsto.dfc.databeans.AbstractDataObject dsto.dfc.databeans.SimpleDataObject dsto.dfc.databeans.FancyDataObject livespace.services.EntityList
public class EntityList
An ordered list of entities. This list allows duplicate entities to be added to the list.
This uses an EntityRegistry to store the entities and includes an 'index' attribute with each entity to order the actual contained entities.
Rolling indexes are used internally for maintaining the order of entities within the list to reduce the property change events that occur when manipulating the list. This means adding to the end of the list, or removing from either ends of the list, only results in one property change event for the list. Adding or removing in the middle of the list will trigger multiple property change events as the indexes of the entities in the list above the modified index will need to be modified also.
Nested Class Summary | |
---|---|
class |
EntityList.ListEntity
Wraps an Entity and adds an index attribute to maintain the index
of an entity within an EntityList . |
Field Summary | |
---|---|
int |
endIndex
|
EntityRegistry |
entities
|
int |
startIndex
|
Fields inherited from class dsto.dfc.databeans.AbstractDataObject |
---|
listeners |
Fields inherited from interface dsto.dfc.databeans.IDataObject |
---|
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE |
Constructor Summary | |
---|---|
EntityList()
|
Method Summary | |
---|---|
void |
add(Entity e)
Adds the specified entity to the end of the list. |
void |
add(int index,
Entity e)
Inserts the specified entity at the specified position in the list. |
void |
clear()
|
Entity |
get(int index)
Returns the entity at the specified position in this list. |
boolean |
isEmpty()
Returns true if this list contains no entities. |
Iterator<Entity> |
iterator()
Returns an iterator of EntityList.ListEntity 's contained within this list. |
boolean |
remove(Entity e)
Removes the first occurrence in this list of the specified entity. |
Entity |
remove(int index)
Removes the entity at the specified position in the list. |
Entity |
remove(String id)
Removes the first occurrence in this list of an entity with the specified id. |
int |
size()
Returns the number of entities in the list. |
List<Entity> |
snapshot()
Returns a snapshot of the EntityList.ListEntity 's within this list. |
Methods inherited from class dsto.dfc.databeans.FancyDataObject |
---|
childPropertyChanged, getValue, isTransient, propertyIterator, setValue, shallowClone |
Methods inherited from class dsto.dfc.databeans.SimpleDataObject |
---|
getFieldNames, getTypeInfo, setValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public EntityRegistry entities
public int startIndex
public int endIndex
Constructor Detail |
---|
public EntityList()
Method Detail |
---|
public boolean isEmpty()
public int size()
public void add(Entity e)
e
- the Entity to add to the end of the list.public void add(int index, Entity e) throws IndexOutOfBoundsException
index
- index at which the specified entity is to be insertede
- the entity to be inserted
IndexOutOfBoundsException
- if the index is out of range (index < 0 ||
index > size())public Entity remove(int index) throws IllegalStateException, IndexOutOfBoundsException
index
- the index of the entity to be removed
IllegalStateException
- if there was no entity found at the specified
position
IndexOutOfBoundsException
- if the index is out of range (index < 0 ||
index >= size())public boolean remove(Entity e)
e
- the entity to remove
public Entity remove(String id)
id
- the id of the entity to remove
public Entity get(int index)
index
- the index of the entity to return
public Iterator<Entity> iterator()
EntityList.ListEntity
's contained within this list. This
will be from a snapshot of the list so changes to the underlying list will
not be reflected in this iterator once it is created.
public void clear()
public List<Entity> snapshot()
EntityList.ListEntity
's within this list.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |