1.0.0

javax.comm
Class CommPortIdentifier

java.lang.Object
  extended by javax.comm.CommPortIdentifier

public class CommPortIdentifier
extends java.lang.Object


Field Summary
(package private) static CommDriver commDriver
           
(package private)  CommPort commPort
           
(package private)  boolean currentlyOwned
           
(package private)  java.lang.String currentOwner
           
(package private) static java.util.Hashtable identifiers
           
(package private) static boolean initialized
           
(package private)  java.lang.String name
           
static int pollingTime
           
static int PORT_PARALLEL
           
static int PORT_SERIAL
           
(package private)  int type
           
 
Method Summary
static void addPortName(java.lang.String portName, int portType, CommDriver commDriver)
          Adds portName to the list of ports.
 void addPortOwnershipListener(CommPortOwnershipListener listener)
          Registers an interested application so that it can receive notification of changes in port ownership.
 void closePort()
          Non-Api method.
(package private)  void fireOwnershipEvent(int eventType)
          This method needs to be called when ownership of the port changes.
 java.lang.String getCurrentOwner()
          Returns the owner of the port.
 java.lang.String getName()
          Returns the name of the port.
static CommPortIdentifier getPortIdentifier(CommPort port)
          Obtains the CommPortIdentifier object corresponding to a port that has already been opened by the application.
static CommPortIdentifier getPortIdentifier(java.lang.String portName)
          Obtains a CommPortIdentifier object by using a port name.
static java.util.Enumeration getPortIdentifiers()
          Obtains an enumeration object that contains a CommPortIdentifier object for each port in the system.
 int getPortType()
          Returns the port type.
(package private)  void internalClosePort()
          Non-Api method.
 boolean isCurrentlyOwned()
          Checks whether the port is owned.
 CommPort open(java.io.FileDescriptor fileDescriptor)
          Opens the communications port using a FileDescriptor object on platforms that support this technique.
 CommPort open(java.lang.String appName, int timeout)
           
 void removePortOwnershipListener(CommPortOwnershipListener listener)
          Deregisters a CommPortOwnershipListener registered using addPortOwnershipListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pollingTime

public static final int pollingTime
See Also:
Constant Field Values

PORT_SERIAL

public static final int PORT_SERIAL
See Also:
Constant Field Values

PORT_PARALLEL

public static final int PORT_PARALLEL
See Also:
Constant Field Values

commDriver

static CommDriver commDriver

name

java.lang.String name

currentOwner

java.lang.String currentOwner

currentlyOwned

boolean currentlyOwned

commPort

CommPort commPort

type

int type

initialized

static boolean initialized

identifiers

static java.util.Hashtable identifiers
Method Detail

getPortIdentifiers

public static java.util.Enumeration getPortIdentifiers()
Obtains an enumeration object that contains a CommPortIdentifier object for each port in the system.

Returns:
an Enumeration object that can be used to enumerate all the ports known to the system
See Also:
Enumeration

getPortIdentifier

public static CommPortIdentifier getPortIdentifier(CommPort port)
                                            throws NoSuchPortException
Obtains the CommPortIdentifier object corresponding to a port that has already been opened by the application.

Parameters:
port - a CommPort object obtained from a previous open
Returns:
a CommPortIdentifier object
Throws:
NoSuchPortException - if the port object is invalid

getPortIdentifier

public static CommPortIdentifier getPortIdentifier(java.lang.String portName)
                                            throws NoSuchPortException
Obtains a CommPortIdentifier object by using a port name. The port name may have been stored in persistent storage by the application.

Type Parameters:
CODE - portName name of the port to open
Returns:
a CommPortIdentifier object
Throws:
NoSuchPortException - if the port does not exist

open

public CommPort open(java.lang.String appName,
                     int timeout)
              throws PortInUseException
Throws:
PortInUseException

closePort

public void closePort()
Non-Api method. Called when close() method is called on CommPort object. Required to set port owner to null and propagate CommPortOwnership event.


internalClosePort

void internalClosePort()
Non-Api method. Called when close() method is called on CommPort object. Required to set port owner to null and propagate CommPortOwnership event.


getName

public java.lang.String getName()
Returns the name of the port.

Returns:
the name of the port

getPortType

public int getPortType()
Returns the port type.

Returns:
portType - PORT_SERIAL or PORT_PARALLEL

getCurrentOwner

public java.lang.String getCurrentOwner()
Returns the owner of the port.

Returns:
current owner of the port.

isCurrentlyOwned

public boolean isCurrentlyOwned()
Checks whether the port is owned.

Returns:
boolean true if the port is owned by some application, false if the port is not owned.

addPortName

public static void addPortName(java.lang.String portName,
                               int portType,
                               CommDriver commDriver)
Adds portName to the list of ports.

Parameters:
portName - The name of the port being added
portType - The type of the port being added
driver - The driver representing the port being added
Since:
CommAPI 1.1
See Also:
CommDriver

addPortOwnershipListener

public void addPortOwnershipListener(CommPortOwnershipListener listener)
Registers an interested application so that it can receive notification of changes in port ownership. This includes notification of the following events: The ownershipChange method of the listener registered using addPortOwnershipListener will be called with one of the above events.

Parameters:
listener - a CommPortOwnershipListener callback object

removePortOwnershipListener

public void removePortOwnershipListener(CommPortOwnershipListener listener)
Deregisters a CommPortOwnershipListener registered using addPortOwnershipListener

Parameters:
listener - The CommPortOwnershipListener object that was previously registered using addPortOwnershipListener

fireOwnershipEvent

void fireOwnershipEvent(int eventType)
This method needs to be called when ownership of the port changes.


open

public CommPort open(java.io.FileDescriptor fileDescriptor)
              throws UnsupportedCommOperationException
Opens the communications port using a FileDescriptor object on platforms that support this technique.

Parameters:
fd - The FileDescriptor object used to build a CommPort.
Returns:
a CommPort object.
Throws:
UnsupportedCommOperationException - is thrown on platforms which do not support this functionality.

1.0.0

Copyright (c) 1999, 2007 IBM