org.caleigo.core
Interface ISelection

All Superinterfaces:
IEntityPool, java.io.Serializable
All Known Subinterfaces:
IProxySelection, IQualifiedSelection
All Known Implementing Classes:
ProxySelection, QualifiedSelection, Selection

public interface ISelection
extends IEntityPool

IEntityCollection defines the interface to entity collection class that can store zero or more IEntity objects. The entities stored by this interface are type specified and must be defined by a single IEntityDescriptor. IEntityCollection is ordered and contained entities can be accesed by index. Implementations to this interface must not accept duplicate entities.

Version:
1.00
Author:
Dennis Zikovic

Method Summary
 boolean addEntity(IEntity entity)
          Adds the provided IEntity object to the end of selection object.
 boolean addEntity(int index, IEntity entity)
          Adds the provided IEntity object to at the specified index in the selection object.
 void addEntityChangeListener(IEntityChangeListener listener)
          Adds IEntityChangeListener to receive notifications of performed data operations on all entities contained in the collection object.
 void addEntityListener(IEntityListener listener)
          Adds IEntityListener to receive notifications of performed data operations on all entities contained in the collection object.
 void addSelectionListener(ISelectionListener listener)
          Adds an IEntityCollectionListener to receive notifiactions of changes in the entity content of the collection object.
 java.util.List asList()
          Returns a List that acts as a wrapper for the selection.
 java.util.Set asSet()
          Returns a Set that acts as a wrapper for the selection.
 void clear()
          Mutation method the removes all entities currently stored in the selection.
 boolean contains(IEntity entity)
          Help method that returns true if the provided IEntity object exists in the selection otherwise false is returned.
 ISelection createSubSelection(int[] indexArray)
          Creates a sub selection with the indexed entities in the called selection.
 ISelection createSubSelection(Qualifier qualifier)
          Creates a sub selection with all qualified entities in the called selection.
 void deleteAll()
          Deletes all contained entities.
 boolean doesAccept(IEntity entity)
          Help method that returns true if the provided IEntity object will be accepted by the selection if added or inserted to it.
 java.lang.Object getData(int row, int column)
          Access method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.
 IEntity getEntity(int index)
          Access method that returns the contained IEntity object with the specified index.
 IEntityDescriptor getEntityDescriptor()
          Access method that returns the IEntityDescriptor for the selection.
 int indexOf(IEntity entity)
          Help method that returns the index of the provided IEntity object in the selection if it exists othewise a negative value is returned.
 int indexOf(IFieldDescriptor fieldDescriptor, java.lang.Object fieldData)
          Help method that returns the index of the the first entity object in the selection with the specified field set to the specified value.
 boolean isDirty()
          Return true if any (one or more) of the collections's contained entities has the DIRTY flag set to true that is have unsaved changes.
 boolean isEmpty()
          Boolean access method that return true if the selection is empty.
 java.util.Iterator iterator()
          Returns a java.util.Iterator object that iterates over all entities in the selection.
 void refreshAll()
          Performs a refresh on all contained entities.
 boolean removeEntity(IEntity entity)
          Mutation method that removes the provided entity from the selection.
 IEntity removeEntity(int index)
          Mutation method that removes the indexed entity from the selection.
 void removeEntityChangeListener(IEntityChangeListener listener)
          Removes the specified IEntityListener from the collection object.
 void removeEntityListener(IEntityListener listener)
          Removes the specified IEntityListener from the collection object.
 void removeSelectionListener(ISelectionListener listener)
          Removes an IEntityCollectionListener from the collection object.
 void setData(int row, int column, java.lang.Object dataValue)
          Mutation method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.
 int size()
          Access method that reurns the number entities currently contained in the selection object.
 void sort(java.util.Comparator comparator)
          This method sorts the called selection using the provided comparator.
 void storeAll()
          Stores all contained entities that have the DIRTY flag set to true.
 

Method Detail

isDirty

public boolean isDirty()
Return true if any (one or more) of the collections's contained entities has the DIRTY flag set to true that is have unsaved changes.

Specified by:
isDirty in interface IEntityPool

storeAll

public void storeAll()
Stores all contained entities that have the DIRTY flag set to true. The entities are stored in a single transaction meaning that if one store fails then all fails.

Specified by:
storeAll in interface IEntityPool

deleteAll

public void deleteAll()
Deletes all contained entities. The entities are deleted in a single transaction meaning that if one delete fails then all fails. USE THIS METHOD WITH CAUTION.

Specified by:
deleteAll in interface IEntityPool

refreshAll

public void refreshAll()
Performs a refresh on all contained entities. The refresh is batched to save performance.

Specified by:
refreshAll in interface IEntityPool

addEntity

public boolean addEntity(IEntity entity)
Adds the provided IEntity object to the end of selection object. If an entity with the same identity already exists in the selection the requeat is ignored and false is returned.

Specified by:
addEntity in interface IEntityPool

addEntity

public boolean addEntity(int index,
                         IEntity entity)
Adds the provided IEntity object to at the specified index in the selection object. If an entity with the same identity already exists in the selection the requeat is ignored and false is returned.


getEntity

public IEntity getEntity(int index)
Access method that returns the contained IEntity object with the specified index.


removeEntity

public boolean removeEntity(IEntity entity)
Mutation method that removes the provided entity from the selection. Returns true if the entity was found and removed otherwise false is returned.

Specified by:
removeEntity in interface IEntityPool

removeEntity

public IEntity removeEntity(int index)
Mutation method that removes the indexed entity from the selection. Returns the indexed entity if it was found and removed otherwise null is returned. The entities are not effecte in any other way.


iterator

public java.util.Iterator iterator()
Returns a java.util.Iterator object that iterates over all entities in the selection. The iterator should be read only and should not support the remove method. The entities are not effected in any other way.

Specified by:
iterator in interface IEntityPool

clear

public void clear()
Mutation method the removes all entities currently stored in the selection. The entities are not effected in any other way.

Specified by:
clear in interface IEntityPool

size

public int size()
Access method that reurns the number entities currently contained in the selection object.

Specified by:
size in interface IEntityPool

isEmpty

public boolean isEmpty()
Boolean access method that return true if the selection is empty.

Specified by:
isEmpty in interface IEntityPool

getData

public java.lang.Object getData(int row,
                                int column)
Access method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.


setData

public void setData(int row,
                    int column,
                    java.lang.Object dataValue)
Mutation method that views the selection objct as a grid where row is the entity index and column is the field index for the stored entities.


getEntityDescriptor

public IEntityDescriptor getEntityDescriptor()
Access method that returns the IEntityDescriptor for the selection. The selection object will only support entities of that type.


addSelectionListener

public void addSelectionListener(ISelectionListener listener)
Adds an IEntityCollectionListener to receive notifiactions of changes in the entity content of the collection object.


removeSelectionListener

public void removeSelectionListener(ISelectionListener listener)
Removes an IEntityCollectionListener from the collection object.


addEntityListener

public void addEntityListener(IEntityListener listener)
Adds IEntityListener to receive notifications of performed data operations on all entities contained in the collection object.


removeEntityListener

public void removeEntityListener(IEntityListener listener)
Removes the specified IEntityListener from the collection object.


addEntityChangeListener

public void addEntityChangeListener(IEntityChangeListener listener)
Adds IEntityChangeListener to receive notifications of performed data operations on all entities contained in the collection object. Note that changes can in specific situations like during end-user editation be very frequent.


removeEntityChangeListener

public void removeEntityChangeListener(IEntityChangeListener listener)
Removes the specified IEntityListener from the collection object.


createSubSelection

public ISelection createSubSelection(int[] indexArray)
Creates a sub selection with the indexed entities in the called selection. The created selection that should be independant of changes in the source/called selection after the time of creation.


createSubSelection

public ISelection createSubSelection(Qualifier qualifier)
Creates a sub selection with all qualified entities in the called selection. The created selection that should be independant of changes in the source/called selection after the time of creation.


contains

public boolean contains(IEntity entity)
Help method that returns true if the provided IEntity object exists in the selection otherwise false is returned.

Specified by:
contains in interface IEntityPool

indexOf

public int indexOf(IEntity entity)
Help method that returns the index of the provided IEntity object in the selection if it exists othewise a negative value is returned.


indexOf

public int indexOf(IFieldDescriptor fieldDescriptor,
                   java.lang.Object fieldData)
Help method that returns the index of the the first entity object in the selection with the specified field set to the specified value.


doesAccept

public boolean doesAccept(IEntity entity)
Help method that returns true if the provided IEntity object will be accepted by the selection if added or inserted to it. Reasons for not accepting an entity is wrong type (IEntityDescriptor), already included or if selection is qualified the entity may fail qualification.

Specified by:
doesAccept in interface IEntityPool

sort

public void sort(java.util.Comparator comparator)
This method sorts the called selection using the provided comparator. One single content change event will be fired when this method is called. Note that if the provided Comparator does not support IEntity objects an exeption will be thrown.

See Also:
EntityCollator

asSet

public java.util.Set asSet()
Returns a Set that acts as a wrapper for the selection. The Set object should reflect changes to and from the wrapped selection.

Specified by:
asSet in interface IEntityPool

asList

public java.util.List asList()
Returns a List that acts as a wrapper for the selection. The List object should reflect changes to and from the wrapped selection.



Copyright © 2005 Caleigo. All Rights Reserved.