EMMA Coverage Report (generated Mon Nov 01 16:48:29 PDT 2010)
[all classes][com.google.caja.service]

COVERAGE SUMMARY FOR SOURCE FILE [ImageHandler.java]

nameclass, %method, %block, %line, %
ImageHandler.java100% (1/1)100% (3/3)53%  (16/30)57%  (4/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ImageHandler100% (1/1)100% (3/3)53%  (16/30)57%  (4/7)
ImageHandler (): void 100% (1/1)100% (3/3)100% (1/1)
apply (URI, CajolingService$Transform, List, ContentHandlerArgs, String, Cont... 100% (1/1)36%  (8/22)40%  (2/5)
canHandle (URI, CajolingService$Transform, List, String, ContentTypeCheck): b... 100% (1/1)100% (5/5)100% (1/1)

1// Copyright 2008 Google Inc. All Rights Reserved.
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6//      http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13 
14package com.google.caja.service;
15 
16import com.google.caja.lexer.FetchedData;
17import com.google.caja.reporting.MessagePart;
18import com.google.caja.reporting.MessageQueue;
19import com.google.caja.reporting.MessageType;
20import com.google.caja.util.Pair;
21 
22import java.io.IOException;
23import java.io.OutputStream;
24import java.net.URI;
25import java.util.List;
26 
27/**
28 * Retrieves image objects and returns them unchecked
29 * to the requester
30 *
31 * @author jasvir@google.com (Jasvir Nagra)
32 */
33public class ImageHandler implements ContentHandler {
34 
35  public boolean canHandle(URI uri, CajolingService.Transform transform,
36      List<CajolingService.Directive> directives,
37      String inputContentType,
38      ContentTypeCheck checker) {
39    return checker.check("image/*", inputContentType);
40  }
41 
42  public Pair<String, String> apply(URI uri,
43                                    CajolingService.Transform trans,
44                                    List<CajolingService.Directive> directives,
45                                    ContentHandlerArgs args,
46                                    String inputContentType,
47                                    ContentTypeCheck checker,
48                                    FetchedData input,
49                                    OutputStream response,
50                                    MessageQueue mq) {
51    try {
52      response.write(input.getByteContent());
53      return Pair.pair(inputContentType, "");
54    } catch (IOException e) {
55      mq.addMessage(
56          MessageType.IO_ERROR,
57          MessagePart.Factory.valueOf(e.getMessage()));
58      return null;
59    }
60  }
61}

[all classes][com.google.caja.service]
EMMA 2.0.5312 (C) Vladimir Roubtsov