Class DataSetWriter
- java.lang.Object
-
- java.io.Writer
-
- com.compuware.api.topaz.hostresources.zos.DataSetWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class DataSetWriter extends Writer
Writes text to a z/OS dataset, providing for the efficient writing of characters.When an instance is constructed, an exclusive enqueue will be obtained on the associated dataset. If an enqueue could not be obtained, an exception will be thrown.
The data written must be in UTF-8 encoding and will be encoded using the code page specified in the credentials of the associated host. If any binary characters were mapped to UTF-8 (see DataSetReader), they will be translated back to binary bytes. If unmappable characters are part of any write, an exception will be thrown and the text will not be written.
If the logical record length of the dataset is exceeded during any write, an exception will be thrown and the text will not be written.
When close is called, the data will be written on the host and the enqueue will be released.
For efficient writing of dataset records, it is advisable to wrap a
BufferedWriter
around aDataSetWriter
. For example,BufferedWriter out = new BufferedWriter(new DataSetWriter(...));
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.1.0
- Version:
- 2.0.0
- See Also:
ISequentialDataSet
- Restriction:
- This class is not intended to be extended by clients.
-
-
Constructor Summary
Constructors Constructor Description DataSetWriter(IZOSHostConnection zosHostConnection, String sequentialDataSetName)
Constructs aDataSetWriter
using the specified z/OS host connection and sequential dataset name.DataSetWriter(ISequentialDataSet sequentialDataSet)
Constructs aDataSetWriter
using the specified sequential dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(char[] dataBuffer, int offset, int length)
Writes a portion of an array of characters.
-
-
-
Constructor Detail
-
DataSetWriter
public DataSetWriter(ISequentialDataSet sequentialDataSet) throws DataSetAccessException, DataSetInUseException, DataSetMigratedException, DataSetNotFoundException
Constructs aDataSetWriter
using the specified sequential dataset.This dataset writer can be used to write UTF-8 characters to the specified sequential dataset. This is ideally used for writing displayable characters to a sequential dataset.
This constructor will attempt to obtain an exclusive enqueue on the specified sequential datatset.
- Parameters:
sequentialDataSet
- the sequential dataset to write to- Throws:
IllegalArgumentException
- ifsequentialDataSet
isnull
HostIOException
- if anIOException
occurs writing to 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
-
DataSetWriter
public DataSetWriter(IZOSHostConnection zosHostConnection, String sequentialDataSetName) throws DataSetAccessException, DataSetInUseException, DataSetMigratedException, DataSetNotFoundException
Constructs aDataSetWriter
using the specified z/OS host connection and sequential dataset name.This dataset writer can be used to write UTF-8 characters to the specified sequential dataset. This is ideally used for writing displayable characters to a sequential dataset.
This constructor will attempt to obtain an exclusive enqueue on the specified sequential datatset.
- Parameters:
zosHostConnection
- a connection to the z/OS host on which the sequential dataset residessequentialDataSetName
- the name of the sequential dataset to write to- Throws:
IllegalArgumentException
- ifzosHostConnection
isnull
, or ifsequentialDataSetName
isnull
or invalidHostIOException
- if anIOException
occurs writing to 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
-
write
public void write(char[] dataBuffer, int offset, int length) throws IOException
Writes a portion of an array of characters.- Specified by:
write
in classWriter
- Parameters:
dataBuffer
- the array of charactersoffset
- the offset from which to start writing characterslength
- the number of characters to write- Throws:
UnmappableCharacterException
- if one or more UTF-8 characters exist in the given character buffer that do not map into the code page associated with the hostMalformedInputException
- if non-displayable binary data exists in the given character buffer (x00 - x3F, shift-out (x0E) and shift-in (x0F) are not considered invalid for double-byte (DBCS) code pages)LogicalRecordLengthExceededException
- if the data will exceed the logical record length of the sequential datasetIOException
- if any other I/O error occurs- Since:
- 1.0.0
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
- Since:
- 1.0.0
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
- Since:
- 1.0.0
-
-