net.sf.xbus.technical.as400
Class AS400FileBase

java.lang.Object
  extended by net.sf.xbus.technical.as400.AS400FileBase
Direct Known Subclasses:
AS400FileReceiver, AS400FileSender, AS400ProgramSender

public abstract class AS400FileBase
extends java.lang.Object

Class AS400FileBase is the abstract base class for the AS400FileReceiver and AS400FileSender classes.

It provides the methods for the following:

.


Field Summary
protected  com.ibm.as400.access.CharConverter mConverter
          The char converter according to actual string encoding.
 
Constructor Summary
AS400FileBase()
           
 
Method Summary
protected  void callAS400Program(com.ibm.as400.access.AS400 as400, java.lang.String programName, com.ibm.as400.access.ProgramParameter[] parameters, int timeout)
          Calls an AS400 program.
protected  void copyFile(com.ibm.as400.access.AS400 as400System, java.lang.String sourceName, java.lang.String targetName)
          This method uses the installable file system classes to copy a file from one directory to another on the server.
protected  void deleteFile(com.ibm.as400.access.AS400 mAS400System, java.lang.String fileName)
          deleteFile deletes a file on the AS400 file system.
protected  void deleteMember(com.ibm.as400.access.AS400 as400System, java.lang.String fileName)
          Deletes a member of a sequential file on the AS/400 file system.
static java.lang.String getEncoding(com.ibm.as400.access.AS400 as400System, java.lang.String system)
          Returns the encoding of the data type from the Configuration.
protected  java.lang.String getRenamedMember(com.ibm.as400.access.QSYSObjectPathName qsysPathname, java.lang.String newMember)
          Return a path name with a new member name.
protected  void releaseLock(com.ibm.as400.access.AS400 as400System, java.lang.String lockFilename)
          Releases all locks acquired via the setLock(AS400, String) method.
protected  void renameFile(com.ibm.as400.access.AS400 as400System, java.lang.String sourceFilename, java.lang.String destFilename)
          Renames the integrated file system object specified by the source path name to have the path name of dest.
protected  void setLock(com.ibm.as400.access.AS400 as400System, java.lang.String lockFilename)
          Sets a lock on the file to prevent other users from accessing the file while it is in use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mConverter

protected com.ibm.as400.access.CharConverter mConverter
The char converter according to actual string encoding. It is protected to grant access by the subclasses.

Constructor Detail

AS400FileBase

public AS400FileBase()
Method Detail

getEncoding

public static java.lang.String getEncoding(com.ibm.as400.access.AS400 as400System,
                                           java.lang.String system)
                                    throws XException
Returns the encoding of the data type from the Configuration. If this one is non-existent, the method returns the default value from the AS400 object that corresponds to the job CCSID of the server.

Parameters:
as400System - AS400 object for the server that holds the files
system - system name for which encoding must be read
Returns:
character encoding from Configuration or default encoding that corresponds to the job CCSID of the server.
Throws:
XException - if encoding cannot be determined neither from the configurationnor by accesing the AS400

setLock

protected void setLock(com.ibm.as400.access.AS400 as400System,
                       java.lang.String lockFilename)
                throws XException
Sets a lock on the file to prevent other users from accessing the file while it is in use.

The following type of lock is used:

WRITE_EXCLUSIVE_LOCK   The current Java program changes the file, and no other program can access the file.

Note: If a lock has already been obtained for this file, no action is taken.

Parameters:
as400System - The AS400 system to which to connect. The system cannot be null.
lockFilename - The integrated file system pathname of the file to be locked. The name cannot be null.
Throws:
XException - if locking did not work

releaseLock

protected void releaseLock(com.ibm.as400.access.AS400 as400System,
                           java.lang.String lockFilename)
                    throws XException
Releases all locks acquired via the setLock(AS400, String) method.

If no locks have been explicitly obtained, no action is taken.

Parameters:
as400System - The AS400 system to which to connect. The system cannot be null.
lockFilename - The integrated file system pathname of the file to be locked. The name cannot be null.
Throws:
XException - if the file lock can not be released

getRenamedMember

protected java.lang.String getRenamedMember(com.ibm.as400.access.QSYSObjectPathName qsysPathname,
                                            java.lang.String newMember)
Return a path name with a new member name. The QSYSObjectPathName provides an integrated file system path name that represents an object in the QSYS library file system.

For example:

/QSYS.LIB/QGPL.LIB/ACCOUNTS.FILE/PAYABLE.MBR

This method parses the given QSYSObjectPathName object to extract the library, object, member, and object type and builds integrated file system path name with new member as follows:

/QSYS.LIB/OLDLIB.LIB/OLDFILE.FILE/NEWMEMBER.MBR

Parameters:
qsysPathname - represents old object in the QSYS library file system
newMember - new member name, cannot exceed 10 characters in length! Must start with a letter.
Returns:
fully qualified integrated file system path of the new object in the QSYS file system

renameFile

protected void renameFile(com.ibm.as400.access.AS400 as400System,
                          java.lang.String sourceFilename,
                          java.lang.String destFilename)
                   throws XException
Renames the integrated file system object specified by the source path name to have the path name of dest.

Parameters:
as400System - AS400 system to which to connect. The system cannot be null
sourceFilename - old abstract pathname of the integrated file system object
destFilename - new abstract pathname of the integrated file system object
Throws:
XException - if an error occurs while communicating with the server.

copyFile

protected void copyFile(com.ibm.as400.access.AS400 as400System,
                        java.lang.String sourceName,
                        java.lang.String targetName)
                 throws XException
This method uses the installable file system classes to copy a file from one directory to another on the server.

Parameters:
as400System - AS400 object for the server which holds the files.
sourceName - name the source file to be copied
targetName - name the target file to be copied to
Throws:
XException - if file processing cannot be completed

deleteFile

protected void deleteFile(com.ibm.as400.access.AS400 mAS400System,
                          java.lang.String fileName)
                   throws XException
deleteFile deletes a file on the AS400 file system. This method is used for files in the AS400 inegrated file system sense.

Parameters:
mAS400System - the AS400 to interact with
fileName - the path of the file to delete
Throws:
XException - if the file cannot be deleted for any reason
See Also:
deleteMember(AS400, String)

deleteMember

protected void deleteMember(com.ibm.as400.access.AS400 as400System,
                            java.lang.String fileName)
                     throws XException
Deletes a member of a sequential file on the AS/400 file system. The surrounding file will continue to exist.

Parameters:
as400System - the AS/400 to interact with
fileName - the name of the file and member to delete
Throws:
XException - if the member cannot be deleted for any reason

callAS400Program

protected void callAS400Program(com.ibm.as400.access.AS400 as400,
                                java.lang.String programName,
                                com.ibm.as400.access.ProgramParameter[] parameters,
                                int timeout)
                         throws XException
Calls an AS400 program.

Parameters:
as400 - the AS400 to interact with
programName - the path of the program to call
parameters - the input and output paremeters of the program call
timeout - seconds before program will be stopped
Throws:
XException - if the AS400 issues an error