diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-08-27 17:16:18 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-08-27 17:16:18 +0000 |
commit | a942ffadee0fe9fd385decdf818ad6baae8c99b3 (patch) | |
tree | d500fbdba7379631b0591a19417c7c3f3df29194 /src/main/java/org/gnunet/util/RunaboutUtil.java | |
parent | 6be9a1ed1b7847c795cb700e3e0bd87824fc0573 (diff) | |
download | gnunet-java-a942ffadee0fe9fd385decdf818ad6baae8c99b3.tar.gz gnunet-java-a942ffadee0fe9fd385decdf818ad6baae8c99b3.zip |
- adapted source tree structure to gradle/maven conventions
- added gradle wrapper
- fixes to adapt to GNUnet changes (new time unit, ...)
- helper process in util
- started implementing testbed
- skeleton for voting tools
- use new mq api
- implemented some more transport api
- mesh
Diffstat (limited to 'src/main/java/org/gnunet/util/RunaboutUtil.java')
-rw-r--r-- | src/main/java/org/gnunet/util/RunaboutUtil.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/main/java/org/gnunet/util/RunaboutUtil.java b/src/main/java/org/gnunet/util/RunaboutUtil.java new file mode 100644 index 0000000..a82dc0a --- /dev/null +++ b/src/main/java/org/gnunet/util/RunaboutUtil.java | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2011, 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | package org.gnunet.util; | ||
22 | |||
23 | import org.gnunet.construct.MessageLoader; | ||
24 | import org.grothoff.Runabout; | ||
25 | |||
26 | import java.lang.reflect.Method; | ||
27 | import java.util.ArrayList; | ||
28 | |||
29 | |||
30 | /** | ||
31 | * Utility methods for the runabout. | ||
32 | */ | ||
33 | public class RunaboutUtil { | ||
34 | public static ArrayList<Class> getRunaboutVisitees(Runabout r) { | ||
35 | Class rc = r.getClass(); | ||
36 | ArrayList<Class> ret = new ArrayList<Class>(5); | ||
37 | for (Method m : rc.getMethods()) { | ||
38 | if (!(m.getName().equals("visit") && m.getParameterTypes().length == 1)) { | ||
39 | continue; | ||
40 | } | ||
41 | ret.add(m.getParameterTypes()[0]); | ||
42 | } | ||
43 | return ret; | ||
44 | } | ||
45 | |||
46 | @SuppressWarnings("unchecked") | ||
47 | public static int[] getRunaboutMessageTypes(Runabout r) { | ||
48 | ArrayList<Class> visitees = getRunaboutVisitees(r); | ||
49 | int[] msgtypes = new int[visitees.size()]; | ||
50 | for (int i = 0; i < visitees.size(); ++i) { | ||
51 | msgtypes[i] = MessageLoader.getUnionTag(GnunetMessage.Body.class, visitees.get(i)); | ||
52 | } | ||
53 | return msgtypes; | ||
54 | } | ||
55 | } | ||