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   * @since 2.0
32   */
33  public abstract class VisitContext
34  {
35      public static final Collection<String> ALL_IDS = new AllIdsCollection();
36  
37      public static VisitContext createVisitContext(FacesContext context)
38      {
39          VisitContextFactory factory
40                  = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
41          return factory.getVisitContext(context, null, null);
42      }
43  
44      public static VisitContext createVisitContext(FacesContext context, Collection<String> ids, Set<VisitHint> hints)
45      {
46          VisitContextFactory factory
47                  = (VisitContextFactory) FactoryFinder.getFactory(FactoryFinder.VISIT_CONTEXT_FACTORY);
48          return factory.getVisitContext(context, ids, hints);
49      }
50  
51      public abstract FacesContext getFacesContext();
52  
53      public abstract Set<VisitHint> getHints();
54  
55      public abstract Collection<String> getIdsToVisit();
56  
57      public abstract Collection<String> getSubtreeIdsToVisit(UIComponent component);
58  
59      public abstract VisitResult invokeVisitCallback(UIComponent component, VisitCallback callback);
60  
61      private static class AllIdsCollection implements Collection<String>, Serializable
62      {
63          public boolean add(String e)
64          {
65              throw new UnsupportedOperationException();
66          }
67  
68          public boolean addAll(Collection<? extends String> c)
69          {
70              throw new UnsupportedOperationException();
71          }
72  
73          public void clear()
74          {
75              throw new UnsupportedOperationException();
76          }
77  
78          public boolean contains(Object o)
79          {
80              throw new UnsupportedOperationException();
81          }
82  
83          public boolean containsAll(Collection<?> c)
84          {
85              throw new UnsupportedOperationException();
86          }
87  
88          public boolean isEmpty()
89          {
90              return false;
91          }
92  
93          public Iterator<String> iterator()
94          {
95              throw new UnsupportedOperationException();
96          }
97  
98          public boolean remove(Object o)
99          {
100             throw new UnsupportedOperationException();
101         }
102 
103         public boolean removeAll(Collection<?> c)
104         {
105             throw new UnsupportedOperationException();
106         }
107 
108         public boolean retainAll(Collection<?> c)
109         {
110             throw new UnsupportedOperationException();
111         }
112 
113         public int size()
114         {
115             throw new UnsupportedOperationException();
116         }
117 
118         public Object[] toArray()
119         {
120             throw new UnsupportedOperationException();
121         }
122 
123         public <T> T[] toArray(T[] a)
124         {
125             throw new UnsupportedOperationException();
126         }
127     }
128 }