Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements. See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership. The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License. You may obtain a copy of the License at
   *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations under the License.
  */
 package org.apache.shindig.gadgets;
 
 
 import  com.google.common.collect.Lists;
 import  com.google.common.collect.Sets;
 
 import java.util.List;
 import java.util.Set;

Intermediary representation of all state associated with processing of a single gadget request.
 
 public class Gadget {
   private GadgetContext context;
   private GadgetSpec spec;
   private View currentView;
   private Set<StringaddedFeatures;
   private Set<StringremovedFeatures;

  

Parameters:
context The request that the gadget is being processed for.
 
   public Gadget setContext(GadgetContext context) {
     this. = context;
     return this;
   }
 
   public GadgetContext getContext() {
     return ;
   }

  

Parameters:
registry The gadget feature registry to use to find dependent features.
 
     this. = registry;
     return this;
   }

  

Parameters:
spec The spec for the gadget that is being processed.
 
   public Gadget setSpec(GadgetSpec spec) {
     this. = spec;
     return this;
   }
 
   public GadgetSpec getSpec() {
     return ;
   }

  

Parameters:
preloads The preloads for the gadget that is being processed.
 
   public Gadget setPreloads(Collection<PreloadedDatapreloads) {
     this. = preloads;
     return this;
   }
 
     return ;
   }

  
List of all features this spec depends on (including all transitive dependencies).
 
   private List<StringallGadgetFeatures;
   public synchronized List<StringgetAllFeatures() {
     if ( == null) {
       if ( != null) {
         = Lists.newArrayList();
        for (GadgetFeature gadgetFeature :
               .getFeatures(
                   this..getModulePrefs().getFeatures().keySet())) {
          .add(gadgetFeature.getName());
        }
        // now all features are in reverse order of dependency. So reverse the list.
        Collections.reverse();
      } else {
        throw new IllegalStateException(
            "setGadgetFeatureRegistry must be called before Gadget.getAllFeatures()");
      }
    }
    return ;
  }
  public Gadget setCurrentView(View currentView) {
    this. = currentView;
    return this;
  }

  

Returns:
The View applicable for the current request.
  public View getCurrentView() {
    return ;
  }

  
Convenience function for getting the locale spec for the current context. Identical to: Locale locale = gadget.getContext().getLocale(); gadget.getSpec().getModulePrefs().getLocale(locale);
  public LocaleSpec getLocale() {
  }
  
  public void addFeature(String name) {
    if ( == null) {
       = Sets.newHashSet();
    }
    
    .add(name);
  }
  
  public void removeFeature(String name) {
    if ( == null) {
       = Sets.newHashSet();
    }
    
    .add(name);
  }
  
  public Set<StringgetAddedFeatures() {
    if ( == null) {
      return Collections.<String>emptySet();
    }
    
    return ;
  }
  public Set<StringgetRemovedFeatures() {
    if ( == null) {
      return Collections.<String>emptySet();
    }
    
    return ;
  }

  
Should the gadget content be sanitized on output

Returns:
  public boolean sanitizeOutput() {
    return (getCurrentView() != null &&
  }
New to GrepCode? Check out our FAQ X