Class DataSetReader
- java.lang.Object
-
- java.io.Reader
-
- com.compuware.api.topaz.hostresources.zos.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 theDataSetReader
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 aDataSetReader
. 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.
-
-
Constructor Summary
Constructors Constructor Description DataSetReader(IZOSHostConnection zosHostConnection, String sequentialDataSetName)
Constructs aDataSetReader
using the specified z/OS host connection and sequential dataset name.DataSetReader(ISequentialDataSet sequentialDataSet)
Constructs aDataSetReader
using the specified sequential dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
containsNonDisplayableData()
Returns whether non-displayable binary data exists within the text of this reader.char
getReplacementCharacter()
Returns the replacement character for non-displayable binary data.int
read(char[] dataBuffer, int offset, int length)
-
Methods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, read, ready, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
DataSetReader
public DataSetReader(ISequentialDataSet sequentialDataSet) throws DataSetAccessException, DataSetInUseException, DataSetMigratedException, DataSetNotFoundException
Constructs aDataSetReader
using the specified sequential dataset.This dataset reader can be used to read the content of the specified sequential dataset in UTF-8 characters. This is ideally used for reading sequential datasets that contain displayable characters.
Non-displayable binary data will be substituted with a replacement character for display purposes.
- Parameters:
sequentialDataSet
- the sequential dataset to read- Throws:
IllegalArgumentException
- ifsequentialDataSet
isnull
HostIOException
- if anIOException
occurs reading the datasetZOSSystemException
- if a z/OS system error occursZOSAbendException
- if a z/OS ABEND occursDataSetAccessException
- if the user's credentials do not grant access authority for the sequential datasetDataSetInUseException
- if an exclusive enqueue exists on the sequential datasetDataSetMigratedException
- if the sequential dataset is migrated (this may occur if the dataset is migrated after it is retrieved from the z/OS host)DataSetNotFoundException
- if the sequential dataset no longer exists (this may occur if the dataset is deleted after it is retrieved from the z/OS host)- Since:
- 1.0.0
- See Also:
ISequentialDataSet
-
DataSetReader
public DataSetReader(IZOSHostConnection zosHostConnection, String sequentialDataSetName) throws DataSetAccessException, DataSetInUseException, DataSetMigratedException, DataSetNotFoundException
Constructs aDataSetReader
using the specified z/OS host connection and sequential dataset name.This dataset reader can be used to read the content of the specified sequential dataset in UTF-8 characters. This is ideally used for reading sequential datasets that contain displayable characters.
Non-displayable binary data will be substituted with a replacement character for display purposes.
- Parameters:
zosHostConnection
- a connection to the z/OS host on which the sequential dataset residessequentialDataSetName
- the name of the sequential dataset to read- Throws:
IllegalArgumentException
- ifzosHostConnection
isnull
, or ifsequentialDataSetName
isnull
or invalidHostIOException
- if anIOException
occurs reading the sequential datasetHostNotConnectedException
- ifzosHostConnection
is not connectedZOSSystemException
- if a z/OS system error occursZOSAbendException
- if a z/OS ABEND occursDataSetAccessException
- if the user's credentials do not grant access authority for the sequential datasetDataSetInUseException
- if an exclusive enqueue exists on the sequential datasetDataSetMigratedException
- if the sequential dataset is migratedDataSetNotFoundException
- if the sequential dataset does not exist- Since:
- 1.0.0
- See Also:
IZOSHostConnection
-
-
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
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
- Since:
- 1.0.0
-
read
public int read(char[] dataBuffer, int offset, int length) throws IOException
- Specified by:
read
in classReader
- Throws:
IOException
- Since:
- 1.0.0
-
-