/* * IntCall.java * * Created on 07.09.2004. * * eaio: NativeCall - calling operating system methods from Java * Copyright (c) 2004-2006 Johann Burkard () * * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * */ package com.eaio.nativecall; /** * An IntCall instance encapsulates an operating system method that returns * an integer. * * @author Johann Burkard * @version $Id: IntCall.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ */ public class IntCall extends NativeCall { /** * Constructor for IntCall. * * @see NativeCall#NativeCall(String) */ public IntCall(String function) throws SecurityException, IllegalArgumentException, NullPointerException { super(function); } /** * Constructor for IntCall. * * @see NativeCall#NativeCall(String, String) */ public IntCall(String module, String function) throws SecurityException, IllegalArgumentException, NullPointerException { super(module, function); } /** * Returns false if calling {@link #executeCall()} returned * 0, true otherwise. *

* Updates the error code field. See {@link #getLastError()}. * * @return true or false */ public boolean executeBooleanCall() { return executeCall() == 0 ? false : true; } /** * Returns false if calling {@link #executeCall(Object)} * returned 0, true otherwise. *

* Updates the error code field. See {@link #getLastError()}. * * @param param the parameter, may be null * @return true or false * @see #executeBooleanCall(Object[]) */ public boolean executeBooleanCall(Object param) { return executeCall(param) == 0 ? false : true; } /** * Returns false if calling * {@link #executeCall(Object[])} returned 0, true otherwise. *

* Updates the error code field. See {@link #getLastError()}. *

* During this operation, the contents of the array might be changed. * * @param params the parameter array, may be null * @return true or false */ public boolean executeBooleanCall(Object[] params) { return executeCall(params) == 0 ? false : true; } /** * Calls the function, returning its output. *

* Updates the error code field. See {@link #getLastError()}. * * @return an int */ public native int executeCall(); /** * Calls the function using the given parameter. *

* Updates the error code field. See {@link #getLastError()}. * * @param param the parameter, may be null * @return an int * @see #executeCall(Object[]) */ public int executeCall(Object param) { return executeCall(new Object[] { param }); } /** * Calls the function using the given parameters. *

* Updates the error code field. See {@link #getLastError()}. *

* During this operation, the contents of the array might be changed. * * @param params the parameter array, may be null * @return an int */ public int executeCall(Object[] params) { if (params == null || params.length == 0) { return executeCall(); } check(params); return executeCall0(params); } private native int executeCall0(Object[] params); }