Class DataSetReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable

    public final class DataSetReader
    extends Reader
    Reads text from a z/OS dataset, providing for the efficient reading of characters.

    The entire content of the dataset will be obtained at the moment the DataSetReader is constructed and stored in a temporary file. Therefore, any reads done on that DataSetReader object will reflect the content of the dataset at the moment the DataSetReader object was constructed, rather than the content of the dataset at the moment the of 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, and if the data is written back to the mainframe using a DataSetWriter, those Unicode characters will be replaced with the corresponding binary bytes.

    For efficient reading of dataset records, it is advisable to wrap a BufferedReader around a DataSetReader. For example,

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

    Regarding parameter validation for the methods within this class:

    A dataset name is considered invalid if:

    • The total length of the name is 0 or is greater than 44 characters.
    • The length of any qualifier within the name is 0 or is greater than 8 characters.
    • Qualifiers are delimited by anything other than a '.' character.
    • Any characters outside of the code page 1047 hex values for A-Z, a-z, 0-9, @, #, $, or - are present.
    • Any qualifier (and hence the name itself) starts with a digit (0-9) or a hyphen (-).
    Since:
    1.0.0
    Version:
    2.0.0
    See Also:
    ISequentialDataSet
    Restriction:
    This class is not intended to be extended by clients.
    • Method Detail

      • containsNonDisplayableData

        public boolean containsNonDisplayableData()
        Returns whether non-displayable binary data exists within the text of this reader.

        Non-displayable binary data is substituted with the replacement character for display purposes.

        Returns:
        true if non-displayable binary data exists, false otherwise
        Since:
        1.0.0
        See Also:
        getReplacementCharacter()
      • getReplacementCharacter

        public char getReplacementCharacter()
        Returns the replacement character for non-displayable binary data.

        The replacement character is uFFFD (a lozenge).

        Returns:
        the replacement character
        Since:
        1.0.0
      • read

        public int read​(char[] dataBuffer,
                        int offset,
                        int length)
                 throws IOException
        Specified by:
        read in class Reader
        Throws:
        IOException
        Since:
        1.0.0