org.apache.activemq.kaha.impl.container
Class ListContainerImpl

java.lang.Object
  extended by org.apache.activemq.kaha.impl.container.BaseContainerImpl
      extended by org.apache.activemq.kaha.impl.container.ListContainerImpl
All Implemented Interfaces:
Iterable, Collection, List, ListContainer

public class ListContainerImpl
extends BaseContainerImpl
implements ListContainer

Implementation of a ListContainer


Field Summary
protected  Marshaller marshaller
           
 
Fields inherited from class org.apache.activemq.kaha.impl.container.BaseContainerImpl
closed, containerId, dataManager, indexList, indexManager, initialized, loaded, persistentIndex, root
 
Constructor Summary
ListContainerImpl(ContainerId id, IndexItem root, IndexManager indexManager, DataManager dataManager, boolean persistentIndex)
           
 
Method Summary
 void add(int index, Object element)
           
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void addFirst(Object o)
          Inserts the given element at the beginning of this list.
 void addLast(Object o)
          Appends the given element to the end of this list.
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 boolean doRemove(int index)
          remove an objecr from the list without retrieving the old value from the store
 boolean equals(Object obj)
           
 Object get(int index)
           
 Object get(StoreEntry entry)
          Retrieve an Object from the Store by its location
 StoreEntry getFirst()
          Get the StoreEntry for the first item of the list
 StoreEntry getLast()
          Get the StoreEntry for the last item of the list
 StoreEntry getNext(StoreEntry entry)
          Get the next StoreEntry from the list
 StoreEntry getPrevious(StoreEntry entry)
          Get the previous StoreEntry from the list
protected  Object getValue(StoreEntry item)
           
 int hashCode()
           
 int indexOf(Object o)
           
protected  IndexItem insert(int insertPos, Object value)
           
protected  IndexItem internalAdd(int index, Object element)
           
protected  StoreEntry internalAddFirst(Object o)
           
protected  StoreEntry internalAddLast(Object o)
           
protected  StoreEntry internalGet(int index)
           
protected  IndexItem internalSet(int index, Object element)
           
 boolean isEmpty()
           
protected  void itemAdded(IndexItem item, int pos, Object value)
           
protected  void itemRemoved(int pos)
           
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 void load()
          The container is created or retrieved in an unloaded state.
 StoreEntry placeFirst(Object object)
          insert an Object in first position int the list but get a StoreEntry of its position
 StoreEntry placeLast(Object object)
          add an Object to the list but get a StoreEntry of its position
 StoreEntry refresh(StoreEntry entry)
          It's possible that a StoreEntry could be come stale this will return an upto date entry for the StoreEntry position
protected  void remove(IndexItem item)
           
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean remove(StoreEntry entry)
          remove the Object at the StoreEntry
 boolean removeAll(Collection c)
           
 Object removeFirst()
          Removes and returns the first element from this list.
 Object removeLast()
          Removes and returns the last element from this list.
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 void setMarshaller(Marshaller marshaller)
          For homogenous containers can set a custom marshaller for loading values The default uses Object serialization
 int size()
           
 List<Object> subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 String toString()
           
 void unload()
          unload indexes from the container
 void update(StoreEntry entry, Object object)
          Advanced feature = must ensure the object written doesn't overwrite other objects in the container
protected  IndexItem writeFirst(Object value)
           
protected  IndexItem writeLast(Object value)
           
 
Methods inherited from class org.apache.activemq.kaha.impl.container.BaseContainerImpl
checkClosed, close, delete, doClear, expressDataInterest, getContainerId, getDataManager, getId, getIndexManager, getInternalList, getList, init, isLoaded, isRoot, setList, storeIndex, updateIndexes
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.activemq.kaha.ListContainer
getId, isLoaded
 

Field Detail

marshaller

protected Marshaller marshaller
Constructor Detail

ListContainerImpl

public ListContainerImpl(ContainerId id,
                         IndexItem root,
                         IndexManager indexManager,
                         DataManager dataManager,
                         boolean persistentIndex)
                  throws IOException
Throws:
IOException
Method Detail

load

public void load()
Description copied from interface: ListContainer
The container is created or retrieved in an unloaded state. load populates the container will all the indexes used etc and should be called before any operations on the container

Specified by:
load in interface ListContainer
Specified by:
load in class BaseContainerImpl

unload

public void unload()
Description copied from interface: ListContainer
unload indexes from the container

Specified by:
unload in interface ListContainer
Specified by:
unload in class BaseContainerImpl

setMarshaller

public void setMarshaller(Marshaller marshaller)
Description copied from interface: ListContainer
For homogenous containers can set a custom marshaller for loading values The default uses Object serialization

Specified by:
setMarshaller in interface ListContainer

equals

public boolean equals(Object obj)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List
Specified by:
size in interface ListContainer
Specified by:
size in class BaseContainerImpl
Returns:
the number of values in the container

addFirst

public void addFirst(Object o)
Description copied from interface: ListContainer
Inserts the given element at the beginning of this list.

Specified by:
addFirst in interface ListContainer
Parameters:
o - the element to be inserted at the beginning of this list.

addLast

public void addLast(Object o)
Description copied from interface: ListContainer
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

Specified by:
addLast in interface ListContainer
Parameters:
o - the element to be inserted at the end of this list.

removeFirst

public Object removeFirst()
Description copied from interface: ListContainer
Removes and returns the first element from this list.

Specified by:
removeFirst in interface ListContainer
Returns:
the first element from this list.

removeLast

public Object removeLast()
Description copied from interface: ListContainer
Removes and returns the last element from this list.

Specified by:
removeLast in interface ListContainer
Returns:
the last element from this list.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection
Specified by:
contains in interface List

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

add

public boolean add(Object o)
Specified by:
add in interface Collection
Specified by:
add in interface List

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface List

remove

protected void remove(IndexItem item)
Specified by:
remove in class BaseContainerImpl

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List
Overrides:
clear in class BaseContainerImpl

get

public Object get(int index)
Specified by:
get in interface List

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List

internalSet

protected IndexItem internalSet(int index,
                                Object element)

add

public void add(int index,
                Object element)
Specified by:
add in interface List

internalAddLast

protected StoreEntry internalAddLast(Object o)

internalAddFirst

protected StoreEntry internalAddFirst(Object o)

internalAdd

protected IndexItem internalAdd(int index,
                                Object element)

internalGet

protected StoreEntry internalGet(int index)

doRemove

public boolean doRemove(int index)
Description copied from interface: ListContainer
remove an objecr from the list without retrieving the old value from the store

Specified by:
doRemove in interface ListContainer
Returns:
true if successful

remove

public Object remove(int index)
Specified by:
remove in interface List

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List

subList

public List<Object> subList(int fromIndex,
                            int toIndex)
Specified by:
subList in interface List

placeLast

public StoreEntry placeLast(Object object)
add an Object to the list but get a StoreEntry of its position

Specified by:
placeLast in interface ListContainer
Parameters:
object -
Returns:
the entry in the Store

placeFirst

public StoreEntry placeFirst(Object object)
insert an Object in first position int the list but get a StoreEntry of its position

Specified by:
placeFirst in interface ListContainer
Parameters:
object -
Returns:
the location in the Store

update

public void update(StoreEntry entry,
                   Object object)
Description copied from interface: ListContainer
Advanced feature = must ensure the object written doesn't overwrite other objects in the container

Specified by:
update in interface ListContainer
Parameters:
entry -
object -
See Also:
ListContainer.update(org.apache.activemq.kaha.StoreEntry, java.lang.Object)

get

public Object get(StoreEntry entry)
Retrieve an Object from the Store by its location

Specified by:
get in interface ListContainer
Parameters:
entry -
Returns:
the Object at that entry

remove

public boolean remove(StoreEntry entry)
remove the Object at the StoreEntry

Specified by:
remove in interface ListContainer
Parameters:
entry -
Returns:
true if successful

getFirst

public StoreEntry getFirst()
Get the StoreEntry for the first item of the list

Specified by:
getFirst in interface ListContainer
Returns:
the first StoreEntry or null if the list is empty

getLast

public StoreEntry getLast()
Get the StoreEntry for the last item of the list

Specified by:
getLast in interface ListContainer
Returns:
the last StoreEntry or null if the list is empty

getNext

public StoreEntry getNext(StoreEntry entry)
Get the next StoreEntry from the list

Specified by:
getNext in interface ListContainer
Parameters:
entry -
Returns:
the next StoreEntry or null

getPrevious

public StoreEntry getPrevious(StoreEntry entry)
Get the previous StoreEntry from the list

Specified by:
getPrevious in interface ListContainer
Parameters:
entry -
Returns:
the previous store entry or null

refresh

public StoreEntry refresh(StoreEntry entry)
It's possible that a StoreEntry could be come stale this will return an upto date entry for the StoreEntry position

Specified by:
refresh in interface ListContainer
Parameters:
entry - old entry
Returns:
a refreshed StoreEntry

writeLast

protected IndexItem writeLast(Object value)

writeFirst

protected IndexItem writeFirst(Object value)

insert

protected IndexItem insert(int insertPos,
                           Object value)

getValue

protected Object getValue(StoreEntry item)
Specified by:
getValue in class BaseContainerImpl

toString

public String toString()
Overrides:
toString in class Object
Returns:
a string representation of this collection.

itemAdded

protected void itemAdded(IndexItem item,
                         int pos,
                         Object value)

itemRemoved

protected void itemRemoved(int pos)


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.