org.apache.shindig.gadgets.features
Class BrowserSpecificFeatureResource

java.lang.Object
  extended by org.apache.shindig.gadgets.features.BrowserSpecificFeatureResource
All Implemented Interfaces:
FeatureResource

public class BrowserSpecificFeatureResource
extends Object
implements FeatureResource

A FeatureResource that supports being supplied only to certain browsers. This is optional functionality, activated by the browser="..." attribute on a <script> element. That attribute's value is interpreted as a comma-separated list of BROWSER-versionKey matchers. BROWSER must match (case-insensitive) the list of UserAgent.Browser enum values eg. "MSIE" or "FIREFOX". versionKey is OPERATORversionNumber, where OPERATOR may be one of: ^ - regex = - exact match >, >=, <, <= - greater than/less than matches [no operator] - exact match If no browser="..." attribute is specified, the resource always matches. Otherwise, if ANY of the browser-versionKey matchers match, the resource matches. In such case, the delegate FeatureResource's content methods are consulted. Otherwise, "" is returned for content. Example: browser="FireFox->=3, MSIE-6.0 would match FireFox 3.x.y (any) and IE 6.0 (only). To activate this capability, you may use the provided Loader class and bind it as your FeatureResourceLoader implementation; or build your own that wraps its resources in BrowserSpecificFeatureResource.


Nested Class Summary
static class BrowserSpecificFeatureResource.Loader
          Simple FeatureResourceLoader implementation that wraps all resource loads in a browser-filtering delegator.
 
Nested classes/interfaces inherited from interface org.apache.shindig.gadgets.features.FeatureResource
FeatureResource.Default, FeatureResource.Simple
 
Constructor Summary
BrowserSpecificFeatureResource(com.google.inject.Provider<UserAgent> uaProvider, FeatureResource delegate, String browserKey)
           
 
Method Summary
 String getContent()
           
 String getDebugContent()
           
 boolean isExternal()
           
 boolean isProxyCacheable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserSpecificFeatureResource

public BrowserSpecificFeatureResource(com.google.inject.Provider<UserAgent> uaProvider,
                                      FeatureResource delegate,
                                      String browserKey)
Method Detail

getContent

public String getContent()
Specified by:
getContent in interface FeatureResource
Returns:
"Normal"-mode content for the feature, eg. obfuscated JS.

getDebugContent

public String getDebugContent()
Specified by:
getDebugContent in interface FeatureResource
Returns:
Debug-mode content for the feature.

isExternal

public boolean isExternal()
Specified by:
isExternal in interface FeatureResource
Returns:
True if the content is actually a URL to be included via <script src>

isProxyCacheable

public boolean isProxyCacheable()
Specified by:
isProxyCacheable in interface FeatureResource
Returns:
True if the JS can be cached by intermediary proxies or not.


Copyright © 2007-2012. All Rights Reserved.