| 1 | // |
| 2 | // (c) Copyright, Moebius Solutions, 2002 |
| 3 | // |
| 4 | // All Rights Reserved |
| 5 | // |
| 6 | // This material may be reproduced by or for the U. S. Government |
| 7 | // pursuant to the copyright license under the clause at |
| 8 | // DFARS 252.227-7013 (OCT 1988). |
| 9 | // |
| 10 | package com.moesol.generator; |
| 11 | |
| 12 | import java.lang.reflect.*; |
| 13 | |
| 14 | public class MethodCallable extends Callable { |
| 15 | public MethodCallable(Method method) { |
| 16 | this(method.getDeclaringClass(), method); |
| 17 | } |
| 18 | public MethodCallable(Class a_class, Method method) { |
| 19 | m_class = a_class; |
| 20 | m_method = method; |
| 21 | } |
| 22 | public Class getDeclaringClass() { |
| 23 | return m_class; |
| 24 | } |
| 25 | public Class getReturnType() { |
| 26 | return m_method.getReturnType(); |
| 27 | } |
| 28 | public Class[] getParameterTypes() { |
| 29 | return m_method.getParameterTypes(); |
| 30 | } |
| 31 | public Class[] getExceptionTypes() { |
| 32 | return m_method.getExceptionTypes(); |
| 33 | } |
| 34 | public String getName() { |
| 35 | return m_method.getName(); |
| 36 | } |
| 37 | public int getModifiers() { |
| 38 | return m_method.getModifiers(); |
| 39 | } |
| 40 | public boolean isOverloaded() { |
| 41 | // TODO inefficient |
| 42 | // TODO should only be checking native methods, but method is not marked native yet. |
| 43 | // TODO hmm, what to do for overrides? |
| 44 | int number = 0; |
| 45 | Method all_methods[] = m_method.getDeclaringClass().getDeclaredMethods(); |
| 46 | for (int i = 0; i < all_methods.length; i++) { |
| 47 | if (m_method.getName().equals(all_methods[i].getName())) { |
| 48 | number++; |
| 49 | } |
| 50 | } |
| 51 | return number > 1; |
| 52 | } |
| 53 | |
| 54 | public boolean isImpl() { |
| 55 | return getName().indexOf('$') != -1; |
| 56 | } |
| 57 | |
| 58 | Class m_class; |
| 59 | Method m_method; |
| 60 | } |