Class Vector

    • 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 object
        fieldName - the owning field name
        elementType - the element types allowed
        allowNulls - 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 object
        fieldName - the owning field name
        elementType - the element types allowed
        allowNulls - true if nulls are allowed
        initialCapacity - 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 specified index of this vector to be the specified object. The previous component at that position is discarded.

        Overrides:
        setElementAt in class Vector
        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 class Vector
        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 specified index.
        Overrides:
        insertElementAt in class Vector
        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 class Vector
        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 class 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 Vector
        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 interface List
        Overrides:
        set in class 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:
        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.
        Specified by:
        add in interface Collection
        Specified by:
        add in interface List
        Overrides:
        add in class 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​(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 Collection
        Specified by:
        remove in interface List
        Overrides:
        remove in class 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,
                        Object element)
        Inserts the specified element at the specified position in this Vector.
        Specified by:
        add in interface List
        Overrides:
        add in class Vector
        Parameters:
        index - index at which the specified element is to be inserted.
        element - element to be inserted.
        Throws:
        ArrayIndexOutOfBoundsException - index is out of range (index < 0 || index > size()).
        See Also:
        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.
        Specified by:
        remove in interface List
        Overrides:
        remove in class Vector
        Parameters:
        index - the index of the element to removed.
        Throws:
        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 Collection
        Specified by:
        clear in interface List
        Overrides:
        clear in class Vector
        See Also:
        Vector
      • 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.
        Specified by:
        addAll in interface Collection
        Specified by:
        addAll in interface List
        Overrides:
        addAll in class Vector
        Parameters:
        c - elements to be inserted into this Vector.
        See Also:
        Vector
      • removeAll

        public boolean removeAll​(Collection c)
        Removes from this Vector all of its elements that are contained in the specified Collection.
        Specified by:
        removeAll in interface Collection
        Specified by:
        removeAll in interface List
        Overrides:
        removeAll in class Vector
        Returns:
        true if this Vector changed as a result of the call.
        See Also:
        Vector
      • 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 interface List
        Overrides:
        addAll in class Vector
        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.
        Specified by:
        retainAll in interface Collection
        Specified by:
        retainAll in interface List
        Overrides:
        retainAll in class Vector
        Returns:
        true if this Vector changed as a result of the call.
        See Also:
        Vector
      • 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.

        Overrides:
        clone in class Vector
      • cloneInternal

        public Object cloneInternal()
        Creates and returns a copy of this object without resetting the owner and field value.
        Specified by:
        cloneInternal in interface SCO
      • reset

        public void reset()
        Cleans removed and added lists
        Specified by:
        reset in interface SCOCollection
      • addInternal

        public void addInternal​(Object o)
        Adds an object to the list without recording changes
        Specified by:
        addInternal in interface SCOCollection
      • getAdded

        public Collection getAdded()
        Returns added collection
        Specified by:
        getAdded in interface SCOCollection
        Returns:
        added collection of added elements
      • getRemoved

        public Collection getRemoved()
        Returns removed collection
        Specified by:
        getRemoved in interface SCOCollection
        Returns:
        removed collection of removed elements
      • clearInternal

        public void clearInternal()
        Clears Collection without notifing the owner
        Specified by:
        clearInternal in interface SCOCollection
      • unsetOwner

        public void unsetOwner()
        Nullifies references to the owner Object and Field
        Specified by:
        unsetOwner in interface SCO
      • getOwner

        public Object getOwner()
        Returns the owner object of the SCO instance
        Specified by:
        getOwner in interface SCO
        Returns:
        owner object
      • getFieldName

        public String getFieldName()
        Returns the field name
        Specified by:
        getFieldName in interface SCO
        Returns:
        field name as java.lang.String
      • makeDirty

        public StateManager makeDirty()
        Marks object dirty
        Specified by:
        makeDirty in interface SCO
        Returns:
        StateManager associated with the owner
      • applyUpdates

        public void applyUpdates​(StateManager sm,
                                 boolean modified)
        Apply changes (can be a no-op)
        Specified by:
        applyUpdates in interface SCO