home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.8 KB | 85 lines |
- // PersonVector.java
- // 27.02.96
- //
- // Puts a lot of typecasting in one place
-
- package cybcerone.utils;
-
- import java.util.Vector;
- import java.util.Enumeration;
-
-
- /**
- * A Vector of Person objects. See the comments for the
- * Vector class, they all apply. The only difference is that it
- * only takes and returns Person's. Note: I didn't implement
- * the entire set of Vector methods, just the one's I use. I would
- * have extended the Vector class, but most of its methods are final.
- *
- * @see Vector;
- * @see Person;
- */
- public class PersonVector {
-
- /* the real Vector behind the scenes */
- private Vector objects;
-
- public PersonVector () {
- objects = new Vector ();
- }
-
- public PersonVector (int initCapacity) {
- objects = new Vector (initCapacity);
- }
-
- /**
- * Converts a Vector into a PersonVector.
- */
- public PersonVector (Vector oldVector) {
- objects = oldVector;
- }
-
- public synchronized void addElement (Person newElement) {
- objects.addElement (newElement);
- }
-
- public synchronized Person elementAt (int index) {
- return (Person)objects.elementAt (index);
- }
-
- public synchronized Person firstElement () {
- return (Person)objects.firstElement ();
- }
-
- public synchronized Person lastElement () {
- return (Person)objects.lastElement ();
- }
-
- /**
- * Ok, so the Person type info is lost in the Enumeration.
- */
- public synchronized Enumeration elements () {
- return objects.elements ();
- }
-
- public int size () {
- return objects.size ();
- }
-
- public boolean isEmpty () {
- return objects.isEmpty ();
- }
-
- public synchronized void removeElementAt (int index) {
- objects.removeElementAt (index);
- }
-
- public synchronized String toString () {
- return objects.toString ();
- }
-
- public synchronized Vector toVector () {
- return objects;
- }
- }
-