org.ozoneDB.collections
Class _BaseList_SubListImpl

java.lang.Object
  extended byorg.ozoneDB.OzoneObject
      extended byorg.ozoneDB.collections.AbstractOzoneCollection
          extended byorg.ozoneDB.collections.BaseListImpl
              extended byorg.ozoneDB.collections._BaseList_SubListImpl
All Implemented Interfaces:
_BaseList_SubList, BaseList, java.util.Collection, java.util.List, OzoneCollection, org.ozoneDB.OzoneCompatible, org.ozoneDB.OzoneCompatibleOrProxy, OzoneList, org.ozoneDB.OzoneRemote, java.io.Serializable
Direct Known Subclasses:
_BaseList_RandomAccessSubListImpl

public class _BaseList_SubListImpl
extends BaseListImpl
implements _BaseList_SubList

This class follows the implementation requirements set forth in AbstractList.subList(int, int). It matches Sun's implementation by using a non-public top-level class in the same package.

Author:
Original author unknown, Eric Blake , ported to Ozone by Leo Mekenkamp
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.ozoneDB.collections.BaseListImpl
modCount
 
Constructor Summary
_BaseList_SubListImpl(BaseList backingList, int fromIndex, int toIndex)
          Construct the sublist.
 
Method Summary
 void _org_ozoneDB_checkBoundsExclusive(int index)
          This method checks that a value is between 0 (inclusive) and size (exclusive).
 void _org_ozoneDB_checkBoundsInclusive(int index)
          This method checks that a value is between 0 and size (inclusive).
 void _org_ozoneDB_checkMod()
          This method checks the two modCount fields to ensure that there has not been a concurrent modification, returning if all is okay.
 java.util.List _org_ozoneDB_emptyClientCollection()
          Needed for sub lists so that they can return the same type of list as the sub lists backing list would when getClientXxx() is called.
 int _org_ozoneDB_getModCount()
           
 int _org_ozoneDB_getOffset()
          Returns the offset of this sublist relative to the backing list.
 void _org_ozoneDB_incSize(int amount)
          Called by an iterator when it removes an item from this sublist or inserts an item.
 java.util.Iterator _org_ozoneDB_internalIterator()
           
 void _org_ozoneDB_removeRange(int fromIndex, int toIndex)
          Specified by AbstractList.subList to delegate to the backing list.
 void _org_ozoneDB_syncModCountWithBackingList()
           
 void add(int index, java.lang.Object o)
          Specified by AbstractList.subList to delegate to the backing list.
 boolean addAll(java.util.Collection c)
          Specified by AbstractList.subList to return addAll(size, c).
 boolean addAll(int index, java.util.Collection c)
          Specified by AbstractList.subList to delegate to the backing list.
 java.lang.Object get(int index)
          Specified by AbstractList.subList to delegate to the backing list.
 java.util.List getClientList()
          Returns a List that contains the same entries as this persistent one; it is (by nature of the client-server enviromnent) always a 'deep' copy of this OzoneList.
 java.util.Iterator iterator()
          Specified by AbstractList.subList to return listIterator().
 java.util.ListIterator listIterator(int index)
          Specified by AbstractList.subList to return a wrapper around the backing list's iterator.
 java.lang.Object remove(int index)
          Specified by AbstractList.subList to delegate to the backing list.
 java.lang.Object set(int index, java.lang.Object o)
          Specified by AbstractList.subList to delegate to the backing list.
 int size()
          Specified by AbstractList.subList to return the private field size.
 
Methods inherited from class org.ozoneDB.collections.BaseListImpl
add, clear, equals, hashCode, indexOf, internalIterator, lastIndexOf, listIterator, subList
 
Methods inherited from class org.ozoneDB.collections.AbstractOzoneCollection
contains, containsAll, getClientCollection, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class org.ozoneDB.OzoneObject
container, database, deleteRecursive, getHandle, getObjectID, handle, onActivate, onCreate, onDelete, onPassivate, requireWriteLocking, self, setContainer, toXML
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ozoneDB.collections.OzoneCollection
add, clear, getClientCollection, remove, removeAll, retainAll
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, toArray, toArray
 
Methods inherited from interface org.ozoneDB.OzoneCompatibleOrProxy
getObjectID
 
Methods inherited from interface java.util.List
add, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, remove, removeAll, retainAll, subList, toArray, toArray
 

Constructor Detail

_BaseList_SubListImpl

public _BaseList_SubListImpl(BaseList backingList,
                             int fromIndex,
                             int toIndex)
Construct the sublist.

Parameters:
backingList - the list this comes from
fromIndex - the lower bound, inclusive
toIndex - the upper bound, exclusive
Method Detail

_org_ozoneDB_checkMod

public void _org_ozoneDB_checkMod()
This method checks the two modCount fields to ensure that there has not been a concurrent modification, returning if all is okay.

Specified by:
_org_ozoneDB_checkMod in interface _BaseList_SubList
Throws:
java.util.ConcurrentModificationException - if the backing list has been modified externally to this sublist

_org_ozoneDB_checkBoundsInclusive

public void _org_ozoneDB_checkBoundsInclusive(int index)
This method checks that a value is between 0 and size (inclusive). If it is not, an exception is thrown.

Specified by:
_org_ozoneDB_checkBoundsInclusive in interface _BaseList_SubList
Parameters:
index - the value to check
Throws:
java.lang.IndexOutOfBoundsException - if the value is out of range

_org_ozoneDB_checkBoundsExclusive

public void _org_ozoneDB_checkBoundsExclusive(int index)
This method checks that a value is between 0 (inclusive) and size (exclusive). If it is not, an exception is thrown.

Specified by:
_org_ozoneDB_checkBoundsExclusive in interface _BaseList_SubList
Parameters:
index - the value to check
Throws:
java.lang.IndexOutOfBoundsException - if the value is out of range

size

public int size()
Specified by AbstractList.subList to return the private field size.

Specified by:
size in interface java.util.Collection
Specified by:
size in class AbstractOzoneCollection
Returns:
the sublist size

set

public java.lang.Object set(int index,
                            java.lang.Object o)
Specified by AbstractList.subList to delegate to the backing list.

Specified by:
set in interface OzoneList
Overrides:
set in class BaseListImpl
Parameters:
index - the location to modify
o - the new value
Returns:
the old value

get

public java.lang.Object get(int index)
Specified by AbstractList.subList to delegate to the backing list.

Specified by:
get in interface java.util.List
Parameters:
index - the location to get from
Returns:
the object at that location

add

public void add(int index,
                java.lang.Object o)
Specified by AbstractList.subList to delegate to the backing list.

Specified by:
add in interface OzoneList
Overrides:
add in class BaseListImpl
Parameters:
index - the index to insert at
o - the object to add

remove

public java.lang.Object remove(int index)
Specified by AbstractList.subList to delegate to the backing list.

Specified by:
remove in interface OzoneList
Overrides:
remove in class BaseListImpl
Parameters:
index - the index to remove
Returns:
the removed object
See Also:
BaseListImpl.modCount

_org_ozoneDB_removeRange

public void _org_ozoneDB_removeRange(int fromIndex,
                                     int toIndex)
Specified by AbstractList.subList to delegate to the backing list. This does no bounds checking, as it assumes it will only be called by trusted code like clear() which has already checked the bounds.

Specified by:
_org_ozoneDB_removeRange in interface BaseList
Overrides:
_org_ozoneDB_removeRange in class BaseListImpl
Parameters:
fromIndex - the lower bound, inclusive
toIndex - the upper bound, exclusive

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Specified by AbstractList.subList to delegate to the backing list.

Specified by:
addAll in interface OzoneList
Overrides:
addAll in class BaseListImpl
Parameters:
index - the location to insert at
c - the collection to insert
Returns:
true if this list was modified, in other words, c is non-empty

addAll

public boolean addAll(java.util.Collection c)
Specified by AbstractList.subList to return addAll(size, c).

Specified by:
addAll in interface OzoneCollection
Overrides:
addAll in class AbstractOzoneCollection
Parameters:
c - the collection to insert
Returns:
true if this list was modified, in other words, c is non-empty
See Also:
AbstractOzoneCollection.add(Object)

_org_ozoneDB_internalIterator

public java.util.Iterator _org_ozoneDB_internalIterator()
Specified by:
_org_ozoneDB_internalIterator in interface OzoneCollection

iterator

public java.util.Iterator iterator()
Specified by AbstractList.subList to return listIterator().

Specified by:
iterator in interface java.util.Collection
Overrides:
iterator in class BaseListImpl
Returns:
an iterator over the sublist
See Also:
BaseListImpl.modCount

listIterator

public java.util.ListIterator listIterator(int index)
Specified by AbstractList.subList to return a wrapper around the backing list's iterator.

Specified by:
listIterator in interface java.util.List
Overrides:
listIterator in class BaseListImpl
Parameters:
index - the start location of the iterator
Returns:
a list iterator over the sublist
See Also:
BaseListImpl.modCount

_org_ozoneDB_getModCount

public int _org_ozoneDB_getModCount()
Specified by:
_org_ozoneDB_getModCount in interface BaseList

_org_ozoneDB_incSize

public void _org_ozoneDB_incSize(int amount)
Description copied from interface: _BaseList_SubList
Called by an iterator when it removes an item from this sublist or inserts an item.

Specified by:
_org_ozoneDB_incSize in interface _BaseList_SubList

getClientList

public java.util.List getClientList()
Description copied from interface: OzoneList

Returns a List that contains the same entries as this persistent one; it is (by nature of the client-server enviromnent) always a 'deep' copy of this OzoneList. I.e. the contents of this OzoneList instance are always copied to the client by use of serialization.

Note that the difference of calling iterator() compared to getClientList().iterator() is that in the first case you go through the real collection on the server and in the second case you go through a local copy on the client side.

Specified by:
getClientList in interface OzoneList
Overrides:
getClientList in class BaseListImpl

_org_ozoneDB_getOffset

public int _org_ozoneDB_getOffset()
Description copied from interface: _BaseList_SubList
Returns the offset of this sublist relative to the backing list.

Specified by:
_org_ozoneDB_getOffset in interface _BaseList_SubList
Returns:
offset into backinglist

_org_ozoneDB_emptyClientCollection

public java.util.List _org_ozoneDB_emptyClientCollection()
Description copied from interface: BaseList
Needed for sub lists so that they can return the same type of list as the sub lists backing list would when getClientXxx() is called.

Specified by:
_org_ozoneDB_emptyClientCollection in interface BaseList
Returns:
empty list, to be filled and returned to client via getClientXxx()

_org_ozoneDB_syncModCountWithBackingList

public void _org_ozoneDB_syncModCountWithBackingList()
Specified by:
_org_ozoneDB_syncModCountWithBackingList in interface _BaseList_SubList


Copyright © 2004 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.