com.google.caja.service
Class InnocentHandler

java.lang.Object
  extended by com.google.caja.service.AbstractCajolingHandler
      extended by com.google.caja.service.InnocentHandler
All Implemented Interfaces:
ContentHandler

public class InnocentHandler
extends AbstractCajolingHandler

Retrieves javascript files and cajoles them

Author:
jasvir@google.com (Jasvir Nagra)

Field Summary
 
Fields inherited from class com.google.caja.service.AbstractCajolingHandler
buildInfo, hostedService, uriFetcher
 
Constructor Summary
InnocentHandler(BuildInfo buildInfo)
           
 
Method Summary
 Pair<java.lang.String,java.lang.String> apply(java.net.URI uri, CajolingService.Transform transform, java.util.List<CajolingService.Directive> directives, ContentHandlerArgs args, java.lang.String inputContentType, ContentTypeCheck checker, FetchedData input, java.io.OutputStream response, MessageQueue mq)
          Reads content from stream and writes it to response.
 boolean canHandle(java.net.URI uri, CajolingService.Transform transform, java.util.List<CajolingService.Directive> directives, java.lang.String inputContentType, ContentTypeCheck checker)
          Returns if this content handler can check the given uri and ensure it has the correct contentType.
private  void innocentJs(java.net.URI inputUri, CharProducer cp, java.lang.Appendable output, java.lang.String jsonpCallback, MessageQueue mq)
           
 
Methods inherited from class com.google.caja.service.AbstractCajolingHandler
checkIdentifier, getReturnedContentParams, makeUriPolicy, renderAsJSON, renderJavascript
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InnocentHandler

public InnocentHandler(BuildInfo buildInfo)
Method Detail

canHandle

public boolean canHandle(java.net.URI uri,
                         CajolingService.Transform transform,
                         java.util.List<CajolingService.Directive> directives,
                         java.lang.String inputContentType,
                         ContentTypeCheck checker)
Description copied from interface: ContentHandler
Returns if this content handler can check the given uri and ensure it has the correct contentType. Testing contentType equality is done using checker

Specified by:
canHandle in interface ContentHandler
Specified by:
canHandle in class AbstractCajolingHandler
Parameters:
uri - URI of content
transform - Type of rewriting to perform
inputContentType - The actual input content-type
checker - Used to check whether two content-types are compatible
Returns:
true if this content-handler is appropriate for this URL and content-type

apply

public Pair<java.lang.String,java.lang.String> apply(java.net.URI uri,
                                                     CajolingService.Transform transform,
                                                     java.util.List<CajolingService.Directive> directives,
                                                     ContentHandlerArgs args,
                                                     java.lang.String inputContentType,
                                                     ContentTypeCheck checker,
                                                     FetchedData input,
                                                     java.io.OutputStream response,
                                                     MessageQueue mq)
                                              throws UnsupportedContentTypeException
Description copied from interface: ContentHandler
Reads content from stream and writes it to response. Checks to ensure that content has type compatible with contentType if fetched from uri

Specified by:
apply in interface ContentHandler
Specified by:
apply in class AbstractCajolingHandler
Parameters:
uri - URI of content
transform - Type of rewriting to perform
args - Handler-specific arguments
inputContentType - The actual input content-type
checker - Used to check whether two content-types are compatible
input - content from uri
response - writes modified content to user
mq - receives status and error messages
Returns:
the content-type and content-encoding of the resulting output
Throws:
UnsupportedContentTypeException

innocentJs

private void innocentJs(java.net.URI inputUri,
                        CharProducer cp,
                        java.lang.Appendable output,
                        java.lang.String jsonpCallback,
                        MessageQueue mq)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0