1 package com.neuronrobotics.sdk.common;
3 import java.lang.reflect.InvocationTargetException;
4 import java.lang.reflect.Method;
5 import java.util.ArrayList;
9 Method methodConnect =
null;
10 Method methodDisconnect =
null;
11 boolean hasGetName =
false;
12 boolean hasIsAvailible=
false;
13 Method methodGetName =
null;
14 Method isAvaibleMeth=
null;
16 public DMDevice(Object o)
throws NoSuchMethodException, SecurityException {
18 throw new RuntimeException(
"This object is not wrappable! ");
20 methodConnect =
getWrapped().getClass().getMethod(
"connect",
null);
21 methodDisconnect =
getWrapped().getClass().getMethod(
"disconnect",
null);
31 if (methodGetName ==
null)
33 methodGetName =
getWrapped().getClass().getMethod(
"getName",
null);
35 }
catch (Exception e) {
36 return super.getScriptingName();
39 return super.getScriptingName();
41 if (methodGetName ==
null)
42 return super.getScriptingName();
44 super.setScriptingName( (String) methodGetName.invoke(
getWrapped(),
null));
45 }
catch (Exception e) {
46 return super.getScriptingName();
48 return super.getScriptingName();
54 return new ArrayList<String>();
61 }
catch (Exception e) {
75 if(isAvaibleMeth==
null) {
77 isAvaibleMeth =
getWrapped().getClass().getMethod(
"isAvailable",
null);
78 }
catch (Exception e) {
83 return (
boolean) isAvaibleMeth.invoke(
getWrapped(),
null);
84 }
catch (Exception e) {
94 Object value = methodConnect.invoke(
getWrapped(),
null);
96 return (Boolean) value;
97 }
catch (Exception e) {
101 }
catch (Exception e) {
115 for (Method method : clazz.getClass().getMethods()) {
116 if (method.getName().equals(methodName)) {
boolean connectDeviceImp()
static boolean wrappable(Object o)
ArrayList< String > getNamespacesImp()
String getScriptingName()
static boolean methodExists(Object clazz, String methodName)
void disconnectDeviceImp()
void setWrapped(Object wrapped)