Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package javax.faces.component.visit;
 
 import java.util.Set;
 

A context object that is used to hold state relating to performing a component tree visit.

 
 abstract public class VisitContext {
 
     // Design notes: The VisitContext contract could be defined
     // as an interface.  However, there is the potential that we
     // may need to add new methods in the future, so leaving as 
     // an abstract class in order to have room to grow.
     // 
     // Since we are an abstract class rather than an interface,
     // we could provide implementations of of some of the simpler
     // methods (eg. getFacesContext() and getHints()) to avoid 
     // duplicating this code in VisitContext implementations.
     // However, doing so would mean that "wrapping" VisitContext
     // implementations would be forced to pick up such implementations,
     // so going with a pure contract (no implementation).
 
    

This unmodifiable Collection is returned by getIdsToVisit() and getSubtreeIdsToVisit() in cases where all ids should be visited.

To simplify logic for visitTree() implementations, this Collection always returns false for isEmpty. All other methods throw UnsupportedOperationException.

Since:
2.0
 
     // Note: We cannot use Collections.emptyList() as that returns
     // a shared instance - we want to unique instance to allow for
     // identity tests.
    static public final Collection<StringALL_IDS = 
        new AbstractCollection<String>() {
            @Override
            public Iterator<Stringiterator() {
                throw new UnsupportedOperationException(
                    "VisitContext.ALL_IDS does not support this operation");
            }
            @Override
            public int size() {
                throw new UnsupportedOperationException(
                    "VisitContext.ALL_IDS does not support this operation");
            }
            @Override
            public boolean isEmpty() {
                return false;
            }
        };

    

Returns the FacesContext for the current request.

Since:
2.0
    abstract public FacesContext getFacesContext();

    

Returns the ids of the components to visit.

In the case of a full tree visit, this method returns the ALL_IDS collection. Otherwise, if a partial visit is beign performed, returns a modifiable collection containing the client ids of the components that should be visited.

    abstract public Collection<StringgetIdsToVisit();

    

Given a javax.faces.component.NamingContainer component, returns the client ids of any components underneath the NamingContainer that should be visited.

This method is called by NamingContainer visitTree() implementations to determine whether the NamingContainer contains components to be visited. In the case where no such components exist, the NamingContainer can short-circuit the tree visit and avoid descending into child subtrees.

In addition, iterating components such as UIData may be able to use the returned ids to determine which iterated states (ie. rows) need to be visited. This allows the visit traversal to be contstrained such only those rows that contain visit targets need to be traversed.

Parameters:
component a NamingContainer component
Returns:
an unmodifiable Collection containing the client ids of any components underneath the NamingContainer that are known to be targets of the tree visit. If no such components exist, returns an empty Collection. If all components underneath the NamingContainer should be visited, returns the VisitContext.ALL_IDS collection.
Throws:
java.lang.IllegalArgumentException if component is not an instance of NamingContainer
    abstract public Collection<StringgetSubtreeIdsToVisit(UIComponent component);

    

Called by UIComponent.visitTree() to visit a single component.

Parameters:
component the component to visit
callback the VisitCallback to call
Returns:
a VisitResult value that indicates whether to continue visiting the component's subtree, skip visiting the component's subtree or abort the visit altogether.
    abstract public VisitResult invokeVisitCallback(UIComponent component
                                                    VisitCallback callback); 

    

Returns hints that influence the behavior of the tree visit.

Interested parties, such as UIComponent.visitTree() implementations, may check to see whether a particular hint is present by calling VisitContext.getHints().contains(), passing in one of the hints defined by VisitHint.

Returns:
a non-empty, unmodifiable collection of VisitHints
    abstract public Set<VisitHintgetHints();


    

Returns a VisitContext instance that is initialized with the specified ids and hintsfor use with javax.faces.component.UIComponent.visitTree(javax.faces.component.visit.VisitContext,javax.faces.component.visit.VisitCallback).

Parameters:
context the FacesContext for the current request
ids the client ids of the components to visit. If null, all components will be visited.
hints the VisitHints to apply to the visit. If null, no hints are applied.
Returns:
a VisitContext instance that is initialized with the specified ids and hints.
    public static VisitContext createVisitContext(FacesContext context,
                                                  Collection<Stringids,
                                                  Set<VisitHinthints) {
        VisitContextFactory factory = (VisitContextFactory)
                FactoryFinder.getFactory(.);
        return factory.getVisitContext(contextidshints);
    }

    

Creates a VisitContext instance for use with UIComponent.visitTree(). This method can be used to obtain a VisitContext instance when all components should be visited with the default visit hints.

Parameters:
context the FacesContext for the current request
Returns:
a VisitContext instance
    public static VisitContext createVisitContext(FacesContext context) {
        return createVisitContext(contextnullnull);
        
    }
    
New to GrepCode? Check out our FAQ X