01: /*
02: * Copyright 2007 Dan Shellman
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.iscreen;
17:
18: import java.util.ArrayList;
19: import java.util.Iterator;
20: import java.util.List;
21:
22: /**
23: * For each validation service, a set of documentation may exist (on a per
24: * validator basis). Instances of this class represent the set of
25: * documentation for the entire service.
26: *
27: * @author Shellman, Dan
28: */
29: public class DocumentationIterator implements Iterator {
30: protected List items = new ArrayList();
31: protected List itemNames = new ArrayList();
32: protected int currentIndex = 0;
33:
34: /**
35: * Default constructor.
36: */
37: public DocumentationIterator() {
38: } //end DocumentationIterator()
39:
40: public boolean hasNext() {
41: if (currentIndex < items.size()) {
42: return true;
43: }
44:
45: return false;
46: } //end hasNext()
47:
48: public Object next() {
49: return items.get(currentIndex++);
50: } //end next()
51:
52: public void remove() {
53: items.remove(currentIndex);
54: } //end remove()
55:
56: public String getCurrentName() {
57: return (String) itemNames.get(currentIndex);
58: } //end getCurrentName()
59:
60: public String nextItem() {
61: return (String) items.get(currentIndex++);
62: } //end nextItem()
63:
64: public void reset() {
65: currentIndex = 0;
66: } //end reset()
67:
68: public int getCount() {
69: return items.size();
70: } //end getCount()
71:
72: public String getDoc(int index) {
73: return (String) items.get(index);
74: } //end getDoc()
75:
76: public String getName(int index) {
77: return (String) itemNames.get(index);
78: } //end getName()
79:
80: public void addItem(String item, String name) {
81: items.add(item);
82: itemNames.add(name);
83: } //end addItem()
84:
85: public int getCurrentIndex() {
86: return currentIndex;
87: }
88:
89: public void addIterator(DocumentationIterator it) {
90: items.addAll(it.items);
91: itemNames.addAll(it.itemNames);
92: } //end addIterator()
93: } //end DocumentationIterator
|