View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package javax.faces.component.visit;
20  
21  import java.io.Serializable;
22  import java.util.Collection;
23  import java.util.Iterator;
24  import java.util.Set;
25  
26  import javax.faces.FactoryFinder;
27  import javax.faces.component.UIComponent;
28  import javax.faces.context.FacesContext;
29  
30  /**
31   * @author Simon Lessard (latest modification by $Author: struberg $)
32   * @version $Revision: 1188415 $ $Date: 2011-10-24 17:13:21 -0500 (Mon, 24 Oct 2011) $
33   * 
34   * @since 2.0
35   */
36  public abstract class VisitContext
37  {
38      public static final Collection<String> ALL_IDS = new AllIdsCollection();
39  
40      public static VisitContext createVisitContext(FacesContext context)
41      {
42          VisitContextFactory factory
43                  = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
44          return factory.getVisitContext(context, null, null);
45      }
46  
47      public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints)
48      {
49          VisitContextFactory factory
50                  = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
51          return factory.getVisitContext(context, ids, hints);
52      }
53  
54      public abstract FacesContext getFacesContext();
55  
56      public abstract Set<VisitHint> getHints();
57  
58      public abstract Collection<String> getIdsToVisit();
59  
60      public abstract Collection<String> getSubtreeIdsToVisit(UIComponent component);
61  
62      public abstract VisitResult invokeVisitCallback(UIComponent component, VisitCallback callback);
63  
64      private static class AllIdsCollection implements Collection<String>, Serializable
65      {
66          public boolean add(String e)
67          {
68              throw new UnsupportedOperationException();
69          }
70  
71          public boolean addAll(Collection<? extends String> c)
72          {
73              throw new UnsupportedOperationException();
74          }
75  
76          public void clear()
77          {
78              throw new UnsupportedOperationException();
79          }
80  
81          public boolean contains(Object o)
82          {
83              throw new UnsupportedOperationException();
84          }
85  
86          public boolean containsAll(Collection<?> c)
87          {
88              throw new UnsupportedOperationException();
89          }
90  
91          public boolean isEmpty()
92          {
93              return false;
94          }
95  
96          public Iterator<String> iterator()
97          {
98              throw new UnsupportedOperationException();
99          }
100 
101         public boolean remove(Object o)
102         {
103             throw new UnsupportedOperationException();
104         }
105 
106         public boolean removeAll(Collection<?> c)
107         {
108             throw new UnsupportedOperationException();
109         }
110 
111         public boolean retainAll(Collection<?> c)
112         {
113             throw new UnsupportedOperationException();
114         }
115 
116         public int size()
117         {
118             throw new UnsupportedOperationException();
119         }
120 
121         public Object[] toArray()
122         {
123             throw new UnsupportedOperationException();
124         }
125 
126         public <T> T[] toArray(T[] a)
127         {
128             throw new UnsupportedOperationException();
129         }
130     }
131 }