org.apache.jdo.impl.sco
Class ArrayList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byorg.apache.jdo.impl.sco.ArrayList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, SCO, SCOCollection, java.io.Serializable

public class ArrayList
extends java.util.ArrayList
implements SCOCollection

A mutable 2nd class object that represents ArrayList.

Version:
1.0.1
Author:
Marina Vatkina
See Also:
ArrayList, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArrayList(java.lang.Class elementType, boolean allowNulls)
          Constructs an empty ArrayList object.
ArrayList(java.lang.Class elementType, boolean allowNulls, int initialCapacity)
          Constructs an empty ArrayList object that the specified initial capacity.
 
Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this ArrayList.
 boolean add(java.lang.Object o)
          Appends the specified element to the end of this ArrayList.
 boolean addAll(java.util.Collection c)
          Appends all of the elements in the specified Collection to the end of this ArrayList, in the order that they are returned by the specified Collection's Iterator.
 boolean addAll(int index, java.util.Collection c)
          Inserts all of the elements in in the specified Collection into this ArrayList at the specified position.
 void addAllInternal(java.util.Collection c)
          Adds objects of the given Collection to this Collection without recording the event.
 void addInternal(java.lang.Object o)
          Adds object to the Collection without recording the event.
 boolean allowNulls()
          Returns whether nulls are permitted as elements.
 void clear()
          Removes all of the elements from this ArrayList.
 void clearInternal()
          Clears Collection without recording the event.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 java.util.Iterator eitherIterator()
          Get an iterator regardless of whether the collection is frozen.
 java.util.Iterator frozenIterator()
          Get an iterator over the frozen elements of this collection.
 java.util.Collection getAdded()
          Returns the Collection of added elements
 java.lang.Class getElementType()
          Returns the element type assignment compatible with all added elements of this collection.
 java.lang.String getFieldName()
          Returns the field name
 java.lang.Object getOwner()
          Returns the owner object of the SCO instance
 java.util.Collection getRemoved()
          Returns the Collection of removed elements
 java.lang.Object remove(int index)
          Removes the element at the specified position in this ArrayList.
 boolean remove(java.lang.Object o)
          Removes the first occurrence of the specified element in this ArrayList If the ArrayList does not contain the element, it is unchanged.
 boolean removeAll(java.util.Collection c)
          Removes from this ArrayList all of its elements that are contained in the specified Collection.
 void removeInternal(java.lang.Object o)
          Removes element from the Collection without recording the event.
 void reset()
          Resets removed and added lists after flush
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this ArrayList that are contained in the specified Collection.
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this ArrayList with the specified element.
 void setFrozen(java.lang.Object[] elements)
          Set the contents of this Collection from the frozen elements.
 void setOwner(java.lang.Object owner, int fieldNumber)
          Sets the owner and field number.
 void unsetOwner(java.lang.Object owner, int fieldNumber)
          Nullifies references to the owner Object iff the passed in owner and fieldNumber match.
 
Methods inherited from class java.util.ArrayList
contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, subList
 

Constructor Detail

ArrayList

public ArrayList(java.lang.Class elementType,
                 boolean allowNulls)
Constructs an empty ArrayList object.

Parameters:
elementType - the element types allowed
allowNulls - true if nulls are allowed

ArrayList

public ArrayList(java.lang.Class elementType,
                 boolean allowNulls,
                 int initialCapacity)
Constructs an empty ArrayList object that the specified initial capacity.

Parameters:
elementType - the element types allowed
allowNulls - true if nulls are allowed
initialCapacity - the initial capacity of the list.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative
Method Detail

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replaces the element at the specified position in this ArrayList with the specified element.

Specified by:
set in interface java.util.List
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns:
the element previously at the specified position.
Throws:
java.lang.IndexOutOfBoundsException - index out of range (index < 0 || index >= size()).
java.lang.IllegalArgumentException - fromIndex > toIndex.
See Also:
ArrayList

add

public boolean add(java.lang.Object o)
Appends the specified element to the end of this ArrayList.

Specified by:
add in interface java.util.Collection
Parameters:
o - element to be appended to this ArrayList.
Returns:
true (as per the general contract of Collection.add).
See Also:
ArrayList

remove

public boolean remove(java.lang.Object o)
Removes the first occurrence of the specified element in this ArrayList If the ArrayList does not contain the element, it is unchanged.

Specified by:
remove in interface java.util.Collection
Parameters:
o - element to be removed from this ArrayList, if present.
Returns:
true if the ArrayList contained the specified element.
See Also:
ArrayList

add

public void add(int index,
                java.lang.Object element)
Inserts the specified element at the specified position in this ArrayList.

Specified by:
add in interface java.util.List
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - index is out of range (index < 0 || index > size()).
See Also:
ArrayList

remove

public java.lang.Object remove(int index)
Removes the element at the specified position in this ArrayList. shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the ArrayList.

Specified by:
remove in interface java.util.List
Parameters:
index - the index of the element to removed.
Throws:
java.lang.IndexOutOfBoundsException - index out of range (index < 0 || index >= size()).
See Also:
ArrayList

clear

public void clear()
Removes all of the elements from this ArrayList. The ArrayList will be empty after this call returns (unless it throws an exception).

Specified by:
clear in interface java.util.Collection
See Also:
ArrayList

addAll

public boolean addAll(java.util.Collection c)
Appends all of the elements in the specified Collection to the end of this ArrayList, in the order that they are returned by the specified Collection's Iterator.

Specified by:
addAll in interface java.util.Collection
Parameters:
c - elements to be inserted into this ArrayList.
Throws:
java.lang.IndexOutOfBoundsException - index out of range (index < 0 || index > size()).
See Also:
ArrayList

removeAll

public boolean removeAll(java.util.Collection c)
Removes from this ArrayList all of its elements that are contained in the specified Collection.

Specified by:
removeAll in interface java.util.Collection
Returns:
true if this ArrayList changed as a result of the call.
See Also:
ArrayList

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements in in the specified Collection into this ArrayList at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the ArrayList in the order that they are returned by the specified Collection's iterator.

Specified by:
addAll in interface java.util.List
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this ArrayList.
Throws:
java.lang.IndexOutOfBoundsException - index out of range (index < 0 || index > size()).
See Also:
ArrayList

retainAll

public boolean retainAll(java.util.Collection c)
Retains only the elements in this ArrayList that are contained in the specified Collection.

Specified by:
retainAll in interface java.util.Collection
Returns:
true if this ArrayList changed as a result of the call.
See Also:
ArrayList

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Mutable Second Class Objects are required to provide a public clone method in order to allow for copying PersistenceCapable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.

Specified by:
clone in interface SCO

reset

public void reset()
Description copied from interface: SCOCollection
Resets removed and added lists after flush

Specified by:
reset in interface SCOCollection
See Also:
SCOCollection.reset()

addInternal

public void addInternal(java.lang.Object o)
Description copied from interface: SCOCollection
Adds object to the Collection without recording the event. Used internaly to initially populate the Collection

Specified by:
addInternal in interface SCOCollection
See Also:
SCOCollection.addInternal(Object o)

addAllInternal

public void addAllInternal(java.util.Collection c)
Description copied from interface: SCOCollection
Adds objects of the given Collection to this Collection without recording the event. Used internaly to initially populate the Collection

Specified by:
addAllInternal in interface SCOCollection
See Also:
SCOCollection.addAllInternal(Collection c)

getAdded

public java.util.Collection getAdded()
Description copied from interface: SCOCollection
Returns the Collection of added elements

Specified by:
getAdded in interface SCOCollection
Returns:
Collection of the added elements as java.util.Collection
See Also:
SCOCollection.getAdded()

getRemoved

public java.util.Collection getRemoved()
Description copied from interface: SCOCollection
Returns the Collection of removed elements

Specified by:
getRemoved in interface SCOCollection
Returns:
Collection of the removed elements as java.util.Collection
See Also:
SCOCollection.getRemoved()

clearInternal

public void clearInternal()
Description copied from interface: SCOCollection
Clears Collection without recording the event. Used internaly to clear the Collection

Specified by:
clearInternal in interface SCOCollection
See Also:
SCOCollection.clearInternal()

removeInternal

public void removeInternal(java.lang.Object o)
Description copied from interface: SCOCollection
Removes element from the Collection without recording the event. Used internaly to update the Collection

Specified by:
removeInternal in interface SCOCollection
See Also:
SCOCollection.removeInternal(Object o)

unsetOwner

public void unsetOwner(java.lang.Object owner,
                       int fieldNumber)
Description copied from interface: SCO
Nullifies references to the owner Object iff the passed in owner and fieldNumber match.

Specified by:
unsetOwner in interface SCO
Parameters:
owner - the existing owner object.
fieldNumber - the existing number of the field.
See Also:
SCO.unsetOwner(Object owner, int fieldNumber)

setOwner

public void setOwner(java.lang.Object owner,
                     int fieldNumber)
Description copied from interface: SCO
Sets the owner and field number. Called by StateManager upon assignment to a managed instance.

Specified by:
setOwner in interface SCO
Parameters:
owner - the owner object.
fieldNumber - the number of the field associated with this instance.
See Also:
(Object owner, int fieldNumber)

getOwner

public java.lang.Object getOwner()
Description copied from interface: SCO
Returns the owner object of the SCO instance

Specified by:
getOwner in interface SCO
Returns:
owner object
See Also:
()

getFieldName

public java.lang.String getFieldName()
Description copied from interface: SCO
Returns the field name

Specified by:
getFieldName in interface SCO
Returns:
field name as java.lang.String
See Also:
SCO.getFieldName()

getElementType

public java.lang.Class getElementType()
Description copied from interface: SCOCollection
Returns the element type assignment compatible with all added elements of this collection.

Specified by:
getElementType in interface SCOCollection
Returns:
the element type assignment compatible with all added elements.
See Also:
{

allowNulls

public boolean allowNulls()
Description copied from interface: SCOCollection
Returns whether nulls are permitted as elements.

Specified by:
allowNulls in interface SCOCollection
Returns:
true if nulls are permitted as elements.
See Also:
{

frozenIterator

public java.util.Iterator frozenIterator()
Get an iterator over the frozen elements of this collection. This class does not require freezing, so this method returns a standard iterator.

Specified by:
frozenIterator in interface SCOCollection
Returns:
an iterator over the elements.
Since:
1.0.1

setFrozen

public void setFrozen(java.lang.Object[] elements)
Set the contents of this Collection from the frozen elements. This class does not support explicit frozen operations, and this method always throws an exception.

Specified by:
setFrozen in interface SCOCollection
Parameters:
elements - not used.
Since:
1.0.1

eitherIterator

public java.util.Iterator eitherIterator()
Get an iterator regardless of whether the collection is frozen. This class does not support frozen operations and always returns a regular iterator.

Specified by:
eitherIterator in interface SCOCollection
Returns:
an iterator over the elements.
Since:
1.0.1


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.