1 | /* |
2 | * VoidCall.java |
3 | * |
4 | * Created on 16.09.2004 |
5 | * |
6 | * eaio: NativeCall - calling operating system methods from Java |
7 | * Copyright (c) 2004-2006 Johann Burkard (<mailto:jb@eaio.com>) |
8 | * <http://eaio.com> |
9 | * |
10 | * Permission is hereby granted, free of charge, to any person obtaining a |
11 | * copy of this software and associated documentation files (the "Software"), |
12 | * to deal in the Software without restriction, including without limitation |
13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
14 | * and/or sell copies of the Software, and to permit persons to whom the |
15 | * Software is furnished to do so, subject to the following conditions: |
16 | * |
17 | * The above copyright notice and this permission notice shall be included |
18 | * in all copies or substantial portions of the Software. |
19 | * |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
23 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
24 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
25 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
26 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
27 | * |
28 | */ |
29 | package com.eaio.nativecall; |
30 | |
31 | /** |
32 | * A VoidCall instance encapsulates an operating system method that returns |
33 | * nothing. |
34 | * |
35 | * @author <a href="mailto:jb@eaio.com">Johann Burkard</a> |
36 | * @version $Id: VoidCall.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ |
37 | */ |
38 | public class VoidCall extends NativeCall { |
39 | |
40 | /** |
41 | * Constructor for VoidCall. |
42 | * |
43 | * @see NativeCall#NativeCall(String) |
44 | */ |
45 | public VoidCall(String function) throws SecurityException, |
46 | IllegalArgumentException, NullPointerException { |
47 | super(function); |
48 | } |
49 | |
50 | /** |
51 | * Constructor for VoidCall. |
52 | * |
53 | * @see NativeCall#NativeCall(String, String) |
54 | */ |
55 | public VoidCall(String module, String function) throws SecurityException, |
56 | IllegalArgumentException, NullPointerException { |
57 | super(module, function); |
58 | } |
59 | |
60 | /** |
61 | * Calls the function. |
62 | * <p> |
63 | * <em>Updates the error code field. See {@link #getLastError()}.</em> |
64 | */ |
65 | public native void executeCall(); |
66 | |
67 | /** |
68 | * Calls the function using the given parameter. |
69 | * <p> |
70 | * <em>Updates the error code field. See {@link #getLastError()}.</em> |
71 | * |
72 | * @param param the parameter, may be <code>null</code> |
73 | * @see #executeCall(Object[]) |
74 | */ |
75 | public void executeCall(Object param) { |
76 | executeCall(new Object[] { param }); |
77 | } |
78 | |
79 | /** |
80 | * Calls the function using the given parameters. |
81 | * <p> |
82 | * <em>Updates the error code field. See {@link #getLastError()}.</em> |
83 | * <p> |
84 | * During this operation, the contents of the array might be changed. |
85 | * |
86 | * @param params the parameter array, may be <code>null</code> |
87 | */ |
88 | public void executeCall(Object[] params) { |
89 | if (params == null || params.length == 0) { |
90 | executeCall(); |
91 | return; |
92 | } |
93 | check(params); |
94 | executeCall0(params); |
95 | } |
96 | |
97 | private native void executeCall0(Object[] params); |
98 | |
99 | } |