com.ibm.jzos
Class JesVsam
- java.lang.Object
-
- com.ibm.jzos.JesVsam
-
public class JesVsam extends java.lang.ObjectThis class is for internal use only.Used by
MvsJobSubmitterto submit jobs to the internal reader.Note: I/O performed using these classes must be performed on a single thread.
- Since:
- 2.4.0
-
-
Field Summary
Fields Modifier and Type Field and Description static intMODE_BINARYstatic intMODE_RECORDstatic intMODE_TEXT
-
Constructor Summary
Constructors Constructor and Description JesVsam(java.lang.String ddname, boolean isWrite)Create a new instance suitable for handling I/O for the supplied ddname.JesVsam(java.lang.String ddname, boolean isWrite, boolean isFixedLength, int bufferSize)Create a new instance suitable for handling I/O for the supplied ddname.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description intadvance(int numrecs, int buflen)Advance the underlying VSAM file by numrecs from the current position.byte[]close()Flush any buffered records (if write mode) and close the underlying VSAM file.byte[]closeWithoutFlush()Close the underlying VSAM file.voidflush()Flushes any pending data in the record buffer into VSAM PUTs.java.lang.StringgetDDName()Answers the DD name used to open the underlying VSAM file.intgetLrecl()Answer the LRECL, which is the maximum record length for variable length files.longgetRbar()Answer the RBA of the last record (in the last buffer) read or written.booleanisOpen()Answer true if the file is open, false otherwise.booleanisWrite()static voidlogDiagnostic(int level, java.lang.String msg)Send a message to the native libraries log, which goes to the Language Environment messages file, which is usually stderr or DD //SYSOUT.voidpoint(long rba)Point to a given RBA before reading.intreadBuffer(byte[] buffer, int mode)Read one or more records into the given bufferlongreadBuffer(byte[] buffer, int mode, int maxRecords)Read one or more records into the given bufferstatic voidsetLoggingLevel(int level)Sets the logging level for the Toolkit native code.voidsetLrecl(int lrecl)Set the LRECL, which is used to control the length of records written (in write mode).voidwrite(byte[] record)Write the supplied bytes as the next sequential record.voidwrite(byte[] record, int offset, int len)Write the supplied bytes, starting at offset for len, as the next sequential record.
-
-
-
Field Detail
-
MODE_RECORD
public static final int MODE_RECORD
- See Also:
- Constant Field Values
-
MODE_BINARY
public static final int MODE_BINARY
- See Also:
- Constant Field Values
-
MODE_TEXT
public static final int MODE_TEXT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JesVsam
public JesVsam(java.lang.String ddname, boolean isWrite) throws java.io.IOExceptionCreate a new instance suitable for handling I/O for the supplied ddname.- Parameters:
ddname- the DDisWrite- if true, the DD is opened for write access, read otherwise- Throws:
java.io.IOException- if a native I/O error occurs
-
JesVsam
public JesVsam(java.lang.String ddname, boolean isWrite, boolean isFixedLength, int bufferSize) throws JesVsamExceptionCreate a new instance suitable for handling I/O for the supplied ddname.- Parameters:
ddname- the DDisWrite- if true, the DD is opened for write access, read otherwiseisFixedLength- if true, fixed length records are used (only used for write mode)bufferSize- the size of record buffer (only used for write mode)- Throws:
java.io.IOException- if a native I/O error occursJesVsamException
-
-
Method Detail
-
close
public byte[] close() throws JesVsamExceptionFlush any buffered records (if write mode) and close the underlying VSAM file. If successful, returns an 8-byte byte array containing the final RBAR (after an ENDREQ is issued for the file).- Throws:
JesVsamException
-
closeWithoutFlush
public byte[] closeWithoutFlush() throws JesVsamExceptionClose the underlying VSAM file. If successful, returns an 8-byte byte array containing the final RBAR (after an ENDREQ is issued for the file).- Throws:
JesVsamException
-
isOpen
public boolean isOpen()
Answer true if the file is open, false otherwise.
-
flush
public void flush() throws JesVsamExceptionFlushes any pending data in the record buffer into VSAM PUTs.- Throws:
java.io.IOExceptionJesVsamException
-
getLrecl
public int getLrecl()
Answer the LRECL, which is the maximum record length for variable length files.Note: This value may not be accurate for JES3 jobs.
-
setLrecl
public void setLrecl(int lrecl)
Set the LRECL, which is used to control the length of records written (in write mode).
-
getRbar
public long getRbar() throws JesVsamExceptionAnswer the RBA of the last record (in the last buffer) read or written.- Returns:
- long the 8 byte RBA address
- Throws:
JesVsamException
-
getDDName
public java.lang.String getDDName()
Answers the DD name used to open the underlying VSAM file.- Returns:
- String ddname
-
readBuffer
public int readBuffer(byte[] buffer, int mode) throws JesVsamExceptionRead one or more records into the given buffer- Parameters:
buffer- which is to contain the records, formatted according to the given mode. MODE_RECORD: each preceded by a 4 byte big-endian length; MODE_TEXT: each record has trailing spaces trimmed and is terminated by a newline (x'15); MODE:BIN: no record separators are present.- Returns:
- int -1 if EOF (no more records), otherwise the number of bytes used in the buffer (low-order 32-bits)
- Throws:
JesVsamException
-
readBuffer
public long readBuffer(byte[] buffer, int mode, int maxRecords) throws JesVsamExceptionRead one or more records into the given buffer- Parameters:
buffer- which is to contain the records, formatted according to the given mode. MODE_RECORD: each preceded by a 4 byte big-endian length; MODE_TEXT: each record has trailing spaces trimmed and is terminated by a newline (x'15); MODE:BIN: no record separators are present.maxRecords- the maximum number of records to read.- Returns:
- long -1 if EOF (no more records), otherwise a combination of the number of records read (high-order 32 bits) + the number of bytes used in the buffer (low-order 32-bits); both are positive integers.
- Throws:
JesVsamException
-
point
public void point(long rba) throws JesVsamExceptionPoint to a given RBA before reading. Forces a flush of any previous read or write buffer.- Throws:
JesVsamException
-
advance
public int advance(int numrecs, int buflen) throws JesVsamExceptionAdvance the underlying VSAM file by numrecs from the current position.- Parameters:
numrecs- the number of records to advancebuflen- the native buffer size to use- Returns:
- the number of records advanced. If this number is less than numrecs, EOF was reached before the numrecs were advanced.
- Throws:
JesVsamException
-
write
public void write(byte[] record) throws JesVsamExceptionWrite the supplied bytes as the next sequential record. Will fail ifisWrite()is false.- Parameters:
record- the bytes to write. The length of the byte array must be less than or equal to the maximum LRECL of the underlying dataset.- Throws:
java.io.IOException- if a native I/O error occursJesVsamException
-
write
public void write(byte[] record, int offset, int len) throws JesVsamExceptionWrite the supplied bytes, starting at offset for len, as the next sequential record. Will fail ifisWrite()is false.- Parameters:
record- the bytes to write.offset- the offset of the first byte in the supplied byte array to write.len- the number of bytes to write. Must be less than or equal to the maximum LRECL of the underlying dataset.- Throws:
java.io.IOException- if a native I/O error occursJesVsamException
-
isWrite
public boolean isWrite()
- Returns:
- true if opened in write mode, false if read mode.
-
logDiagnostic
public static void logDiagnostic(int level, java.lang.String msg)Send a message to the native libraries log, which goes to the Language Environment messages file, which is usually stderr or DD //SYSOUT.- Parameters:
level- one of the LOG_XXX constants defined abovemsg- the message text
-
setLoggingLevel
public static void setLoggingLevel(int level)
Sets the logging level for the Toolkit native code. This method can be used to enable debugging output from the toolkit native library.Alternatively, a system property can be used to set the toolkit logging level. This property has the form: -Djzos.logging={E|W|N|I|D|T}
- Parameters:
level- one of the LOG_XXX constants defined above- See Also:
logDiagnostic(int, String)
-
-