org.exolab.core.database.recman
Class PMDVector

java.lang.Object
  extended byorg.exolab.core.foundation.PersistentObject
      extended byorg.exolab.core.database.recman.PMDVector
All Implemented Interfaces:
java.lang.Cloneable, java.io.Externalizable, PersistentCapableIfc, java.io.Serializable, VectorIfc

public class PMDVector
extends PersistentObject
implements VectorIfc, java.io.Externalizable

This concrete class implements the VectorIfc interface. and defines a PagemManagedDatabase specific implementation for this type of database. This Vector is specific to objects of type PersistentCapableIfc

Version:
$Revision: 1.5 $ $Date: 2001/06/12 07:11:35 $
Author:
Jim Alateras
See Also:
Serialized Form

Constructor Summary
PMDVector()
          Construct an instance of this persistent capable class.
 
Method Summary
 void add(int index, PersistentCapableIfc element)
          Add the element at the specified index.
 boolean add(PersistentCapableIfc element)
          Add the specified element to the end of the Vector.
 void addElement(PersistentCapableIfc element)
          Add the specified element to the end of the vector.
 void clear()
          Clear the vector
 boolean contains(PersistentCapableIfc element)
          Test to see whether the specified object exists.
 PersistentCapableIfc elementAt(int index)
          Return the object at the specified index or null if one does not exist
 java.util.Enumeration elements()
          Return an enumeration of all elements in the Vector
 PersistentCapableIfc firstElement()
          Return the first element in the Vector or null if it is empty
 PersistentCapableIfc get(int index)
          Return the object at the specified index or null
 int indexOf(PersistentCapableIfc element)
          Return the index of the specified element or -1 if it does not exist.
 boolean isEmpty()
          Check to see of the vector is empty.
 PersistentCapableIfc lastElement()
          Return the last element in the Vector or null if it is empty
 void readExternal(java.io.ObjectInput stream)
           
 PersistentCapableIfc remove(int index)
          Remove the element at the specified index and return it to the client
 boolean remove(PersistentCapableIfc element)
          Remove the specified element from the Vector
 void removeAllElements()
          Remove all the elements from the Vector.
 boolean removeElement(PersistentCapableIfc element)
          Remove the specified element from the Vector.
 void removeElementAt(int index)
          Remove the element at the specified index
 void set(int index, PersistentCapableIfc element)
          Set the object at the location given, overwriting the existing object if it exists.
 int size()
          Return the size of the vector
 java.lang.Object[] toArray()
          Return the objects in the Vector as an array.
 void writeExternal(java.io.ObjectOutput stream)
           
 
Methods inherited from class org.exolab.core.foundation.PersistentObject
clone, equals, getId, getMinimumObjectSize, getObjectId, getObjectVersion, getVersion, setId, setMinimumObjectSize, setObjectId, setObjectVersion, setVersion
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exolab.core.foundation.PersistentCapableIfc
getMinimumObjectSize, getObjectId, getObjectVersion, setMinimumObjectSize
 

Constructor Detail

PMDVector

public PMDVector()
Construct an instance of this persistent capable class. Once this has been constructed then it could be made persistent

Method Detail

size

public int size()
Return the size of the vector

Specified by:
size in interface VectorIfc
Returns:
int

isEmpty

public boolean isEmpty()
Check to see of the vector is empty.

Specified by:
isEmpty in interface VectorIfc
Returns:
boolean true if it is empty and false otherwise

elements

public java.util.Enumeration elements()
Return an enumeration of all elements in the Vector

Specified by:
elements in interface VectorIfc
Returns:
Enumeration

contains

public boolean contains(PersistentCapableIfc element)
Test to see whether the specified object exists. This is a very expensive operation since it does a linear search until a match is found.

Specified by:
contains in interface VectorIfc
Parameters:
element - element to test for
Returns:
boolean true if it is present and false otherwise

indexOf

public int indexOf(PersistentCapableIfc element)
Return the index of the specified element or -1 if it does not exist.

Specified by:
indexOf in interface VectorIfc
Parameters:
element - element to search for
Returns:
int index of the found element or -1.

elementAt

public PersistentCapableIfc elementAt(int index)
Return the object at the specified index or null if one does not exist

Specified by:
elementAt in interface VectorIfc
Parameters:
index - index to query on
Returns:
PersistentCapableIfc

firstElement

public PersistentCapableIfc firstElement()
Return the first element in the Vector or null if it is empty

Specified by:
firstElement in interface VectorIfc
Returns:
PersistentCapableIfc

lastElement

public PersistentCapableIfc lastElement()
Return the last element in the Vector or null if it is empty

Specified by:
lastElement in interface VectorIfc
Returns:
PersistentCapableIfc

removeElementAt

public void removeElementAt(int index)
Remove the element at the specified index

Specified by:
removeElementAt in interface VectorIfc
Parameters:
index - index of element to remove

addElement

public void addElement(PersistentCapableIfc element)
Add the specified element to the end of the vector. Although this method does specify the element to be of type Object a further constraint is placed on this argument in that it must also be of type PersistentObject If this second prerequisite is not fullfilled then the runtime error UnsupportedObjectException, which indicates that the supplied object could not be added to this vector.

Specified by:
addElement in interface VectorIfc
Parameters:
element - element to add

removeElement

public boolean removeElement(PersistentCapableIfc element)
Remove the specified element from the Vector. This is an expensive operation since it performs a linear search to determine if the object exists prior to removinf it

Specified by:
removeElement in interface VectorIfc
Parameters:
element - element to remove
Returns:
boolean true if it was removed

removeAllElements

public void removeAllElements()
Remove all the elements from the Vector. Functionally, equivalent to the clear method

Specified by:
removeAllElements in interface VectorIfc

toArray

public java.lang.Object[] toArray()
Return the objects in the Vector as an array.

Specified by:
toArray in interface VectorIfc
Returns:
Object[]

get

public PersistentCapableIfc get(int index)
Return the object at the specified index or null

Specified by:
get in interface VectorIfc
Returns:
PersistentCapableIfc

add

public boolean add(PersistentCapableIfc element)
Add the specified element to the end of the Vector. This subclass adds a further constraint on the incoming parameter which must be of type PeristentCapableIfc

Specified by:
add in interface VectorIfc
Parameters:
element - element to add
Returns:
boolean true if successful and false otherwise

remove

public boolean remove(PersistentCapableIfc element)
Remove the specified element from the Vector

Specified by:
remove in interface VectorIfc
Parameters:
element - element to remove
Returns:
boolean true if successful; and false otherwise

add

public void add(int index,
                PersistentCapableIfc element)
Add the element at the specified index. An additional constraint applies to element in that it must also be of type PersistentCapableIfc

Specified by:
add in interface VectorIfc
Parameters:
index - index
element - element to add

set

public void set(int index,
                PersistentCapableIfc element)
Set the object at the location given, overwriting the existing object if it exists. An additional constraint applies to element in that it must also be of type PersistentCapableIfc

Specified by:
set in interface VectorIfc
Parameters:
index - index
element - element to add

remove

public PersistentCapableIfc remove(int index)
Remove the element at the specified index and return it to the client

Specified by:
remove in interface VectorIfc
Parameters:
index - index to query
Returns:
PersistentCapableIfc

clear

public void clear()
Clear the vector

Specified by:
clear in interface VectorIfc

writeExternal

public void writeExternal(java.io.ObjectOutput stream)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class PersistentObject
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput stream)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class PersistentObject
Throws:
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 1999-2005 The Exolab Group. All Rights Reserved.