KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > naming > NameImpl


1 /*
2  * @(#)NameImpl.java 1.9 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.naming;
9
10 import java.util.Vector JavaDoc;
11 import java.util.Enumeration JavaDoc;
12 import java.util.Properties JavaDoc;
13 import java.util.NoSuchElementException JavaDoc;
14
15 /**
16   * The implementation class for CompoundName and CompositeName.
17   * This class is package private.
18   *
19   * @author Rosanna Lee
20   * @author Scott Seligman
21   * @author Aravindan Ranganathan
22   * @version 1.9 03/12/19
23   * @since 1.3
24   */

25
26 class NameImpl {
27     private static final byte LEFT_TO_RIGHT = 1;
28     private static final byte RIGHT_TO_LEFT = 2;
29     private static final byte FLAT = 0;
30
31     private Vector JavaDoc components;
32
33     private byte syntaxDirection = LEFT_TO_RIGHT;
34     private String JavaDoc syntaxSeparator = "/";
35     private String JavaDoc syntaxSeparator2 = null;
36     private boolean syntaxCaseInsensitive = false;
37     private boolean syntaxTrimBlanks = false;
38     private String JavaDoc syntaxEscape = "\\";
39     private String JavaDoc syntaxBeginQuote1 = "\"";
40     private String JavaDoc syntaxEndQuote1 = "\"";
41     private String JavaDoc syntaxBeginQuote2 = "'";
42     private String JavaDoc syntaxEndQuote2 = "'";
43     private String JavaDoc syntaxAvaSeparator = null;
44     private String JavaDoc syntaxTypevalSeparator = null;
45
46     // escapingStyle gives the method used at creation time for
47
// quoting or escaping characters in the name. It is set to the
48
// first style of quote or escape encountered if and when the name
49
// is parsed.
50
private static final int STYLE_NONE = 0;
51     private static final int STYLE_QUOTE1 = 1;
52     private static final int STYLE_QUOTE2 = 2;
53     private static final int STYLE_ESCAPE = 3;
54     private int escapingStyle = STYLE_NONE;
55
56     // Returns true if "match" is not null, and n contains "match" at
57
// position i.
58
private final boolean isA(String JavaDoc n, int i, String JavaDoc match) {
59     return (match != null && n.startsWith(match, i));
60     }
61
62     private final boolean isMeta(String JavaDoc n, int i) {
63     return (isA(n, i, syntaxEscape) ||
64         isA(n, i, syntaxBeginQuote1) ||
65         isA(n, i, syntaxBeginQuote2) ||
66         isSeparator(n, i));
67     }
68
69     private final boolean isSeparator(String JavaDoc n, int i) {
70     return (isA(n, i, syntaxSeparator) ||
71         isA(n, i, syntaxSeparator2));
72     }
73
74     private final int skipSeparator(String JavaDoc name, int i) {
75     if (isA(name, i, syntaxSeparator)) {
76         i += syntaxSeparator.length();
77     } else if (isA(name, i, syntaxSeparator2)) {
78         i += syntaxSeparator2.length();
79     }
80     return (i);
81     }
82
83     private final int extractComp(String JavaDoc name, int i, int len, Vector JavaDoc comps)
84     throws InvalidNameException JavaDoc {
85     String JavaDoc beginQuote;
86     String JavaDoc endQuote;
87     boolean start = true;
88     boolean one = false;
89     StringBuffer JavaDoc answer = new StringBuffer JavaDoc(len);
90
91     while (i < len) {
92         // handle quoted strings
93
if (start && ((one = isA(name, i, syntaxBeginQuote1)) ||
94               isA(name, i, syntaxBeginQuote2))) {
95
96         // record choice of quote chars being used
97
beginQuote = one ? syntaxBeginQuote1 : syntaxBeginQuote2;
98         endQuote = one ? syntaxEndQuote1 : syntaxEndQuote2;
99         if (escapingStyle == STYLE_NONE) {
100             escapingStyle = one ? STYLE_QUOTE1 : STYLE_QUOTE2;
101         }
102
103         // consume string until matching quote
104
for (i += beginQuote.length();
105              ((i < len) && !name.startsWith(endQuote, i));
106              i++) {
107             // skip escape character if it is escaping ending quote
108
// otherwise leave as is.
109
if (isA(name, i, syntaxEscape) &&
110             isA(name, i + syntaxEscape.length(), endQuote)) {
111             i += syntaxEscape.length();
112             }
113             answer.append(name.charAt(i)); // copy char
114
}
115
116         // no ending quote found
117
if (i >= len)
118             throw
119             new InvalidNameException JavaDoc(name + ": no close quote");
120 // new Exception("no close quote");
121

122         i += endQuote.length();
123
124         // verify that end-quote occurs at separator or end of string
125
if (i == len || isSeparator(name, i)) {
126             break;
127         }
128 // throw (new Exception(
129
throw (new InvalidNameException JavaDoc(name +
130             ": close quote appears before end of component"));
131
132         } else if (isSeparator(name, i)) {
133         break;
134
135         } else if (isA(name, i, syntaxEscape)) {
136         if (isMeta(name, i + syntaxEscape.length())) {
137             // if escape precedes meta, consume escape and let
138
// meta through
139
i += syntaxEscape.length();
140             if (escapingStyle == STYLE_NONE) {
141             escapingStyle = STYLE_ESCAPE;
142             }
143         } else if (i + syntaxEscape.length() >= len) {
144             throw (new InvalidNameException JavaDoc(name +
145             ": unescaped " + syntaxEscape + " at end of component"));
146         }
147         } else if (isA(name, i, syntaxTypevalSeparator) &&
148     ((one = isA(name, i+syntaxTypevalSeparator.length(), syntaxBeginQuote1)) ||
149         isA(name, i+syntaxTypevalSeparator.length(), syntaxBeginQuote2))) {
150         // Handle quote occurring after typeval separator
151
beginQuote = one ? syntaxBeginQuote1 : syntaxBeginQuote2;
152         endQuote = one ? syntaxEndQuote1 : syntaxEndQuote2;
153
154         i += syntaxTypevalSeparator.length();
155         answer.append(syntaxTypevalSeparator+beginQuote); // add back
156

157         // consume string until matching quote
158
for (i += beginQuote.length();
159              ((i < len) && !name.startsWith(endQuote, i));
160              i++) {
161             // skip escape character if it is escaping ending quote
162
// otherwise leave as is.
163
if (isA(name, i, syntaxEscape) &&
164             isA(name, i + syntaxEscape.length(), endQuote)) {
165             i += syntaxEscape.length();
166             }
167             answer.append(name.charAt(i)); // copy char
168
}
169
170         // no ending quote found
171
if (i >= len)
172             throw
173             new InvalidNameException JavaDoc(name + ": typeval no close quote");
174
175         i += endQuote.length();
176         answer.append(endQuote); // add back
177

178         // verify that end-quote occurs at separator or end of string
179
if (i == len || isSeparator(name, i)) {
180             break;
181         }
182         throw (new InvalidNameException JavaDoc(name.substring(i) +
183             ": typeval close quote appears before end of component"));
184         }
185
186         answer.append(name.charAt(i++));
187         start = false;
188     }
189
190     if (syntaxDirection == RIGHT_TO_LEFT)
191         comps.insertElementAt(answer.toString(), 0);
192     else
193         comps.addElement(answer.toString());
194     return i;
195     }
196
197     private static boolean getBoolean(Properties JavaDoc p, String JavaDoc name) {
198     return toBoolean(p.getProperty(name));
199     }
200
201     private static boolean toBoolean(String JavaDoc name) {
202     return ((name != null) && name.toLowerCase().equals("true"));
203     }
204
205     private final void recordNamingConvention(Properties JavaDoc p) {
206     String JavaDoc syntaxDirectionStr =
207         p.getProperty("jndi.syntax.direction", "flat");
208     if (syntaxDirectionStr.equals("left_to_right")) {
209         syntaxDirection = LEFT_TO_RIGHT;
210     } else if (syntaxDirectionStr.equals("right_to_left")) {
211         syntaxDirection = RIGHT_TO_LEFT;
212     } else if (syntaxDirectionStr.equals("flat")) {
213         syntaxDirection = FLAT;
214     } else {
215         throw new IllegalArgumentException JavaDoc(syntaxDirectionStr +
216         "is not a valid value for the jndi.syntax.direction property");
217     }
218
219     if (syntaxDirection != FLAT) {
220         syntaxSeparator = p.getProperty("jndi.syntax.separator");
221         syntaxSeparator2 = p.getProperty("jndi.syntax.separator2");
222         if (syntaxSeparator == null) {
223         throw new IllegalArgumentException JavaDoc(
224             "jndi.syntax.separator property required for non-flat syntax");
225         }
226     } else {
227         syntaxSeparator = null;
228     }
229     syntaxEscape = p.getProperty("jndi.syntax.escape");
230
231     syntaxCaseInsensitive = getBoolean(p, "jndi.syntax.ignorecase");
232     syntaxTrimBlanks = getBoolean(p, "jndi.syntax.trimblanks");
233
234     syntaxBeginQuote1 = p.getProperty("jndi.syntax.beginquote");
235     syntaxEndQuote1 = p.getProperty("jndi.syntax.endquote");
236     if (syntaxEndQuote1 == null && syntaxBeginQuote1 != null)
237         syntaxEndQuote1 = syntaxBeginQuote1;
238     else if (syntaxBeginQuote1 == null && syntaxEndQuote1 != null)
239         syntaxBeginQuote1 = syntaxEndQuote1;
240     syntaxBeginQuote2 = p.getProperty("jndi.syntax.beginquote2");
241     syntaxEndQuote2 = p.getProperty("jndi.syntax.endquote2");
242     if (syntaxEndQuote2 == null && syntaxBeginQuote2 != null)
243         syntaxEndQuote2 = syntaxBeginQuote2;
244     else if (syntaxBeginQuote2 == null && syntaxEndQuote2 != null)
245         syntaxBeginQuote2 = syntaxEndQuote2;
246
247     syntaxAvaSeparator = p.getProperty("jndi.syntax.separator.ava");
248     syntaxTypevalSeparator =
249         p.getProperty("jndi.syntax.separator.typeval");
250     }
251
252     NameImpl(Properties JavaDoc syntax) {
253     if (syntax != null) {
254         recordNamingConvention(syntax);
255     }
256     components = new Vector JavaDoc();
257     }
258
259     NameImpl(Properties JavaDoc syntax, String JavaDoc n) throws InvalidNameException JavaDoc {
260     this(syntax);
261
262     boolean rToL = (syntaxDirection == RIGHT_TO_LEFT);
263     boolean compsAllEmpty = true;
264     int len = n.length();
265
266     for (int i = 0; i < len; ) {
267         i = extractComp(n, i, len, components);
268
269         String JavaDoc comp = rToL
270         ? (String JavaDoc)components.firstElement()
271         : (String JavaDoc)components.lastElement();
272         if (comp.length() >= 1) {
273         compsAllEmpty = false;
274         }
275
276         if (i < len) {
277         i = skipSeparator(n, i);
278         if ((i == len) && !compsAllEmpty) {
279             // Trailing separator found. Add an empty component.
280
if (rToL) {
281             components.insertElementAt("", 0);
282             } else {
283             components.addElement("");
284             }
285         }
286         }
287     }
288     }
289
290     NameImpl(Properties JavaDoc syntax, Enumeration JavaDoc comps) {
291     this(syntax);
292
293     // %% comps could shrink in the middle.
294
while (comps.hasMoreElements())
295         components.addElement(comps.nextElement());
296     }
297 /*
298     // Determines whether this component needs any escaping.
299     private final boolean escapingNeeded(String comp) {
300     int len = comp.length();
301     for (int i = 0; i < len; i++) {
302         if (i == 0) {
303         if (isA(comp, 0, syntaxBeginQuote1) ||
304             isA(comp, 0, syntaxBeginQuote2)) {
305             return (true);
306         }
307         }
308         if (isSeparator(comp, i)) {
309         return (true);
310         }
311         if (isA(comp, i, syntaxEscape)) {
312         i += syntaxEscape.length();
313         if (i >= len || isMeta(comp, i)) {
314             return (true);
315         }
316         }
317     }
318     return (false);
319     }
320 */

321     private final String JavaDoc stringifyComp(String JavaDoc comp) {
322     int len = comp.length();
323     boolean escapeSeparator = false, escapeSeparator2 = false;
324     String JavaDoc beginQuote = null, endQuote = null;
325     StringBuffer JavaDoc strbuf = new StringBuffer JavaDoc(len);
326
327     // determine whether there are any separators; if so escape
328
// or quote them
329
if (syntaxSeparator != null &&
330         comp.indexOf(syntaxSeparator) >= 0) {
331         if (syntaxBeginQuote1 != null) {
332         beginQuote = syntaxBeginQuote1;
333         endQuote = syntaxEndQuote1;
334         } else if (syntaxBeginQuote2 != null) {
335         beginQuote = syntaxBeginQuote2;
336         endQuote = syntaxEndQuote2;
337         } else if (syntaxEscape != null)
338         escapeSeparator = true;
339     }
340     if (syntaxSeparator2 != null &&
341         comp.indexOf(syntaxSeparator2) >= 0) {
342         if (syntaxBeginQuote1 != null) {
343         if (beginQuote == null) {
344             beginQuote = syntaxBeginQuote1;
345             endQuote = syntaxEndQuote1;
346         }
347         } else if (syntaxBeginQuote2 != null) {
348         if (beginQuote == null) {
349             beginQuote = syntaxBeginQuote2;
350             endQuote = syntaxEndQuote2;
351         }
352         } else if (syntaxEscape != null)
353         escapeSeparator2 = true;
354     }
355
356     // if quoting component,
357
if (beginQuote != null) {
358
359         // start string off with opening quote
360
strbuf = strbuf.append(beginQuote);
361
362         // component is being quoted, so we only need to worry about
363
// escaping end quotes that occur in component
364
for (int i = 0; i < len; ) {
365         if (comp.startsWith(endQuote, i)) {
366             // end-quotes must be escaped when inside a quoted string
367
strbuf.append(syntaxEscape).append(endQuote);
368             i += endQuote.length();
369         } else {
370             // no special treatment required
371
strbuf.append(comp.charAt(i++));
372         }
373         }
374
375         // end with closing quote
376
strbuf.append(endQuote);
377
378     } else {
379
380         // When component is not quoted, add escape for:
381
// 1. leading quote
382
// 2. an escape preceding any meta char
383
// 3. an escape at the end of a component
384
// 4. separator
385

386         // go through characters in component and escape where necessary
387
boolean start = true;
388         for (int i = 0; i < len; ) {
389         // leading quote must be escaped
390
if (start && isA(comp, i, syntaxBeginQuote1)) {
391             strbuf.append(syntaxEscape).append(syntaxBeginQuote1);
392             i += syntaxBeginQuote1.length();
393         } else if (start && isA(comp, i, syntaxBeginQuote2)) {
394             strbuf.append(syntaxEscape).append(syntaxBeginQuote2);
395             i += syntaxBeginQuote2.length();
396         } else
397
398         // Escape an escape preceding meta characters, or at end.
399
// Other escapes pass through.
400
if (isA(comp, i, syntaxEscape)) {
401             if (i + syntaxEscape.length() >= len) {
402             // escape an ending escape
403
strbuf.append(syntaxEscape);
404             } else if (isMeta(comp, i + syntaxEscape.length())) {
405             // escape meta strings
406
strbuf.append(syntaxEscape);
407             }
408             strbuf.append(syntaxEscape);
409             i += syntaxEscape.length();
410         } else
411
412         // escape unescaped separator
413
if (escapeSeparator && comp.startsWith(syntaxSeparator, i)) {
414             // escape separator
415
strbuf.append(syntaxEscape).append(syntaxSeparator);
416             i += syntaxSeparator.length();
417         } else if (escapeSeparator2 &&
418                comp.startsWith(syntaxSeparator2, i)) {
419             // escape separator2
420
strbuf.append(syntaxEscape).append(syntaxSeparator2);
421             i += syntaxSeparator2.length();
422         } else {
423             // no special treatment required
424
strbuf.append(comp.charAt(i++));
425         }
426         start = false;
427         }
428     }
429     return (strbuf.toString());
430     }
431
432     public String JavaDoc toString() {
433     StringBuffer JavaDoc answer = new StringBuffer JavaDoc();
434     String JavaDoc comp;
435     boolean compsAllEmpty = true;
436     int size = components.size();
437
438     for (int i = 0; i < size; i++) {
439         if (syntaxDirection == RIGHT_TO_LEFT) {
440         comp =
441             stringifyComp((String JavaDoc) components.elementAt(size - 1 - i));
442         } else {
443         comp = stringifyComp((String JavaDoc) components.elementAt(i));
444         }
445         if ((i != 0) && (syntaxSeparator != null))
446         answer.append(syntaxSeparator);
447         if (comp.length() >= 1)
448         compsAllEmpty = false;
449         answer = answer.append(comp);
450     }
451     if (compsAllEmpty && (size >= 1) && (syntaxSeparator != null))
452         answer = answer.append(syntaxSeparator);
453     return (answer.toString());
454     }
455
456     public boolean equals(Object JavaDoc obj) {
457     if ((obj != null) && (obj instanceof NameImpl JavaDoc)) {
458         NameImpl JavaDoc target = (NameImpl JavaDoc)obj;
459         if (target.size() == this.size()) {
460         Enumeration JavaDoc mycomps = getAll();
461         Enumeration JavaDoc comps = target.getAll();
462         while (mycomps.hasMoreElements()) {
463             // %% comps could shrink in the middle.
464
String JavaDoc my = (String JavaDoc)mycomps.nextElement();
465             String JavaDoc his = (String JavaDoc)comps.nextElement();
466             if (syntaxTrimBlanks) {
467             my = my.trim();
468             his = his.trim();
469             }
470             if (syntaxCaseInsensitive) {
471             if (!(my.equalsIgnoreCase(his)))
472                 return false;
473             } else {
474             if (!(my.equals(his)))
475                 return false;
476             }
477         }
478         return true;
479         }
480     }
481     return false;
482     }
483
484     /**
485       * Compares obj to this NameImpl to determine ordering.
486       * Takes into account syntactic properties such as
487       * elimination of blanks, case-ignore, etc, if relevant.
488       *
489       * Note: using syntax of this NameImpl and ignoring
490       * that of comparison target.
491       */

492     public int compareTo(NameImpl JavaDoc obj) {
493     if (this == obj) {
494         return 0;
495     }
496
497     int len1 = size();
498     int len2 = obj.size();
499     int n = Math.min(len1, len2);
500
501     int index1 = 0, index2 = 0;
502
503     while (n-- != 0) {
504         String JavaDoc comp1 = get(index1++);
505         String JavaDoc comp2 = obj.get(index2++);
506
507         // normalize according to syntax
508
if (syntaxTrimBlanks) {
509         comp1 = comp1.trim();
510         comp2 = comp2.trim();
511         }
512         if (syntaxCaseInsensitive) {
513         comp1 = comp1.toLowerCase();
514         comp2 = comp2.toLowerCase();
515         }
516         int local = comp1.compareTo(comp2);
517         if (local != 0) {
518         return local;
519         }
520     }
521
522     return len1 - len2;
523     }
524
525     public int size() {
526     return (components.size());
527     }
528
529     public Enumeration JavaDoc getAll() {
530     return components.elements();
531     }
532
533     public String JavaDoc get(int posn) {
534     return ((String JavaDoc) components.elementAt(posn));
535     }
536
537     public Enumeration JavaDoc getPrefix(int posn) {
538     if (posn < 0 || posn > size()) {
539         throw new ArrayIndexOutOfBoundsException JavaDoc(posn);
540     }
541     return new NameImplEnumerator(components, 0, posn);
542     }
543
544     public Enumeration JavaDoc getSuffix(int posn) {
545     int cnt = size();
546     if (posn < 0 || posn > cnt) {
547         throw new ArrayIndexOutOfBoundsException JavaDoc(posn);
548     }
549     return new NameImplEnumerator(components, posn, cnt);
550     }
551
552     public boolean isEmpty() {
553     return (components.isEmpty());
554     }
555
556     public boolean startsWith(int posn, Enumeration JavaDoc prefix) {
557     if (posn < 0 || posn > size()) {
558         return false;
559     }
560     try {
561         Enumeration JavaDoc mycomps = getPrefix(posn);
562         while (mycomps.hasMoreElements()) {
563         String JavaDoc my = (String JavaDoc)mycomps.nextElement();
564         String JavaDoc his = (String JavaDoc)prefix.nextElement();
565         if (syntaxTrimBlanks) {
566             my = my.trim();
567             his = his.trim();
568         }
569         if (syntaxCaseInsensitive) {
570             if (!(my.equalsIgnoreCase(his)))
571             return false;
572         } else {
573             if (!(my.equals(his)))
574             return false;
575         }
576         }
577     } catch (NoSuchElementException JavaDoc e) {
578         return false;
579     }
580     return true;
581     }
582
583     public boolean endsWith(int posn, Enumeration JavaDoc suffix) {
584     // posn is number of elements in suffix
585
// startIndex is the starting position in this name
586
// at which to start the comparison. It is calculated by
587
// subtracting 'posn' from size()
588
int startIndex = size() - posn;
589     if (startIndex < 0 || startIndex > size()) {
590         return false;
591     }
592     try {
593         Enumeration JavaDoc mycomps = getSuffix(startIndex);
594         while (mycomps.hasMoreElements()) {
595         String JavaDoc my = (String JavaDoc)mycomps.nextElement();
596         String JavaDoc his = (String JavaDoc)suffix.nextElement();
597         if (syntaxTrimBlanks) {
598             my = my.trim();
599             his = his.trim();
600         }
601         if (syntaxCaseInsensitive) {
602             if (!(my.equalsIgnoreCase(his)))
603             return false;
604         } else {
605             if (!(my.equals(his)))
606             return false;
607         }
608         }
609     } catch (NoSuchElementException JavaDoc e) {
610         return false;
611     }
612     return true;
613     }
614
615     public boolean addAll(Enumeration JavaDoc comps) throws InvalidNameException JavaDoc {
616     boolean added = false;
617     while (comps.hasMoreElements()) {
618         try {
619         Object JavaDoc comp = comps.nextElement();
620         if (size() > 0 && syntaxDirection == FLAT) {
621             throw new InvalidNameException JavaDoc(
622             "A flat name can only have a single component");
623         }
624         components.addElement(comp);
625         added = true;
626         } catch (NoSuchElementException JavaDoc e) {
627         break; // "comps" has shrunk.
628
}
629     }
630     return added;
631     }
632
633     public boolean addAll(int posn, Enumeration JavaDoc comps)
634     throws InvalidNameException JavaDoc {
635     boolean added = false;
636     for (int i = posn; comps.hasMoreElements(); i++) {
637         try {
638         Object JavaDoc comp = comps.nextElement();
639         if (size() > 0 && syntaxDirection == FLAT) {
640             throw new InvalidNameException JavaDoc(
641             "A flat name can only have a single component");
642         }
643         components.insertElementAt(comp, i);
644         added = true;
645         } catch (NoSuchElementException JavaDoc e) {
646         break; // "comps" has shrunk.
647
}
648     }
649     return added;
650     }
651
652     public void add(String JavaDoc comp) throws InvalidNameException JavaDoc {
653     if (size() > 0 && syntaxDirection == FLAT) {
654         throw new InvalidNameException JavaDoc(
655         "A flat name can only have a single component");
656     }
657     components.addElement(comp);
658     }
659
660     public void add(int posn, String JavaDoc comp) throws InvalidNameException JavaDoc {
661     if (size() > 0 && syntaxDirection == FLAT) {
662         throw new InvalidNameException JavaDoc(
663         "A flat name can only zero or one component");
664     }
665     components.insertElementAt(comp, posn);
666     }
667
668     public Object JavaDoc remove(int posn) {
669     Object JavaDoc r = components.elementAt(posn);
670     components.removeElementAt(posn);
671     return r;
672     }
673
674     public int hashCode() {
675     int hash = 0;
676     for (Enumeration JavaDoc e = getAll(); e.hasMoreElements();) {
677         String JavaDoc comp = (String JavaDoc)e.nextElement();
678         if (syntaxTrimBlanks) {
679         comp = comp.trim();
680         }
681         if (syntaxCaseInsensitive) {
682         comp = comp.toLowerCase();
683         }
684     
685         hash += comp.hashCode();
686     }
687     return hash;
688     }
689 }
690
691 final
692 class NameImplEnumerator implements Enumeration JavaDoc {
693     Vector JavaDoc vector;
694     int count;
695     int limit;
696
697     NameImplEnumerator(Vector JavaDoc v, int start, int lim) {
698     vector = v;
699     count = start;
700     limit = lim;
701     }
702
703     public boolean hasMoreElements() {
704     return count < limit;
705     }
706
707     public Object JavaDoc nextElement() {
708     if (count < limit) {
709         return vector.elementAt(count++);
710     }
711     throw new NoSuchElementException JavaDoc("NameImplEnumerator");
712     }
713 }
714
715
Popular Tags