Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ComponentFacetAndChildrenIterator |
|
| 2.3333333333333335;2.333 |
1 | /* | |
2 | * Copyright 2004-2011 the Seasar Foundation and the Others. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
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, | |
13 | * either express or implied. See the License for the specific language | |
14 | * governing permissions and limitations under the License. | |
15 | */ | |
16 | package javax.faces.internal; | |
17 | ||
18 | import java.util.Iterator; | |
19 | import java.util.List; | |
20 | import java.util.Map; | |
21 | import java.util.NoSuchElementException; | |
22 | ||
23 | /** | |
24 | * @author shot | |
25 | * | |
26 | * This class might be changed without notice. Please do not use it | |
27 | * excluding the JSF specification part. | |
28 | */ | |
29 | public class ComponentFacetAndChildrenIterator implements Iterator { | |
30 | ||
31 | 1359 | private Iterator facetIterator = null; |
32 | ||
33 | 1359 | private Iterator childrenIterator = null; |
34 | ||
35 | 1359 | public ComponentFacetAndChildrenIterator(Map facetMap, List childrenList) { |
36 | 1359 | if (facetMap != null) { |
37 | 393 | facetIterator = facetMap.values().iterator(); |
38 | } | |
39 | 1359 | if (childrenList != null) { |
40 | 1080 | childrenIterator = childrenList.iterator(); |
41 | } | |
42 | 1359 | } |
43 | ||
44 | public void remove() { | |
45 | 44 | throw new UnsupportedOperationException("remove"); |
46 | } | |
47 | ||
48 | public boolean hasNext() { | |
49 | 1834 | return (facetHasNext() || childrenHasNext()); |
50 | } | |
51 | ||
52 | public Object next() { | |
53 | 1136 | if (facetHasNext()) { |
54 | 240 | return facetIterator.next(); |
55 | } | |
56 | 896 | if (childrenHasNext()) { |
57 | 895 | return childrenIterator.next(); |
58 | } | |
59 | 1 | throw new NoSuchElementException(); |
60 | } | |
61 | ||
62 | private boolean facetHasNext() { | |
63 | 2970 | return (facetIterator != null && facetIterator.hasNext()); |
64 | } | |
65 | ||
66 | private boolean childrenHasNext() { | |
67 | 2580 | return (childrenIterator != null && childrenIterator.hasNext()); |
68 | } | |
69 | } |