Source code: com/flexstor/common/importprocessor/ImportTypesFound.java
1 /*
2 * ImportTypesFound.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:37 $ FLEXSTOR.net Inc.
5 *
6 * This work is licensed for use and distribution under license terms found at
7 * http://www.flexstor.org/license.html
8 *
9 */
10
11 package com.flexstor.common.importprocessor;
12
13 import java.util.Vector;
14
15
16 /**
17 *
18 *
19 */
20 public class ImportTypesFound extends Vector
21 {
22
23 protected int nTypeIndex = 0;
24
25 /**
26 *
27 *
28 */
29 public ImportTypesFound()
30 {
31
32
33 } // constructor
34
35
36 /**
37 *
38 *
39 */
40 public void resetTypeIndex()
41 {
42 nTypeIndex = 0;
43 }
44
45
46
47 /**
48 *
49 *
50 */
51 public boolean addType(String sType)
52 {
53 if ((sType == null) || (sType.equals("") == true))
54 {
55 return false;
56 }
57
58
59 // Does the type exist in this vector?
60 for (int i = 0; i < this.size(); i++)
61 {
62 String sTypeInVector = (String)this.elementAt(i);
63
64 // Does the string already exist in the vector?
65 // This first check guarantees that any type that
66 // contains a "." will be detected
67 if (sTypeInVector.equals(sType) == true)
68 {
69 // Type already in vector, so exit
70 return true;
71 }
72
73 // Since RoleAssignServices may have prepended a "role." to the type string
74 // extract the type alone if required ("role.type")
75 int nPeriod = sTypeInVector.indexOf(".");
76 if (nPeriod != -1)
77 {
78 // It contains role, so extract the type only
79 sTypeInVector = sTypeInVector.substring(nPeriod + 1);
80 if (sTypeInVector.equals(sType) == true)
81 {
82 // Type already in vector, so exit
83 return true;
84 }
85 }
86 } // for i
87
88 this.addElement(sType);
89
90 return true;
91 }
92
93
94 /**
95 *
96 *
97 */
98 public String getNextType()
99 {
100 return getNextType(false);
101 }
102
103
104 /**
105 *
106 *
107 */
108 public String getNextType(boolean bResetIndex)
109 {
110 String sType = null;
111
112 if (bResetIndex == true)
113 {
114 nTypeIndex = 0;
115 }
116
117 if (nTypeIndex < this.size())
118 {
119 sType = (String)this.elementAt(nTypeIndex);
120 nTypeIndex++;
121 }
122
123 return sType;
124 } // getNextType
125
126
127 /**
128 *
129 *
130 */
131 public String[] getTypes()
132 {
133 String[] saData = new String[this.size()];
134
135 this.copyInto(saData);
136 return saData;
137 } // getTypes
138
139
140 /**
141 *
142 *
143 */
144 public void clearTypes()
145 {
146 this.removeAllElements();
147 }
148
149 } // ImportTypesFound