Examples of storing values in an MQeFields item, and retrieving
values from an MQeFields item
The following example shows how to store values in an
MQeFields item:
- Java™ code
-
/* Store integer values into a fields object */
fields.putInt( "Int1", 1234 );
fields.putInt( "Int2", 5678 );
fields.putInt( "Int3", 0 );
- C code
-
MQeStringHndl hFieldName;
rc = mqeString_newChar8(&errStruct, &hFieldName, "A Field Name");
rc = mqeFields_putInt32(hNewFields,&errStruct,hFieldName,1234);
The following example shows how to retrieve values from an
MQeFields item:
- Java code
-
/* Retrieve an integer value from a fields object */
int Int2 = fields.getInt( "Int2" );
- C code
-
MQEINT32 value;
rc = mqeFields_getInt32(hNewFields, &errStruct, &value, hFieldName);
MQe provides methods for storing and retrieving the
following data types:
- A fixed length array is handled using the putArrayOftype and getArrayOftype methods,
where type can be Byte, Short, Int, Long, Float, or Double.
- The ability to store variable length arrays is possible, but has been
deprecated in this release. You can access these arrays using the Java puttypeArray and gettypeArray calls or the C puttype calls.
- The Java code base has a slightly special form of operations
for Float and Double types. This provides compatibility with the MicroEdition.
Floats are put using an Int representation and Doubles are put using a Long
representation. Use the Float.floatToIntBits() and Double.doubleToLongBits() to
perform the conversion. However, this is not required
on the C API.