Module ibm.jzos
Package com.ibm.jzos

Class JesVsam

java.lang.Object
com.ibm.jzos.JesVsam

public class JesVsam extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    JesVsam(String ddname, boolean isWrite)
    Create a new instance suitable for handling I/O for the supplied ddname.
    JesVsam(String ddname, boolean isWrite, boolean isFixedLength, int bufferSize)
    Create a new instance suitable for handling I/O for the supplied ddname.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    advance(int numrecs, int buflen)
    Advance the underlying VSAM file by numrecs from the current position.
    byte[]
    Flush any buffered records (if write mode) and close the underlying VSAM file.
    byte[]
    Close the underlying VSAM file.
    void
    Flushes any pending data in the record buffer into VSAM PUTs.
    Answers the DD name used to open the underlying VSAM file.
    int
    Answer the LRECL, which is the maximum record length for variable length files.
    long
    Answer the RBA of the last record (in the last buffer) read or written.
    boolean
    Answer true if the file is open, false otherwise.
    boolean
     
    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 buffer
    long
    readBuffer(byte[] buffer, int mode, int maxRecords)
    Read one or more records into the given buffer
    static 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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • JesVsam

      public JesVsam(String ddname, boolean isWrite) throws IOException
      Create a new instance suitable for handling I/O for the supplied ddname.
      Parameters:
      ddname - the DD
      isWrite - 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 DD
      isWrite - if true, the DD is opened for write access, read otherwise
      isFixedLength - 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 occurs
      JesVsamException
  • Method Details

    • close

      public byte[] close() throws JesVsamException
      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

      public byte[] closeWithoutFlush() throws JesVsamException
      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

      public void flush() throws JesVsamException
      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

      public long getRbar() throws JesVsamException
      Answer the RBA of the last record (in the last buffer) read or written.
      Returns:
      long the 8 byte RBA address
      Throws:
      JesVsamException
    • getDDName

      public 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 JesVsamException
      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

      public long readBuffer(byte[] buffer, int mode, int maxRecords) throws JesVsamException
      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

      public void point(long rba) throws JesVsamException
      Point 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 JesVsamException
      Advance the underlying VSAM file by numrecs from the current position.
      Parameters:
      numrecs - the number of records to advance
      buflen - 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 JesVsamException
      Write the supplied bytes as the next sequential record. Will fail if isWrite() 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 occurs
      JesVsamException
    • write

      public void write(byte[] record, int offset, int len) throws JesVsamException
      Write the supplied bytes, starting at offset for len, as the next sequential record. Will fail if isWrite() 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 occurs
      JesVsamException
    • isWrite

      public boolean isWrite()
      Returns:
      true if opened in write mode, false if read mode.
    • logDiagnostic

      public 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.
      Parameters:
      level - one of the LOG_XXX constants defined above
      msg - 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: