org.apache.jdo.impl.sco
Class Vector

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by org.apache.jdo.impl.sco.Vector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess, SCO, SCOCollection

public class Vector
extends java.util.Vector
implements SCOCollection

A mutable 2nd class object that represents Vector.

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

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Vector(java.lang.Class elementType, boolean allowNulls)
          Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.
Vector(java.lang.Class elementType, boolean allowNulls, int initialCapacity)
          Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero.
 
Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this Vector.
 boolean add(java.lang.Object o)
          Appends the specified element to the end of this Vector.
 boolean addAll(java.util.Collection c)
          Appends all of the elements in the specified Collection to the end of this Vector, 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 Vector at the specified position.
 void addAllInternal(java.util.Collection c)
          Adds objects of the given Collection to this Collection without recording the event.
 void addElement(java.lang.Object obj)
          Adds the specified component to the end of this vector, increasing its size by one.
 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 Vector.
 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
 void insertElementAt(java.lang.Object obj, int index)
          Inserts the specified object as a component in this vector at the specified index.
 java.lang.Object remove(int index)
          Removes the element at the specified position in this Vector.
 boolean remove(java.lang.Object o)
          Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged.
 boolean removeAll(java.util.Collection c)
          Removes from this Vector all of its elements that are contained in the specified Collection.
 void removeAllElements()
          Removes all components from this vector and sets its size to zero.
 boolean removeElement(java.lang.Object obj)
          Removes the first (lowest-indexed) occurrence of the argument from this vector.
 void removeElementAt(int index)
          Deletes the component at the specified index.
 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 Vector 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 Vector with the specified element.
 void setElementAt(java.lang.Object obj, int index)
          Sets the component at the specified index of this vector to be the specified object.
 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.Vector
capacity, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, removeRange, setSize, size, subList, toArray, toArray, toString, trimToSize
 
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
 

Constructor Detail

Vector

public Vector(java.lang.Class elementType,
              boolean allowNulls)
Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.

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

Vector

public Vector(java.lang.Class elementType,
              boolean allowNulls,
              int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero.

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

setElementAt

public void setElementAt(java.lang.Object obj,
                         int index)
Sets the component at the specified index of this vector to be the specified object. The previous component at that position is discarded.

Overrides:
setElementAt in class java.util.Vector
Parameters:
obj - what the component is to be set to.
index - the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
See Also:
Vector

removeElementAt

public void removeElementAt(int index)
Deletes the component at the specified index.

Overrides:
removeElementAt in class java.util.Vector
Parameters:
index - the index of the object to remove.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
See Also:
Vector

insertElementAt

public void insertElementAt(java.lang.Object obj,
                            int index)
Inserts the specified object as a component in this vector at the specified index.

Overrides:
insertElementAt in class java.util.Vector
Parameters:
obj - the component to insert.
index - where to insert the new component.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
See Also:
Vector

addElement

public void addElement(java.lang.Object obj)
Adds the specified component to the end of this vector, increasing its size by one.

Overrides:
addElement in class java.util.Vector
Parameters:
obj - the component to be added.
See Also:
Vector

removeElement

public boolean removeElement(java.lang.Object obj)
Removes the first (lowest-indexed) occurrence of the argument from this vector.

Overrides:
removeElement in class java.util.Vector
Parameters:
obj - the component to be removed.
Returns:
true if the argument was a component of this vector; false otherwise.
See Also:
Vector

removeAllElements

public void removeAllElements()
Removes all components from this vector and sets its size to zero.

Overrides:
removeAllElements in class java.util.Vector
See Also:
Vector

set

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

Specified by:
set in interface java.util.List
Overrides:
set in class java.util.Vector
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.ArrayIndexOutOfBoundsException - index out of range (index < 0 || index >= size()).
java.lang.IllegalArgumentException - fromIndex > toIndex.
See Also:
Vector

add

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

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

remove

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

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

add

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

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

remove

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

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

clear

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

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.Vector
See Also:
Vector

addAll

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

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.Vector
Parameters:
c - elements to be inserted into this Vector.
See Also:
Vector

removeAll

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

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

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements in in the specified Collection into this Vector 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 Vector in the order that they are returned by the specified Collection's iterator.

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

retainAll

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

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

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
Overrides:
clone in class java.util.Vector

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:
SCO.getOwner()

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-2012 Apache Software Foundation. All Rights Reserved.