Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.util
Class IndexPropertyList

    java.lang.Object
      java.util.AbstractCollection<E>
          java.util.AbstractList
              org.apache.cayenne.util.IndexPropertyList

All Implemented Interfaces:
  java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.List, ValueHolder

    public class IndexPropertyList

extends java.util.AbstractList
implements ValueHolder

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.

Since:
  1.2
Author:
  Andrus Adamchik
See Also:
  Serialized Form

Field Summary
`protected java.lang.String` | `indexProperty`
`protected java.util.List` | `list` A list used for the actual objects storage.

Fields inherited from class java.util.AbstractList
`modCount`

Constructor Summary
`IndexPropertyList(java.lang.String indexProperty)` Creates an empty NumericPropertyOrderedList.
`IndexPropertyList(java.lang.String indexProperty, java.util.List objects, boolean sortNeeded)` Creates a NumericPropertyOrderedList that decorates another list.

Method Summary
`void` | `add(int index, java.lang.Object element)`
`protected int` | `calculateIndexValue(int listIndex)` Calculates an index value at the specified list index.
`java.lang.Object` | `get(int index)`
`protected int` | `getIndexValue(java.lang.Object object)`
`java.lang.Object` | `getValue()` Returns an object stored by this ValueHolder.
`java.lang.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.
`java.lang.Object` | `remove(int index)`
`java.lang.Object` | `set(int index, java.lang.Object element)`
`protected void` | `setIndexValue(java.lang.Object object, int index)`
`java.lang.Object` | `setValue(java.lang.Object value)` Sets an object stored by this ValueHolder.
`java.lang.Object` | `setValueDirectly(java.lang.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

### list

    protected java.util.List list

  A list used for the actual objects storage.

### indexProperty

    protected java.lang.String indexProperty

Constructor Detail

### IndexPropertyList

    public IndexPropertyList(java.lang.String indexProperty)

  Creates an empty NumericPropertyOrderedList.

### IndexPropertyList

    public IndexPropertyList(java.lang.String indexProperty,
                             java.util.List objects,
                             boolean sortNeeded)

  Creates a NumericPropertyOrderedList that decorates another list. If the list is not known to be properly sorted, caller must set sortNeeded to true. This will result in sorting the original list on first access attempt.

Method Detail

### isFault

    public boolean isFault()

  Description copied from interface: `ValueHolder`
  Returns true if the internal value is not yet resolved.

  Specified by:
    `isFault` in interface `ValueHolder`

### setValueDirectly

    public java.lang.Object setValueDirectly(java.lang.Object value)
                                      throws CayenneRuntimeException

  Description copied from interface: `ValueHolder`
  Sets ValueHolder vaue without triggering fault resolution.

  Specified by:
    `setValueDirectly` in interface `ValueHolder`
  Throws:
    `CayenneRuntimeException`

### setValue

    public java.lang.Object setValue(java.lang.Object value)
                              throws CayenneRuntimeException

  Description copied from interface: `ValueHolder`
  Sets an object stored by this ValueHolder.

  Specified by:
    `setValue` in interface `ValueHolder`
  Parameters:
    `value` - a new value of the ValueHolder.
  Returns:
    a previous value saved in the ValueHolder.
  Throws:
    `CayenneRuntimeException`

### getValue

    public java.lang.Object getValue()
                              throws CayenneRuntimeException

  Description copied from interface: `ValueHolder`
  Returns an object stored by this ValueHolder.

  Specified by:
    `getValue` in interface `ValueHolder`
  Throws:
    `CayenneRuntimeException`

### getValueDirectly

    public java.lang.Object getValueDirectly()
                                      throws CayenneRuntimeException

  Description copied from interface: `ValueHolder`
  Retrieves ValueHolder value without triggering fault resolution.

  Specified by:
    `getValueDirectly` in interface `ValueHolder`
  Throws:
    `CayenneRuntimeException`

### invalidate

    public void invalidate()

  Description copied from interface: `ValueHolder`
  Turns a ValueHolder into a fault.

  Specified by:
    `invalidate` in interface `ValueHolder`

### touch

    public void touch()

  Changes list state to "dirty" forcing reordering on next access.

### get

    public java.lang.Object get(int index)

  Specified by:
    `get` in interface `java.util.List`
  Specified by:
    `get` in class `java.util.AbstractList`

### size

    public int size()

  Specified by:
    `size` in interface `java.util.Collection`
  Specified by:
    `size` in interface `java.util.List`
  Specified by:
    `size` in class `java.util.AbstractCollection`

### set

    public java.lang.Object set(int index,
                                java.lang.Object element)

  Specified by:
    `set` in interface `java.util.List`
  Overrides:
    `set` in class `java.util.AbstractList`

### add

    public void add(int index,
                    java.lang.Object element)

  Specified by:
    `add` in interface `java.util.List`
  Overrides:
    `add` in class `java.util.AbstractList`

### remove

    public java.lang.Object remove(int index)

  Specified by:
    `remove` in interface `java.util.List`
  Overrides:
    `remove` in class `java.util.AbstractList`

### calculateIndexValue

    protected int calculateIndexValue(int listIndex)

  Calculates an index value at the specified list index. Note that using this value may require a shift of the objects following this index.

### getIndexValue

    protected int getIndexValue(java.lang.Object object)

### setIndexValue

    protected void setIndexValue(java.lang.Object object,
                                 int index)

### shift

    protected void shift(int startIndex,
                         int afterIndexValue)

### sort

    protected void sort()

  Sorts internal list.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.