net.sourceforge.jcapi
Class Jcapi

java.lang.Object
  |
  +--net.sourceforge.jcapi.Jcapi
All Implemented Interfaces:
Capi

public class Jcapi
extends java.lang.Object
implements Capi

Jcapi is a Java wrapper for the CAPI. It uses the Java Native Interface to load a platform dependent shared library which gives access to the Common ISDN API (CAPI20) shared library delivered whith the ISDN adapter device.

© 2002 Holger Gräfe

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Contact to author: holger.graefe@gmx.de

Project website: http://jcapi.sourceforge.net


Constructor Summary
Jcapi()
           
 
Method Summary
 void addListener(int appID, CapiListener listener)
          adds the given reference to a List of CapiListeners that will be notified of CapiEvents for the given application ID.
 CapiMessage createMessage(byte[] msg)
          constructs a new CapiMessage object from a binary message.
 CapiMessage createMessage(int appID, int type, int number)
          constructs a new CapiMessage object.
 java.lang.String getImplementationInfo()
          returns an information about the used implementation of this interface.
 java.lang.String getManufacturer()
          CAPI 2.0 equivalent: CAPI_MANUFACTURER.
 java.lang.String getManufacturer(int controller)
          CAPI 2.0 equivalent: CAPI_MANUFACTURER.
 CapiMessage getMessage(int appID)
          CAPI 2.0 equivalent: CAPI_GET_MESSAGE.
 int getNewMessageNumber()
           
 int getNumberOfControllers()
          CAPI 2.0 equivalent: CAPI_GET_PROFILE with parameter 0.
 byte[] getProfile(int controller)
          CAPI 2.0 equivalent: CAPI_GET_PROFILE with parameter <>0.
 java.lang.String getSerialNumber()
          CAPI 2.0 equivalent: CAPI_GET_SERIAL_NUMBER.
 java.lang.String getSerialNumber(int controller)
          CAPI 2.0 equivalent: CAPI_GET_SERIAL_NUMBER.
 int[] getVersion()
          CAPI 2.0 equivalent: CAPI_GET_VERSION.
 int[] getVersion(int controller)
          CAPI 2.0 equivalent: CAPI_GET_VERSION.
 boolean installed()
          CAPI 2.0 equivalent: CAPI_INSTALLED.
static void main(java.lang.String[] argv)
           
 void putMessage(CapiMessage message)
          CAPI 2.0 equivalent: CAPI_PUT_MESSAGE.
 int register()
          calls the register method with default parameters.
 int register(int maxcon, int maxblocks, int maxlen)
          calls the register method with a default bufsize parameter.
 int register(int bufsize, int maxcon, int maxblocks, int maxlen)
          CAPI 2.0 equivalent: CAPI_REGISTER.
 void release(int appID)
          CAPI 2.0 equivalent: CAPI_RELEASE.
 void removeListener(int appID, CapiListener listener)
          removes a CapiListener previously added with addListener().
 void test()
           
 void test(java.io.PrintWriter out)
           
 void waitForSignal(int appID)
          CAPI 2.0 equivalent: CAPI_WAIT_FOR_SIGNAL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jcapi

public Jcapi()
Method Detail

installed

public boolean installed()
                  throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_INSTALLED.

This method always returns a true value or even throws an exception if CAPI 2.0 is not installed correctly.

Specified by:
installed in interface Capi
Following copied from interface: org.capi.capi20.Capi
Returns:
true if CAPI 2.0 is installed and ready

getManufacturer

public java.lang.String getManufacturer()
                                 throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_MANUFACTURER.
Specified by:
getManufacturer in interface Capi
Following copied from interface: org.capi.capi20.Capi
Returns:
the manufacturer identification of the underlying CAPI 2.0 (and probably of the device)

getManufacturer

public java.lang.String getManufacturer(int controller)
                                 throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_MANUFACTURER.
Specified by:
getManufacturer in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
controller - the number of the controller requested
Returns:
the manufacturer identification of the underlying CAPI 2.0 (and probably of the device)

getImplementationInfo

public java.lang.String getImplementationInfo()
Description copied from interface: Capi
returns an information about the used implementation of this interface.
Specified by:
getImplementationInfo in interface Capi
Following copied from interface: org.capi.capi20.Capi
Returns:
the description of the current implementation

getSerialNumber

public java.lang.String getSerialNumber()
                                 throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_SERIAL_NUMBER.
Specified by:
getSerialNumber in interface Capi
Following copied from interface: org.capi.capi20.Capi
Returns:
the serial number coded as a String

getSerialNumber

public java.lang.String getSerialNumber(int controller)
                                 throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_SERIAL_NUMBER.
Specified by:
getSerialNumber in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
controller - the number of the controller requested
Returns:
the serial number coded as a String

getVersion

public int[] getVersion()
                 throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_VERSION.
Specified by:
getVersion in interface Capi
Following copied from interface: org.capi.capi20.Capi
Returns:
an array of four integers: major CAPI version (should be 2), minor CAPI version (should be 0), major and minor manufacturer version

getVersion

public int[] getVersion(int controller)
                 throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_VERSION.
Specified by:
getVersion in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
controller - the number of the controller requested
Returns:
an array of four integers: major CAPI version (should be 2), minor CAPI version (should be 0), major and minor manufacturer version

createMessage

public CapiMessage createMessage(int appID,
                                 int type,
                                 int number)
                          throws CapiException
Description copied from interface: Capi
constructs a new CapiMessage object.
Specified by:
createMessage in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()
type - the message type, which correspond with the CAPI message fields "command" and "subcommand"
number - the identification number of this message
Returns:
the new CapiMessage object

createMessage

public CapiMessage createMessage(byte[] msg)
                          throws CapiException
Description copied from interface: Capi
constructs a new CapiMessage object from a binary message. Memory pointers (Data, Data handle) are not evaluated, but stored.
Specified by:
createMessage in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
msg - the binary CAPI 2.0 message
Returns:
the new CapiMessage object

register

public int register()
             throws CapiException
calls the register method with default parameters.
Returns:
the application identification number

register

public int register(int maxcon,
                    int maxblocks,
                    int maxlen)
             throws CapiException
calls the register method with a default bufsize parameter.
Specified by:
register in interface Capi
Returns:
the application identification number

register

public int register(int bufsize,
                    int maxcon,
                    int maxblocks,
                    int maxlen)
             throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_REGISTER.
Specified by:
register in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
bufsize - the size of the buffer, typical bufsize = 1024 + (1024 * maxcon)
maxcon - the maximum number of logical connections
maxblocks - the maximum number of received data blocks
maxlen - the maximum size of data block to be transmitted and received
Returns:
an unique identification number for this application

release

public void release(int appID)
             throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_RELEASE.
Specified by:
release in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()

getNumberOfControllers

public int getNumberOfControllers()
                           throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_PROFILE with parameter 0.
Specified by:
getNumberOfControllers in interface Capi
Following copied from interface: org.capi.capi20.Capi
Returns:
the number of installed controllers

getProfile

public byte[] getProfile(int controller)
                  throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_PROFILE with parameter <>0.
Specified by:
getProfile in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
controller - the number of the controller; a value of 0 may cause an exception
Returns:
a byte array holding the profile of the requested controller

putMessage

public void putMessage(CapiMessage message)
                throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_PUT_MESSAGE.
Specified by:
putMessage in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()
msg - the CapiMessage to be sent to the CAPI

getMessage

public CapiMessage getMessage(int appID)
                       throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_GET_MESSAGE.
Specified by:
getMessage in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()
Returns:
the CapiMessage received by the CAPI

addListener

public void addListener(int appID,
                        CapiListener listener)
Description copied from interface: Capi
adds the given reference to a List of CapiListeners that will be notified of CapiEvents for the given application ID.
Specified by:
addListener in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()

removeListener

public void removeListener(int appID,
                           CapiListener listener)
Description copied from interface: Capi
removes a CapiListener previously added with addListener().
Specified by:
removeListener in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()

waitForSignal

public void waitForSignal(int appID)
                   throws CapiException
Description copied from interface: Capi
CAPI 2.0 equivalent: CAPI_WAIT_FOR_SIGNAL.
Specified by:
waitForSignal in interface Capi
Following copied from interface: org.capi.capi20.Capi
Parameters:
appID - the application identification number assigned by register()

getNewMessageNumber

public int getNewMessageNumber()

test

public void test(java.io.PrintWriter out)

test

public void test()

main

public static void main(java.lang.String[] argv)