home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / utils / pagevector.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.6 KB  |  74 lines

  1. // PageVector.java
  2. // 27.02.96
  3. // 
  4. // Puts a lot of typecasting in one place
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.util.Vector;
  9. import java.util.Enumeration;
  10.  
  11.  
  12. /**
  13.  * This is a Vector of Page objects.  See the comments for the
  14.  * Vector class, they all apply.  The only difference is that it
  15.  * only takes and returns Page's.  Note: I didn't implement
  16.  * the entire set of Vector methods, just the one's I use.  I would
  17.  * have extended the Vector class, but most of its methods are final.
  18.  *
  19.  * @see Vector;
  20.  * @see Page;
  21.  */
  22. public class PageVector {
  23.  
  24.   /* the real Vector behind the scenes */
  25.   private Vector objects;
  26.  
  27.   public PageVector () {
  28.     objects = new Vector ();
  29.   }
  30.  
  31.   public PageVector (int initCapacity) {
  32.     objects = new Vector (initCapacity);
  33.   }
  34.  
  35.   public synchronized void addElement (Page newElement) {
  36.     objects.addElement (newElement);
  37.   }
  38.  
  39.   public synchronized Page elementAt (int index) {
  40.     return (Page)objects.elementAt (index);
  41.   }
  42.  
  43.   public synchronized Page firstElement () {
  44.     return (Page)objects.firstElement ();
  45.   }
  46.  
  47.   public synchronized Page lastElement () {
  48.     return (Page)objects.lastElement ();
  49.   }
  50.  
  51.   /**
  52.    * Ok, so the Page type info is lost in the Enumeration. 
  53.    */
  54.   public synchronized Enumeration elements () {
  55.     return objects.elements ();
  56.   }
  57.  
  58.   public int size () {
  59.     return objects.size ();
  60.   }
  61.  
  62.   public boolean isEmpty () {
  63.     return objects.isEmpty ();
  64.   }
  65.  
  66.   public synchronized void removeElementAt (int index) {
  67.     objects.removeElementAt (index);
  68.   }
  69.  
  70.   public synchronized String toString () {
  71.     return objects.toString ();
  72.   }
  73. }
  74.