blob: 962629e9f9712470a497cef65e0ace02583e696f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
package com.hackingroomba.roombacomm.net;
import java.lang.reflect.*;
import com.hackingroomba.roombacomm.*;
public class DumpMethods {
RoombaCommSerial rcs;
public static void main(String[] args) {
new DumpMethods(args);
}
public DumpMethods(String[] args) {
rcs = new RoombaCommSerial();
if( args.length == 0 ) {
dumpMethods(rcs);
return;
}
String method_name = args[0];
/*
for( int i=1; i<args.length; i++ ) {
String s = args[i];
try { a0 = Integer.parseInt( s );
} catch( Exception e ) { }
}
*/
}
public void dumpMethods(Object obj) {
//Object result = method.invoke(obj, new Object[0]);
//Class c = Class.forName("roombacomm.RoombaComm");
try {
Method m[] = obj.getClass().getMethods();
for( int i=0; i< m.length; i++ )
System.out.println( m[i].getName() +" -- "+ m[i].toString() );
} catch( Exception e ) {
e.printStackTrace();
}
}
public void getMethod( String name, Object obj ) {
try {
String mname = name;
Class[] types = new Class[] {};
Method method = obj.getClass().getMethod(mname, types);
System.out.println("class: "+method.getDeclaringClass());
System.out.println("method: "+method.toString());
} catch( Exception e ) {
e.printStackTrace();
}
}
}
/*
try {
serialEventMethod =
parent.getClass().getMethod("serialEvent",
new Class[] { Serial.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
*/
|