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