Class JobOutputReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable

    public class JobOutputReader
    extends Reader
    Reads text from a job output or DD for a job, providing for the efficient reading of characters.

    The entire content of the job/DD will be obtained at the moment the JobOutputReader is constructed and stored in a temporary file. Therefore, any reads done on that JobOutputReader object will reflect the content of the dataset at the moment the JobOutputReader object was constructed, rather than the content of the job/DD at the moment of the read. When close is called, the temporary file will be deleted.

    The text returned will be in UTF-8 encoding. Non-displayable binary data will be substituted with Unicode characters that are outside of the code page of the mainframe host login. This allows us to distinguish text data from binary within UTF-8.

    For efficient reading of job/DD records, it is advisable to wrap a BufferedReader around a JobOutputReader. For example,

    BufferedReader in = new BufferedReader(new JobOutputReader(...));

    Examples:
    To read the JES output for a job, use the IJESCommandProvider.findJobs() API to get a JobInfo instance for the job. Then create a JobOutputReader for the job.

     IZOSHostConnection zosHostConnection = ...
     IJESCommandProvider commandProvider = ...
     List<IJob> jobs = ...
      
     // Create the buffered reader with the appropriate JobInfo
     IJob iJob = jobs.get(x)
     BufferedReader in = new BufferedReader(new JobOutputReader(iJob, 200));
     
     //Read the data from the reader
     String ine;
     while ((line = in.readLine()) != null) {
        // Process the line of data
     }
     
    To read the contents of a DD for a job, use the IJESCommandProvider.fetchSysoutDataDefinitions() API to get the list of data definitions for a job. Then create a JobOutputReader for the job and DD.
     IZOSHostConnection zosHostConnection = ...
     IJESCommandProvider commandProvider = ...
     List<IJob> jobs = ...
     List<ISysoutDataDefinition> dds = ...
       
     // Create the buffered reader with the appropriate JobInfo
     IJob iJob = jobs.get(x);
     ISystemDataDefinition dd = dds.get(x);
     BufferedReader in = new BufferedReader(new JobOutputReader(iJob, dd, 200));
     
     // Read the data from the reader
     String line;
     while ((line = in.readLine()) != null) {
        // Process the line of data
     }
     
    Since:
    2.2.0
    Version:
    2.2.0
    See Also:
    IJESCommandProvider, JobInfo, ISystemDataDefinition
    Restriction:
    This class is not intended to be extended by clients.
    • Constructor Detail

      • JobOutputReader

        public JobOutputReader​(IJob iJob,
                               int numberLinesToReturn)
        Creates a JobOutputReader that reads all of the output of a job.
        Parameters:
        iJob - Specifies the job whose output is desired. The IJob object is created using the findJobs methods of com.compuware.api.topaz.jes.IJesCommandProvider
        numberLinesToReturn - An int specifying the maximum number of lines to return. 0 will return all lines.
        Throws:
        HostIOException - for any I/O error
        See Also:
        IJESCommandProvider
      • JobOutputReader

        public JobOutputReader​(IJob iJob,
                               ISysoutDataDefinition ddDefinition,
                               int numberLinesToReturn)
        Creates a JobOutputReader that reads the contents of a specific DD for a job.
        Parameters:
        iJob - A IJob that specifies the job whose output is desired. The IJob object is created using the findJobs methods of com.compuware.api.topaz.jes.IJesCommandProvider
        ddDefinition - A ISysoutDataDefinition instance that specifies the DD whose output is desired. The ISysoutDataDefinition is created using the fetchSystemDataDefinitions method of com.compuware.api.topaz.jes.IJesCommandProvider
        numberLinesToReturn - An int specifying the maximum number of lines to return. 0 will return all lines.
        Throws:
        HostIOException - for any I/O error
        See Also:
        IJESCommandProvider