Inspector | Message | Severity | Location |
---|---|---|---|
Java Inspector 048 | Copyrights information should be present in each file. | 1 | |
Java Inspector 049 | Use a Collection instead of arrays Object[] | 2 | 64:14 |
Java Inspector 049 | Use a Collection instead of arrays Object[] | 2 | 65:14 |
Java Inspector 085 | Do not declare runtime exceptions in the throws clause. | 2 | 48:5 |
Java Inspector 089 | Undocumented top level type | 2 | 29:1 |
Java Inspector 089 | Undocumented constructor | 2 | 34:5 |
Java Inspector 089 | Undocumented constructor | 2 | 41:5 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 71:13 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 73:20 |
1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
22 */
23package biz.hammurapi.eval;
24
25import java.lang.reflect.InvocationTargetException;
26import java.lang.reflect.Method;
27
28
29public class MethodEntry {
30 Object object;
31 Method method;
32 String name;
33
34 public MethodEntry(Object object, Method method) {
35 super();
36 this.object = object;
37 this.method = method;
38 this.name = method.getName();
39 }
40
41 public MethodEntry(Object object, Method method, String name) {
42 super();
43 this.object = object;
44 this.method = method;
45 this.name = name;
46 }
47
48 Object invoke(Object[] args) throws EvaluationException {
49 try {
50 return method.invoke(object, args);
51 } catch (IllegalAccessException e) {
52 throw new EvaluationException(e);
53 } catch (InvocationTargetException e) {
54 throw new EvaluationException(e);
55 }
56 }
57
58 /**
59 * @param otherEntry
60 * @return 0 - neither is more specific, 1 - this one is more specific
61 * -1 - the other one is more specific.
62 */
63 int isMoreSpecific(MethodEntry otherEntry) {
64 Class[] otherTypes = otherEntry.method.getParameterTypes();
65 Class[] types = method.getParameterTypes();
66 if (otherTypes.length!=types.length) {
67 return 0;
68 }
69
70 for (int i=0; i<types.length; i++) {
71 if (types[i].equals(otherTypes[i])) {
72 continue;
73 } else if (types[i].isAssignableFrom(otherTypes[i])) {
74 return -1;
75 } else if (otherTypes[i].isAssignableFrom(types[i])) {
76 return 1;
77 }
78 }
79
80 return 0;
81 }
82}