|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList
org.apache.cayenne.util.IndexPropertyList
public class IndexPropertyList
A List implementation that would maintain its internal ordering based on some object numeric "index" property. When objects are added to the list at a certain index, an "index" property is modified to reflect list order, when objects are removed, their index property is set to the negative number.
For performance reasons this implementation does not guarantee that there is no gaps in
the integer ordering sequence (i.e. generally
object.getIndexProperty() != list.indexOf(object)
). However it
guarantees the right ordering based on index property.
Field Summary | |
---|---|
protected String |
indexProperty
|
protected List |
list
A list used for the actual objects storage. |
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
IndexPropertyList(String indexProperty)
Creates an empty NumericPropertyOrderedList. |
|
IndexPropertyList(String indexProperty,
List objects,
boolean sortNeeded)
Creates a NumericPropertyOrderedList that decorates another list. |
Method Summary | |
---|---|
void |
add(int index,
Object element)
|
protected int |
calculateIndexValue(int listIndex)
Calculates an index value at the specified list index. |
Object |
get(int index)
|
protected int |
getIndexValue(Object object)
|
Object |
getValue()
Returns an object stored by this ValueHolder. |
Object |
getValueDirectly()
Retrieves ValueHolder value without triggering fault resolution. |
void |
invalidate()
Turns a ValueHolder into a fault. |
boolean |
isFault()
Returns true if the internal value is not yet resolved. |
Object |
remove(int index)
|
Object |
set(int index,
Object element)
|
protected void |
setIndexValue(Object object,
int index)
|
Object |
setValue(Object value)
Sets an object stored by this ValueHolder. |
Object |
setValueDirectly(Object value)
Sets ValueHolder vaue without triggering fault resolution. |
protected void |
shift(int startIndex,
int afterIndexValue)
|
int |
size()
|
protected void |
sort()
Sorts internal list. |
void |
touch()
Changes list state to "dirty" forcing reordering on next access. |
Methods inherited from class java.util.AbstractList |
---|
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
Field Detail |
---|
protected List list
protected String indexProperty
Constructor Detail |
---|
public IndexPropertyList(String indexProperty)
public IndexPropertyList(String indexProperty, List objects, boolean sortNeeded)
Method Detail |
---|
public boolean isFault()
ValueHolder
isFault
in interface ValueHolder
public Object setValueDirectly(Object value) throws CayenneRuntimeException
ValueHolder
setValueDirectly
in interface ValueHolder
CayenneRuntimeException
public Object setValue(Object value) throws CayenneRuntimeException
ValueHolder
setValue
in interface ValueHolder
value
- a new value of the ValueHolder.
CayenneRuntimeException
public Object getValue() throws CayenneRuntimeException
ValueHolder
getValue
in interface ValueHolder
CayenneRuntimeException
public Object getValueDirectly() throws CayenneRuntimeException
ValueHolder
getValueDirectly
in interface ValueHolder
CayenneRuntimeException
public void invalidate()
ValueHolder
invalidate
in interface ValueHolder
public void touch()
public Object get(int index)
get
in interface List
get
in class AbstractList
public int size()
size
in interface Collection
size
in interface List
size
in class AbstractCollection
public Object set(int index, Object element)
set
in interface List
set
in class AbstractList
public void add(int index, Object element)
add
in interface List
add
in class AbstractList
public Object remove(int index)
remove
in interface List
remove
in class AbstractList
protected int calculateIndexValue(int listIndex)
protected int getIndexValue(Object object)
protected void setIndexValue(Object object, int index)
protected void shift(int startIndex, int afterIndexValue)
protected void sort()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |