asjava.uniobjects
Class UniSequentialFile

java.lang.Object
  extended byasjava.uniobjects.UniBase
      extended byasjava.uniobjects.UniSequentialFile

public class UniSequentialFile
extends UniBase

UniSequentialFile is created via the UniSession.openSequential method. It is used to define and manage UniVerse Sequential Files, which are operating system files.

Since:
UNIOBJECTS 1.0
Version:
Version 1.0
Author:
David T. Meeks

Field Summary
protected  int uniFileHandle
           
 
Fields inherited from class asjava.uniobjects.UniBase
inPacket, outPacket, uniConnection, uniEncryptionType, uniParentSession, uniStatus
 
Method Summary
 void close()
          Closes an open sequential file
 void fileSeek(int aRelPos, int aOffset)
          Moves the file pointer within the Sequential File by an offset position specified in bytes, relative to the current position, beginning of the file, or the end of the file, as determined by the aRelPos parameter.
 int getReadSize()
          returns the current readblock size for this object
 int getTimeout()
          returns the current timeout value for this object
 boolean isOpen()
          returns whether or not this sequential file is open
 void open()
          physically opens the server-side file, creating it if the CreateFlag value was set and the file doesn't exist
 UniString readBlk()
          reads a block of data from the sequential file.
 UniString readLine()
          reads a line of data from the sequential file.
 void setReadSize(int aBlockSize)
          sets the current ReadSize for this object
 void setTimeout(int aTimeOut)
          sets the current Timeout for this object
 void writeBlk(java.lang.Object aString)
          writes the given block to the sequential file, at the location currently set
 void writeEOF()
          writes an EOF marker
 void writeLine(java.lang.Object aString)
          writes the given line to the sequential file, at the location currently set
 
Methods inherited from class asjava.uniobjects.UniBase
getEncryptionType, isCommandActive, setEncryptionType, status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uniFileHandle

protected int uniFileHandle
Method Detail

close

public void close()
           throws UniSequentialFileException
Closes an open sequential file

Throws:
UniSequentialFileException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0

fileSeek

public void fileSeek(int aRelPos,
                     int aOffset)
              throws UniSequentialFileException
Moves the file pointer within the Sequential File by an offset position specified in bytes, relative to the current position, beginning of the file, or the end of the file, as determined by the aRelPos parameter.

Parameters:
aRelPos - integer denoting the relative position within a file to seek from. A 0 (UniT_START) implies to start from the beginning of the file. 1 (UniT_CURR) means to start from the current position. 2 (UniT_END) means to start from the end of the file.
aOffset - integer denoting the number of bytes before or after aRelPos. A negative value moves the pointer to a position before aRelPos
Throws:
UniSequentialFileException - if any errors occur
Since:
UNIOBJECTS 1.0

getReadSize

public int getReadSize()
returns the current readblock size for this object

Returns:
integer value representing the current block size to be used when reading blocks of data
Since:
UNIOBJECTS 1.0
See Also:
setReadSize(int)

getTimeout

public int getTimeout()
returns the current timeout value for this object

Returns:
integer value representing the current timeout value
Since:
UNIOBJECTS 1.0
See Also:
setTimeout(int)

isOpen

public boolean isOpen()
returns whether or not this sequential file is open

Returns:
boolean value denoting whether the file is open. true represents the file being open
Since:
UNIOBJECTS 1.0

open

public void open()
          throws UniSequentialFileException
physically opens the server-side file, creating it if the CreateFlag value was set and the file doesn't exist

Throws:
UniSequentialFileException - is thrown whenever an error occurs
Since:
UNIOBJECTS 1.0

readBlk

public UniString readBlk()
                  throws UniSequentialFileException
reads a block of data from the sequential file. The size of the data block is defined by what is set using the setReadSize method. Upon completion, the getReadSize method can be used to determine the number of bytes read. Additionally, the status method will return one of the following value:

Returns:
a String value representing the data that was read
Throws:
UniSequentialFileException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0

readLine

public UniString readLine()
                   throws UniSequentialFileException
reads a line of data from the sequential file. The lines must be delimited with a newline character. Additionally, the status method will return one of the following values:

Returns:
a String value representing the data that was read
Throws:
UniSequentialFileException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0

setReadSize

public void setReadSize(int aBlockSize)
sets the current ReadSize for this object

Parameters:
aBlockSize - the block size to be set for subsequent read requests
Since:
UNIOBJECTS 1.0
See Also:
getReadSize()

setTimeout

public void setTimeout(int aTimeOut)
                throws UniSequentialFileException
sets the current Timeout for this object

Parameters:
aTimeOut - the timeout value to be used for read requests
Throws:
UniSequentialFileException - is thrown if there is an error
Since:
UNIOBJECTS 1.0
See Also:
setTimeout(int)

writeBlk

public void writeBlk(java.lang.Object aString)
              throws UniSequentialFileException
writes the given block to the sequential file, at the location currently set

Parameters:
aString - a String representing the data block to be written
Throws:
UniSequentialFileException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0

writeEOF

public void writeEOF()
              throws UniSequentialFileException
writes an EOF marker

Throws:
UniSequentialFileException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0

writeLine

public void writeLine(java.lang.Object aString)
               throws UniSequentialFileException
writes the given line to the sequential file, at the location currently set

Parameters:
aString - a String representing the line to be written
Throws:
UniSequentialFileException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0