PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/testability-explorer/src/main/java/com/google/test/metric/report/html/SourceLinkerModel.java

http://testability-explorer.googlecode.com/
Java | 43 lines | 17 code | 6 blank | 20 comment | 0 complexity | 69b5628942742bbde7aa105129a9a588 MD5 | raw file
 1/*
 2 * Copyright 2009 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric.report.html;
17
18import java.util.List;
19
20import com.google.test.metric.report.SourceLinker;
21
22import freemarker.template.TemplateMethodModel;
23import freemarker.template.TemplateModelException;
24
25/**
26 * Wrap the {@link com.google.test.metric.report.SourceLinker#buildLineLink(String, int, String)}
27 * method as a Freemarker method.
28 * @author alexeagle@google.com (Alex Eagle)
29 */
30public class SourceLinkerModel implements TemplateMethodModel {
31  private final SourceLinker linker;
32
33  public SourceLinkerModel(SourceLinker linker) {
34    this.linker = linker;
35  }
36
37  public Object exec(List arguments) throws TemplateModelException {
38    String file = (String) arguments.get(0);
39    int lineNumber = Integer.parseInt((String) arguments.get(1));
40    String anchorText = (String) arguments.get(2);
41    return linker.buildLineLink(file, lineNumber, anchorText);
42  }
43}