%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.infrared.aspects.api.ApiContext |
|
|
1 | /* |
|
2 | * Copyright 2005 Tavant Technologies and Contributors |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of 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, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | * |
|
16 | * |
|
17 | * |
|
18 | * Original Author: binil.thomas (Tavant Technologies) |
|
19 | * Contributor(s): prashant.nair; |
|
20 | * |
|
21 | */ |
|
22 | package net.sf.infrared.aspects.api; |
|
23 | ||
24 | import java.util.StringTokenizer; |
|
25 | ||
26 | import net.sf.infrared.aspects.AbstractExecutionContext; |
|
27 | ||
28 | ||
29 | /** |
|
30 | * |
|
31 | * @author binil.thomas |
|
32 | * @author prashant.nair |
|
33 | */ |
|
34 | public class ApiContext extends AbstractExecutionContext { |
|
35 | ||
36 | public static final String DELIMITER = ":"; |
|
37 | ||
38 | private String methodName; |
|
39 | ||
40 | private String className; |
|
41 | ||
42 | public ApiContext(String className, String methodName, String layer) { |
|
43 | 0 | super(layer); |
44 | 0 | this.className = className; |
45 | 0 | this.methodName = methodName; |
46 | 0 | } |
47 | ||
48 | public ApiContext(String name, String layer) { |
|
49 | 0 | super(layer); |
50 | ||
51 | 0 | if (name == null) { |
52 | 0 | throw new IllegalArgumentException( |
53 | "The name argument for the ApiContext constructor cannot be null"); |
|
54 | } |
|
55 | ||
56 | //@TODO why store classname and method name seperately? instead store name |
|
57 | 0 | StringTokenizer st = new StringTokenizer(name, DELIMITER); |
58 | 0 | if (st.countTokens() != 2) { |
59 | 0 | throw new IllegalArgumentException( |
60 | "The name argument for the ApiContext constructor is invalid"); |
|
61 | } |
|
62 | ||
63 | 0 | this.className = st.nextToken(); |
64 | 0 | this.methodName = st.nextToken(); |
65 | 0 | } |
66 | ||
67 | public String getName() { |
|
68 | 0 | return className + DELIMITER + methodName; |
69 | } |
|
70 | ||
71 | public boolean equals(Object o) { |
|
72 | 0 | if (o == null) { |
73 | 0 | return false; |
74 | } |
|
75 | ||
76 | 0 | if (this == o) { |
77 | 0 | return true; |
78 | } |
|
79 | ||
80 | 0 | if (!(o instanceof ApiContext)) { |
81 | 0 | return false; |
82 | } |
|
83 | ||
84 | 0 | ApiContext other = (ApiContext) o; |
85 | ||
86 | 0 | return this.methodName.equals(other.methodName) && class="keyword">this.getLayer().equals(other.getLayer()) |
87 | && this.className.equals(other.className); |
|
88 | } |
|
89 | ||
90 | public int hashCode() { |
|
91 | 0 | return 7 * methodName.hashCode() + 11 * className.hashCode() + 13 * getLayer().hashCode(); |
92 | } |
|
93 | ||
94 | public String toString() { |
|
95 | //return "[" + getLayer() + "] " + className + DELIMITER + methodName; |
|
96 | 0 | return className + DELIMITER + methodName + " [" + getLayer() + "] "; |
97 | } |
|
98 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |