Class MemberWriter
- java.lang.Object
-
- java.io.Writer
-
- com.compuware.api.topaz.hostresources.zos.MemberWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
public class MemberWriter extends Writer
Writes text to a z/OS member, providing for the efficient writing of characters.When an instance is constructed, an exclusive enqueue will be obtained on the associated member. 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 member records, it is advisable to wrap a
BufferedWriter
around aMemberWriter
. For example,BufferedWriter out = new BufferedWriter(new MemberWriter(...));
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 (-).
A PDS member name is considered invalid if:
- The length of the name is 0 or is greater than 8 characters.
- Any characters outside of the code page 1047 hex values for A-Z, a-z, 0-9, @, #, or $ are present.
- The name starts with a digit (0-9).
- Since:
- 1.1.0
- Version:
- 2.0.0
- See Also:
IPartitionedDataSetMember
- Restriction:
- This class is not intended to be extended by clients.
-
-
Constructor Summary
Constructors Constructor Description MemberWriter(IZOSHostConnection zosHostConnection, String pdsName, String memberName)
Constructs aMemberWriter
using the specified z/OS host connection, partitioned dataset name, and member name.MemberWriter(IPartitionedDataSetMember pdsMember)
Constructs aMemberWriter
using the specified partitioned dataset member.
-
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
-
MemberWriter
public MemberWriter(IPartitionedDataSetMember pdsMember) throws DataSetAccessException, DataSetInUseException, DataSetMigratedException, DataSetNotFoundException, MemberNotFoundException, MemberInUseException
Constructs aMemberWriter
using the specified partitioned dataset member.This member writer can be used to write UTF-8 characters to the specified partitioned dataset member. This is ideally used for writing displayable characters to a partitioned dataset member.
This constructor will attempt to obtain an exclusive enqueue on the specified partitioned dataset member.
- Parameters:
pdsMember
- the partitioned dataset member to write to- Throws:
IllegalArgumentException
- ifpdsMember
isnull
HostIOException
- if anIOException
occurs writing to the partitioned dataset memberZOSSystemException
- 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 parent partitioned datasetDataSetInUseException
- if an exclusive enqueue exists on the parent partitioned datasetDataSetMigratedException
- if the parent partitioned dataset is migrated (this may occur if the dataset is migrated after it is retrieved from the z/OS host)DataSetNotFoundException
- if the parent partitioned dataset no longer exists (this may occur if the dataset is deleted after it is retrieved from the z/OS host)MemberNotFoundException
- if the partitioned dataset member no longer exists (this may occur if the member is deleted after it is retrieved from the z/OS host)MemberInUseException
- if an exclusive enqueue exists on the partitioned dataset member- Since:
- 1.0.0
- See Also:
IPartitionedDataSetMember
-
MemberWriter
public MemberWriter(IZOSHostConnection zosHostConnection, String pdsName, String memberName) throws DataSetAccessException, DataSetInUseException, DataSetMigratedException, DataSetNotFoundException, MemberNotFoundException, MemberInUseException
Constructs aMemberWriter
using the specified z/OS host connection, partitioned dataset name, and member name.This member writer can be used to write UTF-8 characters to the specified partitioned dataset member. This is ideally used for writing displayable characters to a partitioned dataset member.
This constructor will attempt to obtain an exclusive enqueue on the specified partitioned dataset member.
- Parameters:
zosHostConnection
- a connection to the z/OS host on which the partitioned dataset member residespdsName
- the name of the partitioned datasetmemberName
- the name of the member to write to- Throws:
IllegalArgumentException
- ifzosHostConnection
isnull
, ifpdsName
isnull
or invalid, or ifmemberName
isnull
or invalidHostIOException
- if anIOException
occurs writing to the partitioned 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 partitioned datasetDataSetInUseException
- if an exclusive enqueue exists on the partitioned datasetDataSetMigratedException
- if the partitioned dataset is migratedDataSetNotFoundException
- if the partitioned dataset does not existMemberNotFoundException
- if the partitioned dataset member does not existMemberInUseException
- if an exclusive enqueue exists on the partitioned dataset member- Since:
- 1.0.0
- See Also:
IPartitionedDataSetMember
-
-
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
-
-