Class Vector
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector
-
- com.sun.jdo.spi.persistence.support.sqlstore.sco.Vector
-
- All Implemented Interfaces:
SCO
,SCOCollection
,Serializable
,Cloneable
,Iterable
,Collection
,List
,RandomAccess
public class Vector extends Vector implements SCOCollection
A mutable 2nd class object date.- Version:
- 1.0
- 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
Constructors Constructor Description Vector(Object owner, String fieldName, 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(Object owner, String fieldName, 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Object element)
Inserts the specified element at the specified position in this Vector.boolean
add(Object o)
Appends the specified element to the end of this Vector.boolean
addAll(int index, Collection c)
Inserts all of the elements in in the specified Collection into this Vector at the specified position.boolean
addAll(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.void
addAllInternal(Collection c)
Adds a Collection to the list without recording changesvoid
addElement(Object obj)
Adds the specified component to the end of this vector, increasing its size by one.void
addInternal(Object o)
Adds an object to the list without recording changesvoid
addToBaseCollection(Object o)
Adds an object to the list without recording changes.void
applyDeferredUpdates(Collection c)
void
applyUpdates(StateManager sm, boolean modified)
Apply changes (can be a no-op)void
clear()
Removes all of the elements from this Vector.void
clearInternal()
Clears Collection without notifing the ownerObject
clone()
Creates and returns a copy of this object.Object
cloneInternal()
Creates and returns a copy of this object without resetting the owner and field value.Collection
getAdded()
Returns added collectionString
getFieldName()
Returns the field nameObject
getOwner()
Returns the owner object of the SCO instanceCollection
getRemoved()
Returns removed collectionvoid
insertElementAt(Object obj, int index)
Inserts the specified object as a component in this vector at the specifiedindex
.boolean
isDeferred()
StateManager
makeDirty()
Marks object dirtyvoid
markDeferred()
Object
remove(int index)
Removes the element at the specified position in this Vector.boolean
remove(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(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.void
removeAllInternal(Collection c)
Removes from this collection without recording changesboolean
removeElement(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(Object o)
Removes an element without notifing the ownervoid
reset()
Cleans removed and added listsboolean
retainAll(Collection c)
Retains only the elements in this Vector that are contained in the specified Collection.Object
set(int index, Object element)
Replaces the element at the specified position in this Vector with the specified element.void
setElementAt(Object obj, int index)
Sets the component at the specifiedindex
of this vector to be the specified object.void
setOwner(Object owner, String fieldName, Class elementType)
Set the owner if this instance is not owned.void
unsetOwner()
Nullifies references to the owner Object and Field-
Methods inherited from class java.util.Vector
capacity, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, removeIf, removeRange, replaceAll, setSize, size, sort, spliterator, 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
parallelStream, removeIf, stream, toArray
-
-
-
-
Constructor Detail
-
Vector
public Vector(Object owner, String fieldName, Class elementType, boolean allowNulls)
Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero. Assigns owning object and field name- Parameters:
owner
- the owning objectfieldName
- the owning field nameelementType
- the element types allowedallowNulls
- true if nulls are allowed
-
Vector
public Vector(Object owner, String fieldName, Class elementType, boolean allowNulls, int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero. Assigns owning object and field name- Parameters:
owner
- the owning objectfieldName
- the owning field nameelementType
- the element types allowedallowNulls
- true if nulls are allowedinitialCapacity
- the initial capacity of the vector.- Throws:
IllegalArgumentException
- if the specified initial capacity is negative
-
-
Method Detail
-
setElementAt
public void setElementAt(Object obj, int index)
Sets the component at the specifiedindex
of this vector to be the specified object. The previous component at that position is discarded.- Overrides:
setElementAt
in classVector
- Parameters:
obj
- what the component is to be set to.index
- the specified index.- Throws:
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 classVector
- Parameters:
index
- the index of the object to remove.- Throws:
ArrayIndexOutOfBoundsException
- if the index was invalid.- See Also:
Vector
-
insertElementAt
public void insertElementAt(Object obj, int index)
Inserts the specified object as a component in this vector at the specifiedindex
.- Overrides:
insertElementAt
in classVector
- Parameters:
obj
- the component to insert.index
- where to insert the new component.- Throws:
ArrayIndexOutOfBoundsException
- if the index was invalid.- See Also:
Vector
-
addElement
public void addElement(Object obj)
Adds the specified component to the end of this vector, increasing its size by one.- Overrides:
addElement
in classVector
- Parameters:
obj
- the component to be added.- See Also:
Vector
-
removeElement
public boolean removeElement(Object obj)
Removes the first (lowest-indexed) occurrence of the argument from this vector.- Overrides:
removeElement
in classVector
- 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 classVector
- See Also:
Vector
-
set
public Object set(int index, Object element)
Replaces the element at the specified position in this Vector with the specified element.- Specified by:
set
in interfaceList
- Overrides:
set
in classVector
- 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:
ArrayIndexOutOfBoundsException
- index out of range (index < 0 || index >= size()).IllegalArgumentException
- fromIndex > toIndex.- See Also:
Vector
-
add
public boolean add(Object o)
Appends the specified element to the end of this Vector.
-
remove
public boolean remove(Object o)
Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged.
-
add
public void add(int index, Object element)
Inserts the specified element at the specified position in this Vector.
-
remove
public 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.
-
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).
-
addAll
public boolean addAll(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.
-
removeAll
public boolean removeAll(Collection c)
Removes from this Vector all of its elements that are contained in the specified Collection.
-
addAll
public boolean addAll(int index, 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 interfaceList
- Overrides:
addAll
in classVector
- Parameters:
index
- index at which to insert first element from the specified collection.c
- elements to be inserted into this Vector.- Throws:
ArrayIndexOutOfBoundsException
- index out of range (index < 0 || index > size()).- See Also:
Vector
-
retainAll
public boolean retainAll(Collection c)
Retains only the elements in this Vector that are contained in the specified Collection.
-
clone
public 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.
-
cloneInternal
public Object cloneInternal()
Creates and returns a copy of this object without resetting the owner and field value.- Specified by:
cloneInternal
in interfaceSCO
-
reset
public void reset()
Cleans removed and added lists- Specified by:
reset
in interfaceSCOCollection
-
markDeferred
public void markDeferred()
- Specified by:
markDeferred
in interfaceSCOCollection
-
isDeferred
public boolean isDeferred()
- Specified by:
isDeferred
in interfaceSCOCollection
-
applyDeferredUpdates
public void applyDeferredUpdates(Collection c)
- Specified by:
applyDeferredUpdates
in interfaceSCOCollection
-
addInternal
public void addInternal(Object o)
Adds an object to the list without recording changes- Specified by:
addInternal
in interfaceSCOCollection
-
addAllInternal
public void addAllInternal(Collection c)
Adds a Collection to the list without recording changes- Specified by:
addAllInternal
in interfaceSCOCollection
-
addToBaseCollection
public void addToBaseCollection(Object o)
Description copied from interface:SCOCollection
Adds an object to the list without recording changes.- Specified by:
addToBaseCollection
in interfaceSCOCollection
-
removeAllInternal
public void removeAllInternal(Collection c)
Removes from this collection without recording changes- Specified by:
removeAllInternal
in interfaceSCOCollection
-
getAdded
public Collection getAdded()
Returns added collection- Specified by:
getAdded
in interfaceSCOCollection
- Returns:
- added collection of added elements
-
getRemoved
public Collection getRemoved()
Returns removed collection- Specified by:
getRemoved
in interfaceSCOCollection
- Returns:
- removed collection of removed elements
-
clearInternal
public void clearInternal()
Clears Collection without notifing the owner- Specified by:
clearInternal
in interfaceSCOCollection
-
removeInternal
public void removeInternal(Object o)
Removes an element without notifing the owner- Specified by:
removeInternal
in interfaceSCOCollection
-
unsetOwner
public void unsetOwner()
Nullifies references to the owner Object and Field- Specified by:
unsetOwner
in interfaceSCO
-
getOwner
public Object getOwner()
Returns the owner object of the SCO instance
-
getFieldName
public String getFieldName()
Returns the field name- Specified by:
getFieldName
in interfaceSCO
- Returns:
- field name as java.lang.String
-
makeDirty
public StateManager makeDirty()
Marks object dirty
-
applyUpdates
public void applyUpdates(StateManager sm, boolean modified)
Apply changes (can be a no-op)- Specified by:
applyUpdates
in interfaceSCO
-
setOwner
public void setOwner(Object owner, String fieldName, Class elementType)
Set the owner if this instance is not owned.- Specified by:
setOwner
in interfaceSCOCollection
- Parameters:
owner
- the new owner.fieldName
- the new field name.elementType
- the new element type as Class, or null if type is not to be checked.- See Also:
SCOCollection.setOwner(java.lang.Object, java.lang.String, java.lang.Class)
-
-