edu.uiuc.ge.illigal.gale.io
Class FileIOFactory

java.lang.Object
  |
  +--edu.uiuc.ge.illigal.gale.io.FileIOFactory
All Implemented Interfaces:
IOFactory

public class FileIOFactory
extends java.lang.Object
implements IOFactory

Implements a simple IO factory with multiple channels onto a file system.

Since:
0.9alpha
Version:
0.9alpha
Author:
Xavier Llorà <xllora@illigal.ge.uiuc.edu>

Field Summary
protected  java.io.FileOutputStream[] fosa
          The FileOutputStream array references
protected  java.util.Hashtable htTrans
          Translation for channel ids
protected  java.io.PrintStream[] psa
          The PrintStream array references
 
Constructor Summary
FileIOFactory(int iMax)
          Builds an IOFactory mapped onto a file system.
 
Method Summary
 void closeAllChannels()
          Closes all IO channels.
 void closeChannel(int iDesc)
          Closes an IO channel.
 void closeChannel(java.lang.String sName)
          Closes an IO channel.
 int openChannel(java.lang.String sName, java.lang.String sURL)
          Opens a new IO channel.
 void push(int iDesc, java.lang.Object obj)
          Pushes the information into the given channel.
 void push(java.lang.String sName, java.lang.Object obj)
          Pushes the information into the given channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fosa

protected java.io.FileOutputStream[] fosa
The FileOutputStream array references


psa

protected java.io.PrintStream[] psa
The PrintStream array references


htTrans

protected java.util.Hashtable htTrans
Translation for channel ids

Constructor Detail

FileIOFactory

public FileIOFactory(int iMax)
Builds an IOFactory mapped onto a file system. It allows only num channels open at a certain time,

Parameters:
iMax - Maximum number of concurrent channels
Method Detail

openChannel

public int openChannel(java.lang.String sName,
                       java.lang.String sURL)
                throws IOFactoryException
Description copied from interface: IOFactory
Opens a new IO channel.

Specified by:
openChannel in interface IOFactory
Parameters:
sName - The channel name
sURL - The channel URL
Returns:
The channel descriptor
Throws:
IOFactoryException - The channel could not be opened

closeChannel

public void closeChannel(int iDesc)
                  throws IOFactoryException
Description copied from interface: IOFactory
Closes an IO channel.

Specified by:
closeChannel in interface IOFactory
Parameters:
iDesc - The channel descriptor
Throws:
IOFactoryException - The channel could not be closed

closeChannel

public void closeChannel(java.lang.String sName)
                  throws IOFactoryException
Description copied from interface: IOFactory
Closes an IO channel.

Specified by:
closeChannel in interface IOFactory
Parameters:
sName - The channel name
Throws:
IOFactoryException - The channel could not be closed

closeAllChannels

public void closeAllChannels()
                      throws IOFactoryException
Description copied from interface: IOFactory
Closes all IO channels.

Specified by:
closeAllChannels in interface IOFactory
Throws:
IOFactoryException - The channel could not be closed

push

public void push(int iDesc,
                 java.lang.Object obj)
          throws IOFactoryException
Description copied from interface: IOFactory
Pushes the information into the given channel.

Specified by:
push in interface IOFactory
Parameters:
iDesc - The channel descriptor
obj - The object to be pushed
Throws:
IOFactoryException - The failure in channel

push

public void push(java.lang.String sName,
                 java.lang.Object obj)
          throws IOFactoryException
Description copied from interface: IOFactory
Pushes the information into the given channel.

Specified by:
push in interface IOFactory
Parameters:
obj - The object to be pushed
Throws:
IOFactoryException - The failure in channel