1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.util; |
17 | |
|
18 | |
import java.util.Collection; |
19 | |
import java.util.Iterator; |
20 | |
|
21 | |
import javax.faces.component.UIComponent; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class RenderedComponentIterator implements Iterator { |
27 | |
|
28 | |
private Iterator iterator; |
29 | |
|
30 | |
private UIComponent component; |
31 | |
|
32 | 235 | public RenderedComponentIterator(final Collection collection) { |
33 | 235 | iterator = collection.iterator(); |
34 | 235 | } |
35 | |
|
36 | |
public boolean hasNext() { |
37 | 386 | if (component != null) { |
38 | 0 | return true; |
39 | |
} |
40 | 393 | while (iterator.hasNext()) { |
41 | 160 | final UIComponent c = (UIComponent) iterator.next(); |
42 | 160 | if (c.isRendered()) { |
43 | 153 | component = c; |
44 | 153 | return true; |
45 | |
} |
46 | |
} |
47 | 233 | return false; |
48 | |
} |
49 | |
|
50 | |
public Object next() { |
51 | 157 | if (component != null) { |
52 | 153 | final UIComponent c = component; |
53 | 153 | component = null; |
54 | 153 | return c; |
55 | |
} |
56 | |
while (true) { |
57 | 6 | final UIComponent c = (UIComponent) iterator.next(); |
58 | 4 | if (c.isRendered()) { |
59 | 2 | return c; |
60 | |
} |
61 | |
} |
62 | |
} |
63 | |
|
64 | |
public void remove() { |
65 | 0 | throw new UnsupportedOperationException("remove"); |
66 | |
} |
67 | |
|
68 | |
} |