1 package be
.nikiroo
.jvcard
.launcher
;
3 import java
.io
.IOException
;
4 import java
.lang
.reflect
.InvocationTargetException
;
5 import java
.lang
.reflect
.Method
;
8 import be
.nikiroo
.jvcard
.Card
;
11 * This class let you call "optional" methods, that is, methods and classes that
12 * may or may not be present.
15 * It currently offers services for:
17 * <li>remoting support</li>
18 * <li>TUI support</li>
27 * Create a new jVCard server on the given port, then run it.
32 * @throws SecurityException
33 * in case of internal error
34 * @throws NoSuchMethodException
35 * in case of internal error
36 * @throws ClassNotFoundException
37 * in case of internal error
38 * @throws IllegalAccessException
39 * in case of internal error
40 * @throws InstantiationException
41 * in case of internal error
42 * @throws InvocationTargetException
43 * in case of internal error
44 * @throws IllegalArgumentException
45 * in case of internal error
49 @SuppressWarnings("unchecked")
50 static public void runServer(int port
) throws NoSuchMethodException
,
51 SecurityException
, ClassNotFoundException
, InstantiationException
,
52 IllegalAccessException
, IllegalArgumentException
,
53 InvocationTargetException
{
54 @SuppressWarnings("rawtypes")
55 Class serverClass
= Class
.forName("be.nikiroo.jvcard.remote.Server");
56 Method run
= serverClass
.getDeclaredMethod("run", new Class
[] {});
57 run
.invoke(serverClass
.getConstructor(int.class).newInstance(port
));
61 * Start the TUI program.
64 * TRUE to force text mode, FALSE to force the Swing terminal
65 * emulator, null to automatically determine the best choice
67 * the files to show at startup
69 * @throws SecurityException
70 * in case of internal error
71 * @throws NoSuchMethodException
72 * in case of internal error
73 * @throws ClassNotFoundException
74 * in case of internal error
75 * @throws IllegalAccessException
76 * in case of internal error
77 * @throws InstantiationException
78 * in case of internal error
79 * @throws InvocationTargetException
80 * in case of internal error
81 * @throws IllegalArgumentException
82 * in case of internal error
86 @SuppressWarnings("unchecked")
87 static public void startTui(Boolean textMode
, List
<String
> files
)
88 throws NoSuchMethodException
, SecurityException
,
89 ClassNotFoundException
, InstantiationException
,
90 IllegalAccessException
, IllegalArgumentException
,
91 InvocationTargetException
{
92 @SuppressWarnings("rawtypes")
93 Class launcherClass
= Class
94 .forName("be.nikiroo.jvcard.tui.TuiLauncher");
95 Method start
= launcherClass
.getDeclaredMethod("start", new Class
[] {
96 Boolean
.class, List
.class });
97 start
.invoke(launcherClass
.newInstance(), textMode
, files
);
101 * Return the {@link Card} corresponding to the given URL, synchronised if
105 * the jvcard:// with resource name URL (e.g.:
106 * <tt>jvcard://localhost:4444/coworkers</tt>)
108 * @throws SecurityException
109 * in case of internal error
110 * @throws NoSuchMethodException
111 * in case of internal error
112 * @throws ClassNotFoundException
113 * in case of internal error
114 * @throws IllegalAccessException
115 * in case of internal error
116 * @throws InstantiationException
117 * in case of internal error
118 * @throws InvocationTargetException
119 * in case of internal error
120 * @throws IllegalArgumentException
121 * in case of internal error
122 * @throws IOException
123 * in case of IO error
125 @SuppressWarnings("unchecked")
126 static public Card
syncCard(String input
) throws ClassNotFoundException
,
127 NoSuchMethodException
, SecurityException
, InstantiationException
,
128 IllegalAccessException
, IllegalArgumentException
,
129 InvocationTargetException
, IOException
{
130 @SuppressWarnings("rawtypes")
131 Class syncClass
= Class
.forName("be.nikiroo.jvcard.remote.Sync");
132 Method sync
= syncClass
.getDeclaredMethod("sync",
133 new Class
[] { boolean.class });
135 Object o
= syncClass
.getConstructor(String
.class).newInstance(input
);
136 Card card
= (Card
) sync
.invoke(o
, false);