If there is an odd number of items in the dataset, the one below
* the 50% mark will be returned. The true mathmatical mean, therefore
* would be:
*
* (beanVector.elementAt(x).getProperty() + beanVector.elementAt(x+1).getProperty() )/2
*
*
* This method is identical in functionality to the add(Object) method
* (which is part of the List interface).
*
* @param obj the component to be added.
* @see #add(Object)
* @see List
*/
public void addElement(T obj) {
super.addElement(obj);
if((this.indexPropertyName != null)&&(this.changes != null)) {
changes.fireIndexedPropertyChange(this.indexPropertyName,this.size() - 1,null,obj);
}
}
/**
* Registers propertyChangeListeners to be fired when something changes in the Vector.
* Note, the whole vector is an "indexedProperty" name specified and parent delineated in
* the constructor.
* @param listener PropertyChangeListener to register
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {
changes.addPropertyChangeListener(listener);
}
/**
* Registers propertyChangeListeners to be fired when something changes in the Vector.
* Note, the whole vector is an "indexedProperty" name specified and parent delineated in
* the constructor.
* @param property propteryName must match what the property name of this vector is or the listener will be ignored.
* @param listener the listener to register
*/
public void addPropertyChangeListener(String property,PropertyChangeListener listener) {
if((property != null)&&property.equals(this.indexPropertyName)) {
changes.addPropertyChangeListener(property,listener);
}
}
/**
* This method reverses the order of the vector.
*/
public synchronized void invert() {
BeanVector
*
* This method is identical in functionality to the clear method
* (which is part of the List interface).
*
* @see #clear
* @see List
*/
public void removeAllElements() {
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
super.removeAllElements();
if(old != null) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
}
/**
* Removes the first (lowest-indexed) occurrence of the argument
* from this vector. If the object is found in this vector, each
* component in the vector with an index greater or equal to the
* object's index is shifted downward to have an index one smaller
* than the value it had previously.
*
* This method is identical in functionality to the remove(Object)
* method (which is part of the List interface).
*
* @param obj the component to be removed.
* @return
*
* The index must be a value greater than or equal to
*
* This method is identical in functionality to the remove method
* (which is part of the List interface). Note that the remove method
* returns the old value that was stored at the specified position.
*
* @see #size()
* @see #remove(int)
* @see List
* @param index the index of the object to remove.
*/
public void removeElementAt(int index) {
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
super.removeElementAt(index);
if(old != null) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
}
/**
* Removes propertyChangeListeners to be fired when something changes in the Vector.
* Note, the whole vector is an "indexedProperty" name specified and parent delineated in
* the constructor.
* @param listener listener to remove
*/
public void removePropertyChangeListener(PropertyChangeListener listener) {
changes.removePropertyChangeListener(listener);
}
/**
* Removes propertyChangeListeners to be fired when something changes in the Vector.
* Note, the whole vector is an "indexedProperty" name specified and parent delineated in
* the constructor.
* @param property must match the current property name for the vector or will be ignored
* @param listener listener to remove
*/
public void removePropertyChangeListener(String property,PropertyChangeListener listener) {
if((property != null)&&property.equals(this.indexPropertyName)) {
changes.removePropertyChangeListener(property,listener);
}
}
/**
* Resets the contents of the vector to the values provided.
* @param contents Array of object to replace the current contents with
*/
public synchronized void resetContents(T[] contents) {
if((this.indexPropertyName != null)&&(this.changes != null)) {
changes.firePropertyChange(this.indexPropertyName,this.toTypedArray(),contents);
}
this.removeAllElements();
for(T t : contents)
this.add(t);
}
/**
* Retains only the elements in this Vector that are contained in the
* specified Collection. In other words, removes from this Vector all
* of its elements that are not contained in the specified Collection.
*
* @return true if this Vector changed as a result of the call.
* @since 1.2
* @param c a collection of elements to be retained in this Vector
* (all other elements are removed)
*/
public boolean retainAll(Collection > c) {
boolean retValue;
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
retValue = super.retainAll(c);
if(retValue&&(old != null)) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
return retValue;
}
/**
* Replaces the element at the specified position in this Vector with the
* specified element.
*
* @return the element previously at the specified position.
* @since 1.2
* @param index index of element to replace.
* @param element element to be stored at the specified position.
*/
public T set(int index,T element) {
T retValue;
retValue = super.set(index,element);
if((this.indexPropertyName != null)&&(this.changes != null)) {
changes.fireIndexedPropertyChange(this.indexPropertyName,index,retValue,element);
}
return retValue;
}
/**
* performs a selection sort on all the beans in the Vector by PropertyName
*
* You can use a mixture of bean classes as long as all the beans support
* the same property (getName() for instance), and all have the same return
* type. For optimal performance, it is recommended that if you have a
* mixed class set the you have them grouped with like classes together as this
* will minimize reflection inspections. You can use a mixture of bean classes as long as all the beans
* support the same property (getName() for instance), and all have the
* same return type, or can be compareTo()ed each other. For optimal performance, it is recommended that if you have a
* mixed class set the you have them grouped with like classes together
* as this will minimize reflection inspections.(o==null ? get(i)==null : o.equals(get(i)))
(if such
* an element exists).
*
* @param o element to be removed from this Vector, if present.
* @return true if the Vector contained the specified element.
* @since 1.2
*/
public boolean remove(Object o) {
boolean retValue;
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
retValue = super.remove(o);
if(retValue&&(old != null)) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
return retValue;
}
/**
* 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.
*
* @return element that was removed
* @since 1.2
* @param index the index of the element to removed.
*/
public T remove(int index) {
T retValue;
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
retValue = super.remove(index);
if((retValue != null)&&(old != null)) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
return retValue;
}
/**
* Removes from this Vector all of its elements that are contained in the
* specified Collection.
*
* @return true if this Vector changed as a result of the call.
* @since 1.2
* @param c a collection of elements to be removed from the Vector
*/
public boolean removeAll(Collection > c) {
boolean retValue;
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
retValue = super.removeAll(c);
if(retValue&&(old != null)) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
return retValue;
}
/**
* Removes all components from this vector and sets its size to zero.true
if the argument was a component of this
* vector; false
otherwise.
* @see List#remove(Object)
* @see List
*/
public boolean removeElement(Object obj) {
boolean retValue;
T[] old = null;
if((this.indexPropertyName != null)&&(this.changes != null)) {
old = this.toTypedArray();
}
retValue = super.removeElement(obj);
if(retValue&&(old != null)) {
changes.firePropertyChange(this.indexPropertyName,old,this.toTypedArray());
}
return retValue;
}
/**
* Deletes the component at the specified index. Each component in
* this vector with an index greater or equal to the specified
* index
is shifted downward to have an index one
* smaller than the value it had previously. The size of this vector
* is decreased by 1.0
* and less than the current size of the vector.