PageRenderTime 48ms CodeModel.GetById 44ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/testability-explorer/src/main/java/com/google/test/metric/method/op/turing/MethodInvocation.java

http://testability-explorer.googlecode.com/
Java | 79 lines | 48 code | 13 blank | 18 comment | 1 complexity | 4e56359b9020d1666551e5cea34932a3 MD5 | raw file
 1/*
 2 * Copyright 2007 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.method.op.turing;
17
18import com.google.test.metric.TestabilityVisitor;
19import com.google.test.metric.Variable;
20
21import java.util.List;
22
23public class MethodInvocation extends Operation {
24
25  private final String name;
26  private final String clazzName;
27  private final Variable methodThis;
28  private final List<Variable> parameters;
29  private final Variable returnVariable;
30
31  public MethodInvocation(int lineNumber, String clazz, String name,
32      Variable methodThis, List<Variable> parameters,
33      Variable returnVariable) {
34    super(lineNumber);
35    this.clazzName = clazz;
36    this.name = name;
37    this.methodThis = methodThis;
38    this.parameters = parameters;
39    this.returnVariable = returnVariable;
40  }
41
42  public List<Variable> getParameters() {
43    return parameters;
44  }
45
46  public String getName() {
47    return name;
48  }
49
50  public String getOwner() {
51    return clazzName;
52  }
53
54  @Override
55  public String toString() {
56    return clazzName + ":" + name;
57  }
58
59  @Override
60  public void visit(TestabilityVisitor.Frame visitor) {
61    visitor.recordMethodCall(clazzName, getLineNumber(), name,
62        methodThis, parameters, returnVariable);
63  }
64
65  public Variable getMethodThis() {
66    return methodThis;
67  }
68
69  /**
70   * @return true iff this is an invocation of methodName in a class className
71   */
72  public boolean equals(String className, String methodName) {
73    return className.equals(clazzName) && methodName.equals(name);
74  }
75
76  public String getClazzName() {
77    return clazzName;
78  }
79}