Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mitre/cvw/CheckVector.java


1   /*
2    * Copyright (c) 1996-2000. The MITRE Corporation (http://www.mitre.org/).
3    * All rights reserved.
4    * CVW comes with ABSOLUTELY NO WARRANTY. See license for details.
5    */
6   
7   package org.mitre.cvw;
8   
9   import java.util.Vector;
10  import java.util.Enumeration;
11  
12  
13  /**
14   * This class is for special vectors that may have document checkout operations 
15   *
16   * @version 1 
17   * @author Stephen Jones, The MITRE Corporation
18   */
19  public class CheckVector extends Object {
20    boolean co_vector = false;   // tracks whether this vector has checkout information
21    Vector docVector;
22    
23  /**
24   * Constructor
25   */
26    public CheckVector(Vector docTypes) {
27      docVector = docTypes;
28    }
29    
30  /**
31   * Determines the number of items in the Vector
32   *
33   * @return The number of items stored.
34   */
35    public int sizeOf() {
36      if (docVector != null) {
37        if (co_vector) 
38    return (docVector.size()/2);
39        else  
40    return (docVector.size());
41      } else {
42        return 0;
43      }
44    }
45    
46  /**
47   * Signals whether this instance is a checkout vector
48   *
49   * @return <code>true</code> if this is a checkout vector, otherwise <code>false</code>
50   */
51    public boolean isCOVector() {
52      return co_vector;
53    }
54    
55  /**
56   * Modifies an instance to becoming a checkout vector
57   */
58    public void createCOVector() {
59      co_vector = true;
60    }
61      
62  /**
63   * Retrieves the elements of a standard vector.
64   *
65   * @return a listing of the elements stored in the vector.
66   */
67    public Enumeration elementsOf() {
68      return (new CheckVectorEnum(this, false));
69    }
70  
71  /**
72   * Retrieves the elements of a checkout vector
73   *
74   * @return a listing of the elements stored in the vector.
75   */
76    public Enumeration coElementsOf() {
77      return (new CheckVectorEnum(this, true));
78    }
79  
80  /**
81   * Retrieve a particular element within the vector
82   *
83   * @param position The position where the element resides
84   * @return The element requested.
85   */
86    public Object elementAt(int position) {
87      return (docVector.elementAt(position));
88    }
89  }
90