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

COVERAGE SUMMARY FOR SOURCE FILE [Pipeline.java]

nameclass, %method, %block, %line, %
Pipeline.java100% (1/1)100% (4/4)100% (36/36)100% (8/8)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Pipeline100% (1/1)100% (4/4)100% (36/36)100% (8/8)
Pipeline (): void 100% (1/1)100% (8/8)100% (3/3)
apply (Object): boolean 100% (1/1)100% (21/21)100% (3/3)
applyStage (Pipeline$Stage, Object): boolean 100% (1/1)100% (4/4)100% (1/1)
getStages (): List 100% (1/1)100% (3/3)100% (1/1)

1// Copyright (C) 2007 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package com.google.caja.util;
16 
17import java.util.ArrayList;
18import java.util.List;
19 
20/**
21 * A pipeline takes an input and passes it through multiple stages, like a
22 * conveyor belt that passes a bucket of spare parts through a factory until
23 * the bucket reaches the end hopefully containing something resembling a
24 * bicycle.
25 *
26 * @author mikesamuel@gmail.com
27 */
28public class Pipeline<T> {
29  private final List<Stage<T>> stages = new ArrayList<Stage<T>>();
30 
31  public final List<Stage<T>> getStages() { return stages; }
32 
33  public final boolean apply(T input) {
34    for (Stage<T> stage : stages) {
35      if (!applyStage(stage, input)) { return false; }
36    }
37    return true;
38  }
39 
40  protected boolean applyStage(Stage<? super T> stage, T input) {
41    return stage.apply(input);
42  }
43 
44  public interface Stage<S> {
45    /**
46     * Operates on an input and returns true iff processing should proceed to
47     * the next stage.
48     */
49    boolean apply(S input);
50  }
51}

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