KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > faces > component > _FacetsAndChildrenIterator


1 /*
2  * Copyright 2004 The Apache Software Foundation.
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, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package javax.faces.component;
17
18 import java.util.Iterator JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.Map JavaDoc;
21 import java.util.NoSuchElementException JavaDoc;
22
23 /**
24  * @author Manfred Geiler (latest modification by $Author: mwessendorf $)
25  * @version $Revision: 1.3 $ $Date: 2004/07/01 22:00:49 $
26  */

27 class _FacetsAndChildrenIterator
28         implements Iterator JavaDoc
29 {
30     private Iterator JavaDoc _facetsIterator;
31     private Iterator JavaDoc _childrenIterator;
32
33     _FacetsAndChildrenIterator(Map JavaDoc facetMap, List JavaDoc childrenList)
34     {
35         _facetsIterator = facetMap != null ? facetMap.values().iterator() : null;
36         _childrenIterator = childrenList != null ? childrenList.iterator() : null;
37     }
38
39     public boolean hasNext()
40     {
41         return (_facetsIterator != null && _facetsIterator.hasNext()) ||
42                (_childrenIterator != null && _childrenIterator.hasNext());
43     }
44
45     public Object JavaDoc next()
46     {
47         if (_facetsIterator != null && _facetsIterator.hasNext())
48         {
49             return _facetsIterator.next();
50         }
51         else if (_childrenIterator != null && _childrenIterator.hasNext())
52         {
53             return _childrenIterator.next();
54         }
55         else
56         {
57             throw new NoSuchElementException JavaDoc();
58         }
59     }
60
61     public void remove()
62     {
63         throw new UnsupportedOperationException JavaDoc(this.getClass().getName() + " UnsupportedOperationException");
64     }
65
66 }
67
Popular Tags