com.sun.comm
Class PathBundle

java.lang.Object
  extended bycom.sun.comm.PathBundle
Direct Known Subclasses:
PlatformPortBundle

public class PathBundle
extends java.lang.Object

Used to conglomerate valid physical ports device links (only) into a list containing File objects and descriptive information.

The named object is the root object. Paths representing either single files or directories can be added via the add() method. Non-existent paths are ignored. For each file added, singly, in bulk and collectively a new PhyPort object is added to the root PhyPort's list.

At any time, the list of accumulated PathBundle stored in the root object can be accessed, each containing a File representing a single file in the filesystem, and the type of port that it was associated with at add() time.

Usage:

PathBundle ports = new PathBundle();
ports.add("/dev/term", CommPortIdentifier.PORT_SERIAL);
ports.add("/dev/cua/a", CommPortIdentifier.PORT_SERIAL);
In the above lines, the first 'add()' adds a PathBundle object to the master list for each file found in /dev/term
The second 'add()' adds a single PathBundle object representing the file /dev/cua/a.

PhyPort pathList[] = ports.getAll();
for (i = 0; i < ports.getCount(); i++)
     System.out.println("File #" + i + pathList[i].getPath());

Since:
3.0.0
Author:
Paul Klissner

Field Summary
private  java.io.File file
           
private  java.util.Vector rootPathVector
           
private  boolean rootPort
           
private  int type
           
 
Constructor Summary
  PathBundle()
          Public constructor.
private PathBundle(java.io.File file, int type, PathBundle rootPort)
          Private constructor.
 
Method Summary
 void add(java.lang.String pathName, int type)
          Given a path to a port, or a path to a directory containing a valid port device link and an associated port type, adds each physical port path encountered to the internal list.
private  void addToVector(PathBundle phyPort)
          Add port to root port's vector.
 void clear()
          Clear the PathBundle list.
 PathBundle[] getAll()
          Return all the PathBundle objects in the list.
 int getCount()
          Get number of physical ports stored in root class.
 java.io.File getFile()
          Get the File object associated with this object.
 java.lang.String getName()
          Get the base name path to the physical port path associated with this object.
 java.lang.String getPath()
          Get the full path to the physical port associated with this object.
 int getType()
          Get the type, serial or parallel, associated with this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private java.io.File file

type

private int type

rootPathVector

private java.util.Vector rootPathVector

rootPort

private boolean rootPort
Constructor Detail

PathBundle

public PathBundle()
Public constructor. Creates a new root port


PathBundle

private PathBundle(java.io.File file,
                   int type,
                   PathBundle rootPort)
Private constructor. Given a File object and a port type it adds the file to specified root port's internal list in the form of a PhysPorts object.

Method Detail

addToVector

private void addToVector(PathBundle phyPort)
Add port to root port's vector.

Parameters:
phyPort - port to add.

add

public void add(java.lang.String pathName,
                int type)
Given a path to a port, or a path to a directory containing a valid port device link and an associated port type, adds each physical port path encountered to the internal list.

Parameters:
pathName - Path name to serial or parallel port or directory containing them.
type - Integer type to associate with port.

getAll

public PathBundle[] getAll()
Return all the PathBundle objects in the list.

Returns:
Array of all physical ports in our list.

getFile

public java.io.File getFile()
Get the File object associated with this object.

Returns:
File associated with this object.

getType

public int getType()
Get the type, serial or parallel, associated with this object.

Returns:
type of port.

getPath

public java.lang.String getPath()
Get the full path to the physical port associated with this object.

Returns:
path to physical comm device.

getName

public java.lang.String getName()
Get the base name path to the physical port path associated with this object.

Returns:
path to physical comm device.

getCount

public int getCount()
Get number of physical ports stored in root class.

Returns:
number of ports in list.

clear

public void clear()
Clear the PathBundle list.