com.ibm.jtopenlite.ddm
Class DDMConnection

java.lang.Object
  extended by com.ibm.jtopenlite.HostServerConnection
      extended by com.ibm.jtopenlite.ddm.DDMConnection
All Implemented Interfaces:
Connection

public class DDMConnection
extends HostServerConnection

Represents a TCP/IP socket connection to the System i Distributed Data Management (DDM) host server (QUSRWRK/QRWTSRVR job).


Nested Class Summary
 
Nested classes/interfaces inherited from class com.ibm.jtopenlite.HostServerConnection
HostServerConnection.HostInputStream, HostServerConnection.HostOutputStream
 
Field Summary
static int DEFAULT_DDM_SERVER_PORT
           
 
Fields inherited from class com.ibm.jtopenlite.HostServerConnection
in_, out_
 
Method Summary
 Message[] close(DDMFile file)
          Closes the specified file and returns any messages that were issued.
 void deleteCurrent(DDMFile file)
          Removes the current record from the file.
 Message[] execute(String command)
          Executes the specified CL command within the DDM host server job.
static DDMConnection getConnection(String system, String user, String password)
          Establishes a new socket connection to the specified system and authenticates the specified user and password.
static DDMConnection getConnection(SystemInfo info, String user, String password)
          Establishes a new socket connection to the specified system and authenticates the specified user and password.
static DDMConnection getConnection(SystemInfo info, String user, String password, int ddmPort)
          Establishes a new socket connection to the specified system and port, and authenticates the specified user and password.
 DDMRecordFormat getRecordFormat(DDMFile file)
          Retrieves the record format of the specified file.
 DDMRecordFormat getRecordFormat(String library, String file)
          Retrieves the record format of the specified file.
 DDMFile open(String library, String file, String member, String recordFormat)
          Opens the specified file for sequential read-only access and a preferred batch size of 100.
 DDMFile open(String library, String file, String member, String recordFormat, int readWriteType, boolean keyed, int preferredBatchSize, int numBuffers)
          Opens the specified file for reading or writing records.
 void position(DDMFile file, DDMReadCallback listener, int recordNumber)
          Positions the cursor to the specified record number.
 void positionAfterLast(DDMFile file)
          Positions the cursor to the end of the file (after the last record).
 void positionBeforeFirst(DDMFile file)
          Positions the cursor to the beginning of the file (before the first record).
 void positionToFirst(DDMFile file)
          Positions the cursor to the first record in the file.
 void positionToKeyEqual(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Positions the file cursor to the record whose key is equal to the specified key.
 void positionToKeyGreater(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Positions the file cursor to the record whose key is greater than the specified key.
 void positionToKeyGreaterOrEqual(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Positions the file cursor to the record whose key is greater than or equal to the specified key.
 void positionToKeyLess(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Positions the file cursor to the record whose key is less than the specified key.
 void positionToKeyLessOrEqual(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Positions the file cursor to the record whose key is less than or equal to the specified key.
 void positionToLast(DDMFile file)
          Positions the cursor to the last record in the file.
 void positionToNext(DDMFile file, DDMReadCallback listener)
          Positions the cursor to the next record in the file.
 void positionToPrevious(DDMFile file, DDMReadCallback listener)
          Positions the cursor to the previous record in the file.
 void read(DDMFile file, DDMReadCallback listener, int recordNumber)
          Reads the record with the specified record number from the file.
 void readCurrent(DDMFile file, DDMReadCallback listener)
          Reads the current record from the specified file and positions the cursor on or after it.
 void readFirst(DDMFile file, DDMReadCallback listener)
          Reads the first record from the specified file and positions the cursor on or after it.
 void readKeyEqual(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Reads the next record whose key is equal to the specified key.
 void readKeyGreater(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Reads the next record whose key is greater than the specified key.
 void readKeyGreaterOrEqual(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Reads the next record whose key is greater than or equal to the specified key.
 void readKeyLess(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Reads the next record whose key is less than the specified key.
 void readKeyLessOrEqual(DDMFile file, DDMReadCallback listener, byte[] key, int numberOfKeyFields)
          Reads the next record whose key is less than or equal to the specified key.
 void readLast(DDMFile file, DDMReadCallback listener)
          Reads the last record from the specified file and positions the cursor on or after it.
 void readNext(DDMFile file, DDMReadCallback listener)
          Reads the next record from the specified file and positions the cursor on or after it.
 void readPrevious(DDMFile file, DDMReadCallback listener)
          Reads the previous record from the specified file and positions the cursor on or before it.
protected  void sendEndJobRequest()
          No-op.
 void updateCurrent(DDMFile file, byte[] data, int offset, boolean[] nullFieldValues)
          Updates the current record with the specified data.
 void updateCurrent(DDMFile file, DDMWriteCallback listener)
          Updates the current record with the first record provided by the callback.
 void write(DDMFile file, byte[] data, int offset, boolean[] nullFieldValues, DDMReadCallback listener)
          Writes a single record to the end of the file.
 void write(DDMFile file, DDMWriteCallback listener)
          Writes records provided by the callback to the file.
 
Methods inherited from class com.ibm.jtopenlite.HostServerConnection
close, connect, finalize, getEncryptedPassword, getInfo, getJobName, getUser, isClosed, isDatastreamDebug, isDefaultDatastreamDebug, setDatastreamDebug, writePadEBCDIC, writePadEBCDIC10, writeStringToUnicodeBytes
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DDM_SERVER_PORT

public static final int DEFAULT_DDM_SERVER_PORT
See Also:
Constant Field Values
Method Detail

sendEndJobRequest

protected void sendEndJobRequest()
                          throws IOException
No-op. The DDM host server does not use an end job datastream.

Specified by:
sendEndJobRequest in class HostServerConnection
Throws:
IOException

getConnection

public static DDMConnection getConnection(String system,
                                          String user,
                                          String password)
                                   throws IOException
Establishes a new socket connection to the specified system and authenticates the specified user and password.

Throws:
IOException

getConnection

public static DDMConnection getConnection(SystemInfo info,
                                          String user,
                                          String password)
                                   throws IOException
Establishes a new socket connection to the specified system and authenticates the specified user and password.

Throws:
IOException

getConnection

public static DDMConnection getConnection(SystemInfo info,
                                          String user,
                                          String password,
                                          int ddmPort)
                                   throws IOException
Establishes a new socket connection to the specified system and port, and authenticates the specified user and password.

Throws:
IOException

close

public Message[] close(DDMFile file)
                throws IOException
Closes the specified file and returns any messages that were issued.

Throws:
IOException

open

public DDMFile open(String library,
                    String file,
                    String member,
                    String recordFormat)
             throws IOException
Opens the specified file for sequential read-only access and a preferred batch size of 100.

Parameters:
library - The name of the library in which the file resides. For example, "QSYS".
file - The name of the physical or logical file.
member - The member within the file. This can be a special value such as "*FIRST".
recordFormat - The name of the record format. This value can also be obtained from DDMRecordFormat.getName().
Throws:
IOException

open

public DDMFile open(String library,
                    String file,
                    String member,
                    String recordFormat,
                    int readWriteType,
                    boolean keyed,
                    int preferredBatchSize,
                    int numBuffers)
             throws IOException
Opens the specified file for reading or writing records.

Parameters:
library - The name of the library in which the file resides. For example, "QSYS".
file - The name of the physical or logical file.
member - The member within the file. This can be a special value such as "*FIRST".
recordFormat - The name of the record format. This value can also be obtained from DDMRecordFormat.getName().
readWriteType - The read-write access type to use. Allowed values are:
keyed - Indicates if the file should be opened for sequential or keyed access.
preferredBatchSize - The number of records to read or write at a time. This is a preferred number because the DDMConnection may decide to use a different batch size depending on circumstances (e.g. READ_WRITE files always use a batch size of 1).
numBuffers - The number of data buffers to allocate for use when reading new records. The DDMConnection will round-robin through the data buffers as it calls DDMReadCallback.newRecord(). This can be useful for multi-threaded readers that process new record data, such as DDMThreadedReader. In such cases, each processing thread could be assigned a specific data buffer, to avoid contention. See DDMDataBuffer.
Throws:
IOException

getRecordFormat

public DDMRecordFormat getRecordFormat(String library,
                                       String file)
                                throws IOException
Retrieves the record format of the specified file. This currently only retrieves the first record format in a multi-format file.

Throws:
IOException

getRecordFormat

public DDMRecordFormat getRecordFormat(DDMFile file)
                                throws IOException
Retrieves the record format of the specified file. This currently only retrieves the first record format in a multi-format file.

Throws:
IOException

read

public void read(DDMFile file,
                 DDMReadCallback listener,
                 int recordNumber)
          throws IOException
Reads the record with the specified record number from the file.

Throws:
IOException

readKeyEqual

public void readKeyEqual(DDMFile file,
                         DDMReadCallback listener,
                         byte[] key,
                         int numberOfKeyFields)
                  throws IOException
Reads the next record whose key is equal to the specified key.

Throws:
IOException

readKeyGreater

public void readKeyGreater(DDMFile file,
                           DDMReadCallback listener,
                           byte[] key,
                           int numberOfKeyFields)
                    throws IOException
Reads the next record whose key is greater than the specified key.

Throws:
IOException

readKeyGreaterOrEqual

public void readKeyGreaterOrEqual(DDMFile file,
                                  DDMReadCallback listener,
                                  byte[] key,
                                  int numberOfKeyFields)
                           throws IOException
Reads the next record whose key is greater than or equal to the specified key.

Throws:
IOException

readKeyLess

public void readKeyLess(DDMFile file,
                        DDMReadCallback listener,
                        byte[] key,
                        int numberOfKeyFields)
                 throws IOException
Reads the next record whose key is less than the specified key.

Throws:
IOException

readKeyLessOrEqual

public void readKeyLessOrEqual(DDMFile file,
                               DDMReadCallback listener,
                               byte[] key,
                               int numberOfKeyFields)
                        throws IOException
Reads the next record whose key is less than or equal to the specified key.

Throws:
IOException

positionToKeyEqual

public void positionToKeyEqual(DDMFile file,
                               DDMReadCallback listener,
                               byte[] key,
                               int numberOfKeyFields)
                        throws IOException
Positions the file cursor to the record whose key is equal to the specified key.

Throws:
IOException

positionToKeyGreater

public void positionToKeyGreater(DDMFile file,
                                 DDMReadCallback listener,
                                 byte[] key,
                                 int numberOfKeyFields)
                          throws IOException
Positions the file cursor to the record whose key is greater than the specified key.

Throws:
IOException

positionToKeyGreaterOrEqual

public void positionToKeyGreaterOrEqual(DDMFile file,
                                        DDMReadCallback listener,
                                        byte[] key,
                                        int numberOfKeyFields)
                                 throws IOException
Positions the file cursor to the record whose key is greater than or equal to the specified key.

Throws:
IOException

positionToKeyLess

public void positionToKeyLess(DDMFile file,
                              DDMReadCallback listener,
                              byte[] key,
                              int numberOfKeyFields)
                       throws IOException
Positions the file cursor to the record whose key is less than the specified key.

Throws:
IOException

positionToKeyLessOrEqual

public void positionToKeyLessOrEqual(DDMFile file,
                                     DDMReadCallback listener,
                                     byte[] key,
                                     int numberOfKeyFields)
                              throws IOException
Positions the file cursor to the record whose key is less than or equal to the specified key.

Throws:
IOException

readNext

public void readNext(DDMFile file,
                     DDMReadCallback listener)
              throws IOException
Reads the next record from the specified file and positions the cursor on or after it.

Throws:
IOException

readPrevious

public void readPrevious(DDMFile file,
                         DDMReadCallback listener)
                  throws IOException
Reads the previous record from the specified file and positions the cursor on or before it.

Throws:
IOException

readFirst

public void readFirst(DDMFile file,
                      DDMReadCallback listener)
               throws IOException
Reads the first record from the specified file and positions the cursor on or after it.

Throws:
IOException

readLast

public void readLast(DDMFile file,
                     DDMReadCallback listener)
              throws IOException
Reads the last record from the specified file and positions the cursor on or after it.

Throws:
IOException

readCurrent

public void readCurrent(DDMFile file,
                        DDMReadCallback listener)
                 throws IOException
Reads the current record from the specified file and positions the cursor on or after it.

Throws:
IOException

positionToNext

public void positionToNext(DDMFile file,
                           DDMReadCallback listener)
                    throws IOException
Positions the cursor to the next record in the file.

Throws:
IOException

positionToPrevious

public void positionToPrevious(DDMFile file,
                               DDMReadCallback listener)
                        throws IOException
Positions the cursor to the previous record in the file.

Throws:
IOException

positionToFirst

public void positionToFirst(DDMFile file)
                     throws IOException
Positions the cursor to the first record in the file.

Throws:
IOException

positionToLast

public void positionToLast(DDMFile file)
                    throws IOException
Positions the cursor to the last record in the file.

Throws:
IOException

positionAfterLast

public void positionAfterLast(DDMFile file)
                       throws IOException
Positions the cursor to the end of the file (after the last record).

Throws:
IOException

positionBeforeFirst

public void positionBeforeFirst(DDMFile file)
                         throws IOException
Positions the cursor to the beginning of the file (before the first record).

Throws:
IOException

position

public void position(DDMFile file,
                     DDMReadCallback listener,
                     int recordNumber)
              throws IOException
Positions the cursor to the specified record number.

Throws:
IOException

write

public void write(DDMFile file,
                  byte[] data,
                  int offset,
                  boolean[] nullFieldValues,
                  DDMReadCallback listener)
           throws IOException
Writes a single record to the end of the file.

Throws:
IOException

write

public void write(DDMFile file,
                  DDMWriteCallback listener)
           throws IOException
Writes records provided by the callback to the file.

Throws:
IOException

updateCurrent

public void updateCurrent(DDMFile file,
                          byte[] data,
                          int offset,
                          boolean[] nullFieldValues)
                   throws IOException
Updates the current record with the specified data.

Throws:
IOException

updateCurrent

public void updateCurrent(DDMFile file,
                          DDMWriteCallback listener)
                   throws IOException
Updates the current record with the first record provided by the callback.

Throws:
IOException

execute

public Message[] execute(String command)
                  throws IOException
Executes the specified CL command within the DDM host server job.

Throws:
IOException

deleteCurrent

public void deleteCurrent(DDMFile file)
                   throws IOException
Removes the current record from the file.

Throws:
IOException