Class Container
This is the Java implementation of CICS Containers.
Applications should use methods on the Channel class to obtain Containers.
For example:
Task t = Task.getTask();
Channel custData = t.createChannel("Customer_Data");
Container custRec = custData.createContainer("Customer_Record");
The string supplied to the createContainer() method is the name by which the Container object is known to CICS. The name is padded with spaces to 16 characters, if necessary, to conform to CICS naming conventions. If a container of the same name already exists in the channel, a ContainerErrorException is thrown.
A JCICS program that is passed a channel can access all the Container objects by using a Channel object without receiving the channel explicitly.
When a Channel object is instantiated, its getContainerNames() method returns a list of names of all the containers currently existing on this channel. When you have a container name, the container object can be obtained with the getContainer(java.lang.String,boolean) method. Use 'false' for the boolean parameter where no further checking for existence is required.
For example:
Task t = Task.getTask();
Channel chl = t.getCurrentChannel();
if (chl != null)
{
List<String> names = chl.getContainerNames();
for (String name : names)
{
Container custData = chl.getContainer(name, false);
// Process the container...
}
}
- See Also:
- Since CICS TS version:
- 3.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant for BIT type containersstatic final intConstant for CHAR type containersstatic final intThe maximum allowable length for a container name.static final intConstant for state that has yet been set -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(byte[] byteArrayData) Appends a byte[] to the end of the data in the Container.voidAppends a byte[] to the end of the data in the Container.voidappendString(String stringData) Appends a String to the end of the data in the Container.voiddelete()Delete the Container in CICS, and remove it from the owning Channel.booleanexists()Does the container exist in CICS yet ?byte[]get()Get the data from the Container.intget(byte[] destination, int sourceOffset, int length) Get a specified length of data at the given source offset from the Container into a pre-existing byte array.intget(byte[] destination, int destinationOffset, int theSourceOffset, int length) Get a specified length of data at the given source offset from the Container into the given destination offset in a pre-existing byte array.byte[]get(int sourceOffset, int length) Get a specified length of data at the given source offset from the Containerbyte[]Get the data from the Container.byte[]Get a specified length of data at the given source offset from the Container, converting the data from the source code page into the given destination code page.intgetCCSID()Get the CCSID value of the data returned by getNoConvert().intGet the datatype of this container.intGet the length of the data in the Container.intGet the length of the data in the Container.intGet the length of the data in the Container without conversion.getName()Get the name of the Container as known to CICS.byte[]Get the data from the Container without conversion.intgetNoConvert(byte[] destination, int sourceOffset, int length) Get a specified length of data at the given source offset from the Container into a pre-existing byte array.intgetNoConvert(byte[] destination, int destinationOffset, int theSourceOffset, int length) Get a specified length of data at the given source offset from the Container into the given destination offset in a pre-existing byte array.byte[]getNoConvert(int offset, int length) Get a specified length of data at the given source offset from the Container, without code page conversion.Get the data from a CICS Container and return it as a String.voidprepend(byte[] byteArrayData) Prepends a byte[] to the start of the data in the Container.voidPrepends a byte[] to the start of the data in the Container.voidprependString(String stringData) Prepends a String to the start of the data in the Container.voidput(byte[] byteArrayData) Puts byte[] array data into the Container.voidPuts byte[] array data into the Container.voidPuts String data into the Container.toString()Methods inherited from class com.ibm.cics.server.API
getCICSServerApiVersion
-
Field Details
-
NOTSET
public static final int NOTSETConstant for state that has yet been set- See Also:
- Since CICS TS version:
- 3.2
-
DATATYPE_BIT
public static final int DATATYPE_BITConstant for BIT type containers- See Also:
- Since CICS TS version:
- 3.2
-
DATATYPE_CHAR
public static final int DATATYPE_CHARConstant for CHAR type containers- See Also:
- Since CICS TS version:
- 3.2
-
MAX_CONTAINER_NAME_LENGTH
public static final int MAX_CONTAINER_NAME_LENGTHThe maximum allowable length for a container name.- See Also:
- Since CICS TS version:
- 6.1
-
-
Method Details
-
getName
Get the name of the Container as known to CICS.- Returns:
- The name of the Container.
- Since CICS TS version:
- 3.1
-
getString
public String getString() throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorExceptionGet the data from a CICS Container and return it as a String. This method replaces malformed-input and unmappable-character sequences with the default replacement string. If the container holds BIT data a CodePageErrorException is thrown.- Returns:
- String comprising the Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 5.1
-
get
public byte[] get() throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorExceptionGet the data from the Container.- Returns:
- byte[] array comprising the Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 3.1
-
get
public byte[] get(String targetCodePage) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get the data from the Container.- Parameters:
targetCodePage- is the code page in which the container data will be returned- Returns:
- byte[] array comprising the Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 3.2
-
get
public byte[] get(String targetCodePage, int sourceOffset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container, converting the data from the source code page into the given destination code page.- Parameters:
targetCodePage- the code page in which the container data will be returnedsourceOffset- the offset at which to begin reading data from the Container. If negative, 0 is assumedlength- length of data to retrieve starting at offset- Returns:
- byte[] array comprising the requested section of Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 5.1
-
get
public int get(byte[] destination, int sourceOffset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container into a pre-existing byte array.- Parameters:
destination- the byte array to populatesourceOffset- the offset at which to begin reading data from the Container. If negative, 0 is assumedlength- the length of data to retrieve from the Container- Returns:
- the actual length of data read
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGTHERR- Since CICS TS version:
- 5.6
-
get
public int get(byte[] destination, int destinationOffset, int theSourceOffset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container into the given destination offset in a pre-existing byte array.- Parameters:
destination- the byte array to populatedestinationOffset- the offset within the destination byte array at which to write outputtheSourceOffset- the offset at which to begin reading data from the Container. If negative, 0 is assumedlength- the length of data to retrieve from the Container- Returns:
- the actual length of data read
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGTHERR- Since CICS TS version:
- 5.6
-
get
public byte[] get(int sourceOffset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container- Parameters:
sourceOffset- start of the data (offset in bytes, 1 indexed). If negative, 0 is assumedlength- length of data to retrieve starting at offset- Returns:
- byte[] array comprising the requested section of Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 5.1
-
getNoConvert
public byte[] getNoConvert() throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorExceptionGet the data from the Container without conversion.- Returns:
- byte[] array comprising the Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 3.2
-
getNoConvert
public byte[] getNoConvert(int offset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container, without code page conversion.- Parameters:
offset- start of the data (offset in bytes, 0 indexed). If negative, 0 is assumedlength- length of data to retrieve starting at offset- Returns:
- byte[] array comprising the requested section of Container data.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 5.1
-
getNoConvert
public int getNoConvert(byte[] destination, int destinationOffset, int theSourceOffset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container into the given destination offset in a pre-existing byte array. Do so without incurring codepage conversion for a CHAR mode container.- Parameters:
destination- the byte array to populatedestinationOffset- the offset within the destination byte array at which to write outputtheSourceOffset- the offset at which to begin reading data from the Container. If negative, 0 is assumedlength- the length of data to retrieve from the Container- Returns:
- the actual length of data read
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 5.6
-
getNoConvert
public int getNoConvert(byte[] destination, int sourceOffset, int length) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException, LengthErrorException Get a specified length of data at the given source offset from the Container into a pre-existing byte array. Do so without incurring codepage conversion for a CHAR mode container.- Parameters:
destination- the byte array to populatesourceOffset- the offset at which to begin reading data from the Container. If negative, 0 is assumedlength- the length of data to retrieve from the Container- Returns:
- the actual length of data read
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERRLengthErrorException- LENGERR- Since CICS TS version:
- 5.6
-
exists
public boolean exists()Does the container exist in CICS yet ?- Returns:
- True if the container exists in CICS. False if it is only this java object where no underlying container currently exists in CICS. Perhaps this container has been created from the channel, and not written to. Or perhaps the container used to exist, but no longer does.
- Since CICS TS version:
- 6.1
-
getLength
public int getLength() throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorExceptionGet the length of the data in the Container. For a BIT mode container this is the length in bytes For a CHAR mode container this is the length in bytes of the data in the LOCALCCSID encoding.- Returns:
- The length of the data in the Container.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 3.1
-
getLength
public int getLength(String targetCodePage) throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorException Get the length of the data in the Container.- Parameters:
targetCodePage- is the code page into which the container data will be converted when retrieved from the container.- Returns:
- The length of the data in the Container.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 3.2
-
getLengthNoConvert
public int getLengthNoConvert() throws ContainerErrorException, ChannelErrorException, CCSIDErrorException, CodePageErrorExceptionGet the length of the data in the Container without conversion.- Returns:
- The length of the data in the Container.
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 3.2
-
getCCSID
public int getCCSID()Get the CCSID value of the data returned by getNoConvert(). If getNoConvert has not been issued then value NOTSET is returned.- Returns:
- The CCSID value of the data returned
- Since CICS TS version:
- 3.2
-
getDatatype
Get the datatype of this container. A Container.DATATYPE_BIT container is a block of binary data, much like a COMMAREA. There is no automatic code page conversion of the data. A Container.DATATYPE_CHAR container has an associated code page. When the data in the container is read, it is automatically converted from the container code page to the default code page for the CICS region.- Returns:
- The datatype of this container
- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERR- Since CICS TS version:
- 5.4
-
append
public void append(byte[] byteArrayData) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Appends a byte[] to the end of the data in the Container. The data is added immediately after any existing data in the Container. If no Container exists, a Container of type DATATYPE(BIT) is created and the Container attributes set.- Parameters:
byteArrayData- data to be appended to the existing data in the Container.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 5.1
-
append
public void append(byte[] byteArrayData, String sourceCodePage) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Appends a byte[] to the end of the data in the Container. The data is added immediately after any existing data in the Container. Data conversion is performed, if required, to convert the data to the code page of the first put(), append() or prepend() action performed. If no Container exists, a Container of type DATATYPE(CHAR) is created and the Container attributes set.- Parameters:
byteArrayData- data to be appended to the existing data in the Container.sourceCodePage- is the code page in which the byteArrayData is encoded.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 5.1
-
prepend
public void prepend(byte[] byteArrayData) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Prepends a byte[] to the start of the data in the Container. The data is added immediately before any existing data in the Container. If no Container exists, a Container of type DATATYPE(BIT) is created and the Container attributes set.- Parameters:
byteArrayData- data to be prepended to the existing data in the Container.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 6.2
-
prepend
public void prepend(byte[] byteArrayData, String sourceCodePage) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Prepends a byte[] to the start of the data in the Container. The data is added immediately before any existing data in the Container. Data conversion is performed, if required, to convert the data to the code page of the first put(), append() or prepend() action performed. If no Container exists, a Container of type DATATYPE(CHAR) is created and the Container attributes set.- Parameters:
byteArrayData- data to be appended to the existing data in the Container.sourceCodePage- is the code page in which the byteArrayData is encoded.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 6.2
-
put
public void put(byte[] byteArrayData) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Puts byte[] array data into the Container. Data in the Container is replaced by the put() method data. If no Container exists, a Container of type DATATYPE(BIT) is created and the Container attributes set. If the container already exists and is of type DATATYPE(CHAR), then CICS will assume that the byte[] array data was encoded in the LOCALCCSID of the CICS region.- Parameters:
byteArrayData- data to be put into the Container.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 3.1
-
put
public void put(byte[] byteArrayData, String sourceCodePage) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Puts byte[] array data into the Container. Data in the Container is replaced by the put() method data. Data conversion is performed, if required, to convert the data to the code page of the first put() or append() action performed. If put(byte[] byteArrayData, String fromCodePage) is used, the data is converted if it is encoded using a different code page to the code page associated with the Container. If put(byte[] byteArrayData) or put(String stringData) is used, the data is assumed to be in the CICS LOCALCCSID code page. Data conversion takes place only if the CICS LOCALCCSID code page is different to the code page associated with the container. If no Container exists, a Container of type DATATYPE(CHAR) is created, the Container attributes set, and the fromCodePage is associated with the container.- Parameters:
byteArrayData- data to be put into the Container.sourceCodePage- is the code page in which the byteArrayData is encoded.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 3.2
-
appendString
public void appendString(String stringData) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Appends a String to the end of the data in the Container. The data is added immediately after any existing data in the Container. If no Container exists, a Container of type DATATYPE(CHAR) is created and the Container attributes set. If the container is of type BIT an InvalidRequestException is returned.- Parameters:
stringData- data to be put into the Container.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 5.1
-
prependString
public void prependString(String stringData) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Prepends a String to the start of the data in the Container. The data is added immediately before any existing data in the Container. If no Container exists, a Container of type DATATYPE(CHAR) is created and the Container attributes set. If the container is of type BIT an InvalidRequestException is returned.- Parameters:
stringData- data to be put into the Container.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 6.2
-
putString
public void putString(String stringData) throws ContainerErrorException, ChannelErrorException, InvalidRequestException, CCSIDErrorException, CodePageErrorException Puts String data into the Container. Data in the Container is replaced by the putString() method data. If no Container exists, a Container of type DATATYPE(CHAR) is created and the Container attributes set. To create an empty container specify "" rather than null. This method replaces the now deleted put(String) method. If the container is of type BIT an InvalidRequestException is returned.- Parameters:
stringData- data to be put into the Container.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQCCSIDErrorException- CCSIDERRCodePageErrorException- CODEPAGEERR- Since CICS TS version:
- 5.1
-
delete
Delete the Container in CICS, and remove it from the owning Channel.- Throws:
ContainerErrorException- CONTAINERERRChannelErrorException- CHANNELERRInvalidRequestException- INVREQ- Since CICS TS version:
- 3.1
-
toString
-