java.lang.Object
com.ibm.jzos.JesVsam
This class is for internal use only.
Used by MvsJobSubmitter
to 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
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
advance
(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[]
Close the underlying VSAM file.void
flush()
Flushes any pending data in the record buffer into VSAM PUTs.Answers the DD name used to open the underlying VSAM file.int
getLrecl()
Answer the LRECL, which is the maximum record length for variable length files.long
getRbar()
Answer the RBA of the last record (in the last buffer) read or written.boolean
isOpen()
Answer true if the file is open, false otherwise.boolean
isWrite()
static void
logDiagnostic
(int level, 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.void
point
(long rba) Point to a given RBA before reading.int
readBuffer
(byte[] buffer, int mode) Read one or more records into the given bufferlong
readBuffer
(byte[] buffer, int mode, int maxRecords) Read one or more records into the given bufferstatic void
setLoggingLevel
(int level) Sets the logging level for the Toolkit native code.void
setLrecl
(int lrecl) Set the LRECL, which is used to control the length of records written (in write mode).void
write
(byte[] record) Write the supplied bytes as the next sequential record.void
write
(byte[] record, int offset, int len) Write the supplied bytes, starting at offset for len, as the next sequential record.
-
Field Details
-
MODE_RECORD
public static final int MODE_RECORD- See Also:
-
MODE_BINARY
public static final int MODE_BINARY- See Also:
-
MODE_TEXT
public static final int MODE_TEXT- See Also:
-
-
Constructor Details
-
JesVsam
Create 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:
IOException
- if a native I/O error occurs
-
JesVsam
public JesVsam(String ddname, boolean isWrite, boolean isFixedLength, int bufferSize) throws JesVsamException Create 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:
IOException
- if a native I/O error occursJesVsamException
-
-
Method Details
-
close
Flush 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
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
-
isOpen
public boolean isOpen()Answer true if the file is open, false otherwise. -
flush
Flushes any pending data in the record buffer into VSAM PUTs.- Throws:
IOException
JesVsamException
-
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
Answer the RBA of the last record (in the last buffer) read or written.- Returns:
- long the 8 byte RBA address
- Throws:
JesVsamException
-
getDDName
Answers the DD name used to open the underlying VSAM file.- Returns:
- String ddname
-
readBuffer
Read 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
Read 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
Point to a given RBA before reading. Forces a flush of any previous read or write buffer.- Throws:
JesVsamException
-
advance
Advance 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
Write 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:
IOException
- if a native I/O error occursJesVsamException
-
write
Write 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:
IOException
- if a native I/O error occursJesVsamException
-
isWrite
public boolean isWrite()- Returns:
- true if opened in write mode, false if read mode.
-
logDiagnostic
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:
-