|
Websphere MQ Everyplace | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.mqe.MQe | +--com.ibm.mqe.MQeFields
This class is used to create a basic MQeFields object. This object is used to hold various data items and provide mechanisms to dump and restore these field items to or from a byte array.
Field items are assigned a character name at the time they are added to the MQeFields object. This name must:
Note : These rules are not enforced but the results are unpredictable if they are not followed.
This class is a descendant of MQe
Field Summary | |
static char |
ArraySeparator
Constant representing the Array Separator used in Dynamic Arrays. |
static char |
TypeArrayElements
The datatype of a Field representing data which is a dynamic array. |
static char |
TypeAscii
The datatype of a Field representing data of type 'Ascii'. |
static char |
TypeBoolean
The datatype of a Field representing data of type 'boolean'. |
static char |
TypeByte
The datatype of a Field representing data of type 'byte'. |
static char |
TypeDouble
The datatype of a Field representing data of type 'double'. |
static char |
TypeFields
The datatype of a Field representing data which is an embedded MQeFields Object. |
static char |
TypeFloat
The datatype of a Field representing data of type 'float'. |
static char |
TypeInt
The datatype of a Field representing data of type 'int'. |
static char |
TypeLong
The datatype of a Field representing data of type 'long'. |
static char |
TypeShort
The datatype of a Field representing data of type 'short'. |
static char |
TypeUnicode
The datatype of a Field representing data of type 'Unicode'. |
static char |
TypeUnTyped
The datatype of a Field representing data of unknown type. |
Constructor Summary | |
MQeFields()
Default constructor which creates an empty MQeFields object. |
|
MQeFields(byte[] data)
Constructor with a byte array. |
Method Summary | |
boolean |
contains(java.lang.String item)
Verifies that the field exists within the object. |
void |
copy(MQeFields from,
boolean replace)
Copies all fields. |
void |
copy(MQeFields from,
boolean replace,
java.lang.String item)
Copies an individual field. |
char |
dataType(java.lang.String item)
Determines the data type of a field in the object. |
MQeFields |
deepCopy()
Creates a deep copy of this MQeFields object. |
void |
delete(java.lang.String item)
Removes a field from the object. |
byte[] |
dump()
This method dumps the contents of this MQeFields object to a byte array, so that is can be restored using the restore() method. |
static java.lang.String |
dumpedType(byte[] data)
Returns the object type of the dumped MQeFields object. |
java.lang.String |
dumpToString(java.lang.String template)
Produces a human readable representation of the contents of the MQeFields object. |
boolean |
equals(java.lang.Object match)
Deprecated. The equals() method will change in the next release to conform with the Java Language Specification. Please use either the includes() method or the isEqualTo() method instead. |
java.util.Enumeration |
fields()
Returns an enumeration of all the fields in the object. |
int |
getArrayLength(java.lang.String item)
Extracts the length value of a dynamic array of specified fields. |
byte[] |
getArrayOfByte(java.lang.String item)
Extracts a fixed size array of bytes. |
long[] |
getArrayOfDoubleAsLong(java.lang.String item)
Returns an array of long representing an array of double. |
int[] |
getArrayOfFloatAsInt(java.lang.String item)
Returns an array of int representing an array of float. |
int[] |
getArrayOfInt(java.lang.String item)
Returns an array of int. |
long[] |
getArrayOfLong(java.lang.String item)
Returns an array of long. |
short[] |
getArrayOfShort(java.lang.String item)
Returns an array of short. |
java.lang.String |
getAscii(java.lang.String item)
Extracts an Ascii string from the MQeFields object. |
java.lang.String[] |
getAsciiArray(java.lang.String item)
Extracts an Ascii array of strings from the MQeFields object. |
MQeAttribute |
getAttribute()
Extracts the current attribute object reference associated with this MQeFields object. |
boolean |
getBoolean(java.lang.String item)
Extracts a boolean value or null. |
byte |
getByte(java.lang.String item)
Extracts a byte value. |
long |
getDoubleAsLong(java.lang.String item)
Returns a long representing a double. |
MQeFields |
getFields(java.lang.String item)
Extracts an embedded MQeFields object. |
MQeFields[] |
getFieldsArray(java.lang.String item)
Extracts a dynamic size array of MQeFields objects. |
int |
getFloatAsInt(java.lang.String item)
Returns an int representing a float. |
int |
getInt(java.lang.String item)
Extracts an integer. |
int[] |
getIntArray(java.lang.String item)
Deprecated. Use getArrayOfInt. |
long |
getLong(java.lang.String item)
Extracts a long integer. |
long[] |
getLongArray(java.lang.String item)
Deprecated. Use getArrayOfLong. |
java.lang.Object |
getObject(java.lang.String item)
Deprecated. |
short |
getShort(java.lang.String item)
Extracts a short integer. |
short[] |
getShortArray(java.lang.String item)
Deprecated. Use getArrayOfShort. |
java.lang.String |
getUnicode(java.lang.String item)
Extracts a Unicode string. |
java.lang.String[] |
getUnicodeArray(java.lang.String item)
Extracts a dynamic size array of Unicode strings. |
boolean |
includes(MQeFields match)
Checks whether an object has a match with an MQeFields object field. |
boolean |
isEqualTo(java.lang.Object match)
Checks for equality between MQeFields objects. |
void |
putArrayLength(java.lang.String item,
int value)
Sets the length value of a dynamic array of fields. |
void |
putArrayOfByte(java.lang.String item,
byte[] itemData)
Sets a fixed size array of bytes. |
void |
putArrayOfDoubleAsLong(java.lang.String item,
long[] itemData)
Adds an array of long representing an array of double. |
void |
putArrayOfFloatAsInt(java.lang.String item,
int[] itemData)
Adds an array of int representing an array of float. |
void |
putArrayOfInt(java.lang.String item,
int[] itemData)
Adds an array of int. |
void |
putArrayOfLong(java.lang.String item,
long[] itemData)
Adds an array of long. |
void |
putArrayOfShort(java.lang.String item,
short[] itemData)
Adds an array of short. |
void |
putAscii(java.lang.String item,
java.lang.String itemData)
Sets a string containing Ascii characters. |
void |
putAsciiArray(java.lang.String item,
java.lang.String[] data)
Sets a dynamic size array of strings containing Ascii characters. |
void |
putBoolean(java.lang.String item,
boolean itemData)
Sets a boolean value. |
void |
putByte(java.lang.String item,
byte itemData)
This method sets the data in the MQeFields object for the supplied byte. |
void |
putByteArray(java.lang.String item,
byte[][] data)
Adds an array of byte arrays. |
void |
putDoubleAsLong(java.lang.String item,
long itemData)
Adds a long representing a double field. |
void |
putFields(java.lang.String item,
MQeFields theseFields)
Sets an embedded MQeFields object. |
void |
putFieldsArray(java.lang.String item,
MQeFields[] data)
Sets an array of MQeFields objects. |
void |
putFloatAsInt(java.lang.String item,
int itemData)
Adds an int representing a float field. |
void |
putInt(java.lang.String item,
int itemData)
Sets an integer. |
void |
putIntArray(java.lang.String item,
int[] data)
Deprecated. Use putArrayOfInt. |
void |
putLong(java.lang.String item,
long itemData)
Sets a long integer. |
void |
putLongArray(java.lang.String item,
long[] data)
Deprecated. Use putArrayOfLong. |
void |
putObject(java.lang.String item,
java.lang.Object itemData)
Deprecated. |
void |
putShort(java.lang.String item,
short itemData)
Sets a short integer. |
void |
putShortArray(java.lang.String item,
short[] data)
Deprecated. Use putArrayOfShort. |
void |
putUnicode(java.lang.String item,
java.lang.String itemData)
Sets a string containing Unicode characters. |
void |
putUnicodeArray(java.lang.String item,
java.lang.String[] data)
Sets a dynamic size array of strings containing Unicode characters. |
void |
rename(java.lang.String item,
java.lang.String newName)
Renames an item held within the MQeFields object. |
void |
restore(byte[] data)
This method restores a MQeFields object from a byte array that was created using the dump method. |
void |
restoreFromString(java.lang.String template,
java.lang.String data)
Restores the contents of an MQeFields object from an Ascii string. |
void |
restoreFromString(java.lang.String endRecord,
java.lang.String template,
java.lang.String data)
Restores the contents of an MQeFields object from an Ascii string. |
static MQeFields |
restoreFromString(java.lang.String endRecord,
java.lang.String sectionMatch,
java.lang.String template,
java.lang.String data)
Restores the contents of an MQeFields object from an Ascii string. |
void |
setAttribute(MQeAttribute attribute)
Assigns an attribute object to an MQeFields object. |
long |
updateValue(java.lang.String item,
long update)
Updates (increments or decrements) an integer type value within an MQeFields object. |
Methods inherited from class com.ibm.mqe.MQe |
abbreviate, alias, asciiToByte, byteToAscii, byteToHex, byteToHex, byteToInt, byteToLong, byteToShort, byteToUnicode, fileSeparator, getEventLogHandler, hexToAscii, hexToByte, intToByte, isCLDC, loadClass, loadObject, log, setEventLogHandler, setLoader, sliceByteArray, type, unicodeToByte, uniqueValue |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final char ArraySeparator
public static final char TypeUnTyped
public static final char TypeAscii
public static final char TypeUnicode
public static final char TypeBoolean
public static final char TypeByte
public static final char TypeShort
public static final char TypeInt
public static final char TypeLong
public static final char TypeFloat
The float value has to be converted to an int prior to addition into an MQeFields Object
public static final char TypeDouble
The double value has to be converted to a long prior to addition into an MQeFields Object.
public static final char TypeArrayElements
Note : The specific datatype of the array can be retrieved by inquiring on one of the elements held within the dynamic array.
public static final char TypeFields
Constructor Detail |
public MQeFields()
Default constructor which creates an empty MQeFields object.
The call to the ancestor constructor will increment the MQe object counter.
MQeFields myFields = new com.ibm.mqe.MQeFields();
public MQeFields(byte[] data) throws java.lang.Exception
Constructor with a byte array. This restores an MQeFields object from the
supplied byte array.
The call to the ancestor constructor will increment the MQe object counter.
data
- A byte array containing a dumped MQeFields object.
MQeException
- Except_Type, Except_Data, Except_NotFound
java.lang.Exception
- anything thrown by attribute.decodeData()Method Detail |
public boolean contains(java.lang.String item)
Verifies that the field exists within the object.
This method verifies that a field exists within the MQeFields object.
item
- The name of the item to be checked.
boolean Contains = false; MQeFields msg = new MQeFields(); try { msg.putAscii("Data", "This is some data"); if (msg.contains("Data")) { Contains = true; } } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return Contains;
public void copy(MQeFields from, boolean replace) throws java.lang.Exception
Copies all fields.
This method copies a reference to all fields from one
MQeFields object to another.
from
- The MQeFields object to be used as the source of the data, must not be null.replace
- A boolean controlling whether a field is to be replaced or not.
MQeException
- Except_Duplicate
java.lang.Exception
public void copy(MQeFields from, boolean replace, java.lang.String item) throws java.lang.Exception
Copies an individual field.
The boolean value replace , if set to false , throws an exception if the
field already exists within the target MQeFields object, if set to true ,
it replaces the value that already exists.
from
- The MQeFields object to be used as the source of the data, must not be null.replace
- A boolean controlling whether a field is to be replaced or not.item
- The name of a single field to be copied.
MQeException
- Except_Duplicate, Except_NotFound
java.lang.Exception
MQeFields fields1 = new MQeFields(); MQeFields fields2 = new MQeFields(); try { fields1.putAscii("data", "This is some data"); fields2.copy(fields1, true, "data"); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); }
public char dataType(java.lang.String item) throws java.lang.Exception
Determines the data type of a field in the object.
This method returns the data type of a field within the MQeFields object.
item
- The name of the item to be checked.
public final static char TypeUnTyped public final static char TypeAscii public final static char TypeUnicode public final static char TypeBoolean public final static char TypeByte public final static char TypeShort public final static char TypeInt public final static char TypeLong public final static char TypeFloat public final static char TypeDouble public final static char TypeArrayElements public final static char TypeFields
MQeException
- Except_NotFound
java.lang.Exception
MQeFields msg = new MQeFields(); char DataType = ' '; try { msg.putAscii("Data", "This is some data"); if (msg.dataType("Data") == msg.TypeAscii) { DataType = msg.TypeAscii;// perform the necessary action here } } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return DataType;
public MQeFields deepCopy() throws java.lang.Exception
java.lang.ClassNotFoundException
MQeException
- Except_Type, Except_Data, Except_NotFound
java.lang.Exception
- anything thrown by attribute.decodeData()public void delete(java.lang.String item)
Removes a field from the object.
This method deletes an existing field from the MQeFields object.
item
- The name of the item to be removed.
MQeFields msg = new MQeFields(); try { msg.putAscii("Data", "This is some data"); msg.delete("Data"); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); }
public byte[] dump() throws java.lang.Exception
MQeException
- Except_Data, Except_NotAllowed, Except_Not_Found
java.lang.Exception
byte dumpData[] = null; MQeFields msg = new MQeFields(); try { msg.putAscii("Data", "This is some data"); dumpData = msg.dump(); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return dumpData; MQeFields fields = new MQeFields(); String data = " "; try { fields.putBoolean("tb", true); fields.putLong("ml", -1); data = fields.dumpToString("Test1.obj (#0)\t#1 \t=#2 \r \n"); System.out.println(fields.dumpToString("Test1.obj (#0)\t#1 \t=#2 \r \n")); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } byte dumpdata[] = new byte[0]; String ObjType = " "; MQeFields fields = new MQeFields(); try { fields.putAscii("Data", "This is some data"); dumpdata = fields.dump(); ObjType = fields.dumpedType(dumpdata); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return ObjType;
public static java.lang.String dumpedType(byte[] data) throws java.lang.Exception
Returns the object type of the dumped MQeFields object.
This method returns a String containing the class name of the MQeFields object that
was dumped.
data
- A byte array containing a dump of an MQeFields object.
java.lang.ClassNotFoundException
MQeException
- Except_Type, Except_Data, Except_NotFound
java.lang.Exception
- anything thrown by attribute.decodeData()byte dumpdata[] = new byte[0]; String ObjType = " "; MQeFields fields = new MQeFields(); try { fields.putAscii("Data", "This is some data"); dumpdata = fields.dump(); ObjType = fields.dumpedType(dumpdata); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return ObjType;
public java.lang.String dumpToString(java.lang.String template) throws java.lang.Exception
Produces a human readable representation of the contents of the
MQeFields object.
This method dumps the MQeFields object in human readable form and
returns the data as a String.
template
- A String template used when formatting the output.
The template should have 3 insert sequences ’#n’. That is :
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); String data = " "; try { fields.putBoolean("tb", true); fields.putLong("ml", -1); data = fields.dumpToString("Test1.obj (#0)\t#1 \t=#2 \r \n"); System.out.println(fields.dumpToString("Test1.obj (#0)\t#1 \t=#2 \r \n")); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); }
public boolean equals(java.lang.Object match)
Performs an equality test with another object.
equals
in class java.lang.Object
match
- An object to be compared with the MQeFields object.
If the parameter is not an MQeFields object, the value of super.equals(match)
is returned.
boolean Equals = false; MQeFields fields = new MQeFields(); MQeFields test = new MQeFields(); try { fields.putAscii("Data1", "This is some data"); fields.putAscii("Data2", "This is more data"); test.putAscii("Data1", "This is some data"); if (fields.isEqualTo(test)) //should return true Equals = true; else Equals = false; } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return Equals;
public java.util.Enumeration fields()
Returns an enumeration of all the fields in the object.
This method returns an enumeration object that contains all the field
names within the object.
MQeFields fields = new MQeFields(); Enumeration names = null; try { fields.putAscii("data", "This is some data"); names = fields.fields(); } catch (Exception e) { System.err.println("Failure ! " + e.toString()); } return names;
public int getArrayLength(java.lang.String item) throws java.lang.Exception
Extracts the length value of a dynamic array of specified fields.
This extracts the dynamic array length of the specified item. An
exception is thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(dumpdata); numElements = fields.getArrayLength("Data"); return numElements;
public byte[] getArrayOfByte(java.lang.String item) throws java.lang.Exception
Extracts a fixed size array of bytes.
This extracts an array of bytes data from the MQeFields object. An
exception is thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); dumpdata = fields.getArrayOfByte("Data"); return dumpdata;
public long[] getArrayOfDoubleAsLong(java.lang.String item) throws java.lang.Exception
Returns an array of long representing an array of double.
item
- - a String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public int[] getArrayOfFloatAsInt(java.lang.String item) throws java.lang.Exception
Returns an array of int representing an array of float.
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public int[] getArrayOfInt(java.lang.String item) throws java.lang.Exception
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public long[] getArrayOfLong(java.lang.String item) throws java.lang.Exception
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public short[] getArrayOfShort(java.lang.String item) throws java.lang.Exception
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public java.lang.String getAscii(java.lang.String item) throws java.lang.Exception
Extracts an Ascii string from the MQeFields object.
This extracts the Ascii data from the MQeFields object and returns it
as a string. An exception is thrown if there is no data or it is of the
wrong data type.
Note:The item parameter is a java Unicode string, which must only
contain character codes that appear in the invariant part of the Ascii code
pages (characters with values between 32 and 127 inclusive, not including
{}[]#():;'"=). If you attempt to pass variant character codes, these codes
are subject to translations between machines when different codepages are used
to manipulate the data, possibly resulting in unpredictable results. If you wish
to pass variant character codes in an WebSphere MQ Everyplace message, we recommend
you use the putArrayOfByte() method and handle your own codepage
translations between machines , or putUnicode() method where no codepage
translations is required.
item
- The name of the item to be retrieved.
MQeException
- Except_Type, Except_Not_Found
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getAscii("Data"); return data; MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getAsciiArray("Data"); return data;
public java.lang.String[] getAsciiArray(java.lang.String item) throws java.lang.Exception
Extracts an Ascii array of strings from the MQeFields object.
This extracts the Ascii data (see note in getAscii() method description)
from the MQeFields object and returns it as an array of strings. An
exception is thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getAsciiArray("Data"); return data;
public MQeAttribute getAttribute()
Extracts the current attribute object reference associated with this MQeFields object.
This method returns an MQeAttribute
object reference
associated with this MQeFields object, or null if there is no attribute.
MQeAttribute
object reference.MQeAttribute thisAttribute = null; MQeFields fields = new MQeFields(); thisAttribute = fields.getAttribute(); return thisAttribute;
public boolean getBoolean(java.lang.String item) throws java.lang.Exception
Extracts a boolean value or null.
This extracts a boolean value from the MQeFields object. An exception is
thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getBoolean("Data"); return data;
public byte getByte(java.lang.String item) throws java.lang.Exception
Extracts a byte value.
This extracts a byte of data from the MQeFields object. An exception is
thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getByte("Data"); return data; MQeFields fields =new MQeFields(); fields.restore(dumpdata ); byte data []=fields.getByteArray("Data");
public long getDoubleAsLong(java.lang.String item) throws java.lang.Exception
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getDoubleAsLong("Data");
public MQeFields getFields(java.lang.String item) throws java.lang.Exception
Extracts an embedded MQeFields object.
This extracts a field item from the MQeFields object. An exception is
thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getFields("Data"); MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getFieldsArray("Data");
public MQeFields[] getFieldsArray(java.lang.String item) throws java.lang.Exception
Extracts a dynamic size array of MQeFields objects.
This extracts a dynamic array of field objects from the MQeFields object
and returns it as an array. The length of the array is determined by the
ArrayLength value for this item. An exception is thrown if there is no
data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getFieldsArray("Data");
public int getFloatAsInt(java.lang.String item) throws java.lang.Exception
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getFloatAsInt("Data");
public int getInt(java.lang.String item) throws java.lang.Exception
Extracts an integer.
This extracts an int length integer value item from the MQeFields object.
An exception is thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getInt("Data"); MQeFields fields =new MQeFields(); fields.restore(dumpdata ); int data []=fields.getIntArray("Data");
public int[] getIntArray(java.lang.String item) throws java.lang.Exception
Returns an array of int.
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public long getLong(java.lang.String item) throws java.lang.Exception
Extracts a long integer.
This extracts an long length integer value item from the MQeFields object.
An exception is thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getLong("Data"); MQeFields fields =new MQeFields(); fields.restore(dumpdata ); long data []=fields.getLongArray("Data");
public long[] getLongArray(java.lang.String item) throws java.lang.Exception
Returns an array of long.
item
- A String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public java.lang.Object getObject(java.lang.String item) throws java.lang.Exception
Returns a field object.
This method returns a field object from an array of MQeFields object.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
public short getShort(java.lang.String item) throws java.lang.Exception
Extracts a short integer.
This extracts a short length integer value item from the MQeFields object.
An exception is thrown if there is no data or it is of the wrong data type.
item
- The name of the item to be retrieved
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getShort("Data"); MQeFields fields =new MQeFields(); fields.restore(dumpdata ); short data []=fields.getShortArray("Data");
public short[] getShortArray(java.lang.String item) throws java.lang.Exception
item
- - a String containing the name of the item
MQeException
- Except_NotFound
java.lang.Exception
public java.lang.String getUnicode(java.lang.String item) throws java.lang.Exception
Extracts a Unicode string.
This extracts the Unicode data from the MQeFields object and returns it as a
string. An exception is thrown if there is no data or it is of the wrong data
type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getUnicode("Data"); MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getUnicodeArray("Data");
public java.lang.String[] getUnicodeArray(java.lang.String item) throws java.lang.Exception
Extracts a dynamic size array of Unicode strings.
This extracts the Unicode data from the MQeFields object and returns it as an
array of strings. An exception is thrown if there is no data or it is of the
wrong data type.
item
- The name of the item to be retrieved.
MQeException
- Except_NotFound
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); data = fields.getUnicodeArray("Data");
public void putArrayLength(java.lang.String item, int value) throws java.lang.Exception
Sets the length value of a dynamic array of fields.
This sets the dynamic array length of the specified item.
item
- The name of the item to be set.
java.lang.Exception
- Doesn't throw anythingMQeFields fields = new MQeFields(dumpdata); fields.putArrayLength("Data", 5);
public void putArrayOfByte(java.lang.String item, byte[] itemData) throws java.lang.Exception
Sets a fixed size array of bytes.
This method sets the data in the MQeFields object for the supplied byte array.
item
- The name of the item to be set.
MQeException
- Except_Not_Found
java.lang.Exception
MQeFields fields = new MQeFields(); fields.putArrayOfByte("Data", new byte[] {1, 2, 3, 4 } );
public void putArrayOfDoubleAsLong(java.lang.String item, long[] itemData) throws java.lang.Exception
item
- A String containing the name of the itemitemData
- A long array to add to this Fields object
MQeException
- Except_Not_Found
java.lang.Exception
public void putArrayOfInt(java.lang.String item, int[] itemData) throws java.lang.Exception
item
- A String containing the name of the itemitemData
- An int array to add to this Fields object
MQeException
- Except_Not_Found
java.lang.Exception
public void putArrayOfLong(java.lang.String item, long[] itemData) throws java.lang.Exception
item
- A String containing the name of the itemitemData
- A long array to add to this Fields object
MQeException
- Except_Not_Found
java.lang.Exception
public void putArrayOfFloatAsInt(java.lang.String item, int[] itemData) throws java.lang.Exception
item
- A String containing the name of the itemitemData
- An int array to add to this Fields object
MQeException
- Except_Not_Found
java.lang.Exception
public void putArrayOfShort(java.lang.String item, short[] itemData) throws java.lang.Exception
item
- A String containing the name of the itemitemData
- A short array to add to this Fields object
MQeException
- Except_Not_Found
java.lang.Exception
public void putAscii(java.lang.String item, java.lang.String itemData) throws java.lang.Exception
Sets a string containing Ascii characters.
This method sets Ascii data (see note getAscii() method description)
into the MQeFields object and sets the data type.
item
- The name of the item to be set.
MQeException
- Except_Not_Found
java.lang.Exception
MQeFields fields = new MQeFields(); fields.putAscii("Data", "This is some data"); MQeFields fields = new MQeFields(); data[0] = new String("This is some data"); data[1] = new String("This is more data"); fields.putAsciiArray("Data", data);
public void putAsciiArray(java.lang.String item, java.lang.String[] data) throws java.lang.Exception
Sets a dynamic size array of strings containing Ascii characters.
This method sets Ascii data (see note getAscii() method description)
from an array of strings into the MQeFields object and sets the data type.
item
- The name of the item to be set.data
- A string array containing the data to be set into the
MQeFields object.
MQeException
- Except_Not_Found
java.lang.Exception
MQeFields fields = new MQeFields(); data[0] = new String("This is some data"); data[1] = new String("This is more data"); fields.putAsciiArray("Data", data);
public void putBoolean(java.lang.String item, boolean itemData) throws java.lang.Exception
Sets a boolean value.
This sets a boolean value into the MQeFields object.
item
- The name of the item to be set.
MQeException
- Except_Not_Found
java.lang.Exception
MQeFields fields = new MQeFields(); fields.restore(dumpdata); fields.putBoolean("Data", false);
public void putByte(java.lang.String item, byte itemData)
This method sets the data in the MQeFields object for the supplied byte.
item
- The name of the item to be set.
MQeFields fields = new MQeFields(); data = 123; fields.putByte("Data", data); MQeFields fields =new MQeFields(); byte data [][]=new byte [2][]; data [1]= new byte[] {1,2,3,4}; data [2]= new byte[] {5,6,7,8}; fields.putByteArray("Data",data );
public void putByteArray(java.lang.String item, byte[][] data) throws java.lang.Exception
item
- A String containing the name of the itemdata
- An array of byte arrays to add to this Fields object
MQeException
- Except_Not_Found
java.lang.Exception
public void putDoubleAsLong(java.lang.String item, long itemData)
item
- A String containing the name of the itemitemData
- A long value to add to this Fields objectpublic void putFields(java.lang.String item, MQeFields theseFields) throws java.lang.Exception
Sets an embedded MQeFields object.
This method sets the data field as an item within this MQeFields object.
item
- The name of the item to be set.
MQeException
- Except_Not_Found, Except_NotAllowed
java.lang.Exception
MQeFields fields = new MQeFields(); MQeFields subFields = new MQeFields(); fields.putFields("Data", subFields); MQeFields fields = new MQeFields(); MQeFields[] subFields = new MQeFields[2]; subFields[0] = new MQeFields(); subFields[1] = new MQeFields(); fields.putFieldsArray("Data", subFields);
public void putFieldsArray(java.lang.String item, MQeFields[] data) throws java.lang.Exception
Sets an array of MQeFields objects.
This method sets an array of fields into this MQeFields object.
item
- The name of the item to be set.data
- An array of fields to be set into this MQeFields object.
MQeException
- Except_Not_Found, Except_NotAllowed
java.lang.Exception
MQeFields fields = new MQeFields(); MQeFields[] subFields = new MQeFields[2]; subFields[0] = new MQeFields(); subFields[1] = new MQeFields(); fields.putFieldsArray("Data", subFields);
public void putFloatAsInt(java.lang.String item, int itemData)
item
- A String containing the name of the itemitemData
- An int to add to this Fields objectpublic void putInt(java.lang.String item, int itemData)
Sets an integer.
This method sets an integer into the MQeFields object.
item
- The name of the item to be set.
MQeFields fields = new MQeFields(); fields.putInt("Data", 123456); MQeFields fields =new MQeFields(); int data []=new byte [2 ]; data [1 ]=1234;data [2 ]=5678; fields.putIntArray("Data",data );
public void putIntArray(java.lang.String item, int[] data) throws java.lang.Exception
item
- A String containing the name of the itemdata
- An intgegers array to add to this Fields object
java.lang.Exception
- Doesn't throw anythingpublic void putLong(java.lang.String item, long itemData)
Sets a long integer.
This method sets a long value into the MQeFields object.
item
- The name of the item to be set.
MQeFields fields = new MQeFields(); fields.putLong("Data", 123456); MQeFields fields =new MQeFields(); long data []= new byte [2]; data [1]= 1234; data [2]= 5678; fields.putLongArray("Data",data );
public void putLongArray(java.lang.String item, long[] data) throws java.lang.Exception
item
- A String containing the name of the itemdata
- A long array to add to this Fields object
java.lang.Exception
- Doesn't throw anythingpublic void putObject(java.lang.String item, java.lang.Object itemData) throws java.lang.Exception
Sets an Object field with the data.
This method sets an object field with the data specified.
item
- The name of the item to be set.
MQeException
- Except_Not_Found
java.lang.Exception
public void putShort(java.lang.String item, short itemData)
Sets a short integer.
This method sets the a short value into the MQeFields object.
item
- The name of the item to be set.
MQeFields fields = new MQeFields(); data = 123; fields.putShort("Data", data); MQeFields fields =new MQeFields(); short data []=new byte [2 ]; data [1 ]=1234; data [2 ]=5678; fields.putShortArray("Data",data );
public void putShortArray(java.lang.String item, short[] data) throws java.lang.Exception
item
- A String containing the name of the itemdata
- A short array to add to this Fields object
java.lang.Exception
- Doesn't throw anythingpublic void putUnicode(java.lang.String item, java.lang.String itemData) throws java.lang.Exception
Sets a string containing Unicode characters.
This method sets Unicode data into the MQeFields object and sets the data
type.
item
- The name of the item to be set
MQeException
- Except_Not_Found
java.lang.Exception
MQeFields msg = new MQeFields(); msg.putUnicode("Data", "Merry xmas to all our readers"); MQeFields msg = new MQeFields(); data = new String[2]; data[1] = "Merry xmas to all our readers"; data[2] = "and a happy new year"; System.out.println("Data1:" + data[1]); // msg.putUnicode("Data",data );
public void putUnicodeArray(java.lang.String item, java.lang.String[] data) throws java.lang.Exception
Sets a dynamic size array of strings containing Unicode characters.
This method sets Unicode data into the MQeFields object for the string array
and sets the data type.
item
- The name of the item to be set.data
- An array of strings containing the data to be set into the
MQeFields object.
MQeException
- Except_Not_Found
java.lang.Exception
MQeFields msg = new MQeFields(); data = new String[2]; data[1] = "Merry xmas to all our readers"; data[2] = "and a happy new year"; System.out.println("Data1:" + data[1]); // msg.putUnicode("Data",data );
public void rename(java.lang.String item, java.lang.String newName) throws java.lang.Exception
Renames an item held within the MQeFields object.
This method renames an existing item within the MQeFields object to the
specified new name. If an item with the newName already exists in the
MQeFields object, it is replaced by the renamed item.
newName
- A String containing the new name of the item
MQeException
- Except_NotFound : Item + "not found"
java.lang.Exception
MQeFields fields = new MQeFields(); fields.rename("ThisItem", "ThatItem");
public void restore(byte[] data) throws java.lang.Exception
This method restores a MQeFields object from a byte array that was created using the dump method.
Note: You can only restore an Object of the same type, use dumpedType(byte[]) to determine the type of the object within the byte array, then create a new Instance of this type in order to use the restore method.
data
- A byte array containing a dumped MQeFields object.
MQeException
- Except_Type, Except_Data, Except_NotFound
java.lang.Exception
- anything thrown by attribute.decodeData()MQeFields fields = new MQeFields(); fields.restore(dumpdata); MQeFields fields = MQeFields.restoreFromFile(File.separator +"directory"+ File.separator +"thisfile.xyz", "\r \n", "[#0 ]", "#1=#2"); MQeFields fields = new MQeFields(); fields.putBoolean("tb", true); data = " "; fields.putLong("ml", -1); data = fields.dumpToString("Name=#1,Type=#0 Value=#2 \r \n"); newFields = new MQeFields(); newFields.restoreFromString("Name=#1,Type=#0 Value=#2 \r \n", data);
public void restoreFromString(java.lang.String template, java.lang.String data) throws java.lang.Exception
Restores the contents of an MQeFields object from an Ascii string.
(typically produced by dumpToString(java.lang.String)
method call)
This method restores an individual item from a string.
template
- A String template used to parse the input.
The template should have up to 3 insert sequences #n :
Note: Hidden state is not dumped/restored
data
- The decorated string
MQeException
- Except_NotFound, Except_Syntax, Except_NotSupported
java.lang.Exception
MQeFields fields = new MQeFields(); fields.putBoolean("tb", true); data = " "; fields.putLong("ml", -1); data = fields.dumpToString("Name=#1,Type=#0 Value=#2 \r \n"); newFields = new MQeFields(); newFields.restoreFromString("Name=#1,Type=#0 Value=#2 \r \n", data);
public void restoreFromString(java.lang.String endRecord, java.lang.String template, java.lang.String data) throws java.lang.Exception
Restores the contents of an MQeFields object from an Ascii string.
A group of items from an EndRecord delimited string.
Note: A record that starts with an asterisk "*" is treated as a comment and blank records are ignored.
endRecord
- A String containg the end of record identifier, each
record MUST end with this string.template
- A pattern String used to parse the items.
(refer to the previous method for example )data
- The decorated string.
MQeException
- Except_NotFound, Except_Syntax, Except_NotSupported
java.lang.Exception
public static MQeFields restoreFromString(java.lang.String endRecord, java.lang.String sectionMatch, java.lang.String template, java.lang.String data) throws java.lang.Exception
Restores the contents of an MQeFields object from an Ascii string.
A nested MQeFields within MQeFields object from a SectionMatch and
EndRecord delimited string.
Note: a record that starts with an asterisk "*" is treated as a comment and blank records are ignored.
endRecord
- A String containg the end of record identifier, each
record MUST end with this string.sectionMatch
- A pattern String identifying a section, a record MUST
begin with section.template
- A pattern String used to parse the items.data
- The decorated string.
MQeException
- Except_NotFound, Except_Syntax, Except_NotSupported, Except_NotAllowed
java.lang.Exception
public void setAttribute(MQeAttribute attribute) throws java.lang.Exception
Assigns an attribute object to an MQeFields object.
This method assigns an attribute to be used to encode or decode the
contents of the MQeFields object when ever it is dumped or restored.
attribute
- An MQeAttribute
object reference.
java.lang.Exception
- Doesn't throw anythingMQeFields fields = new MQeFields(); MQeAttribute attr = new MQeAttribute(null, new MQeXorCryptor(), null); fields.setAttribute(attr);
public long updateValue(java.lang.String item, long update) throws java.lang.Exception
Updates (increments or decrements) an integer type value within an MQeFields object.
item
- The name of the item to be set.update
- A value to be added to the current value of the specified item.
MQeException
- Except_Type, Except_Not_Found
java.lang.Exception
long l = 0; MQeFields fields = new MQeFields(); fields.putInt("Data", 123); l = fields.updateValue("Data", -3); return l;
public boolean includes(MQeFields match)
Checks whether an object has a match with an MQeFields object field.
must also exist in this object and have the same type and value (and not be hidden).
Each field in the parameter object is checked to see if there is a matching
field in the MQeFields. In order to match, the field must have the same
name, type and value (except for embedded MQeFields objects, see below).
Hidden fields, in the parameter and in the MQeFields, are ignored when
checking for a match.
If the parameter is null , the method returns true.
If a field in the parameter object is an embedded MQeFields object and an embedded MQeFields object with the same name exists in the main MQeFields, the two embedded fields objects are compared using includes().
boolean Includes = false; MQeFields fields = new MQeFields(); MQeFields test = new MQeFields(); try { fields.putAscii("Data1", "This is some data"); fields.putAscii("Data2", "This is more data"); test.putAscii("Data1", "This is some data"); if (fields.isEqualTo(test)) //should return true Includes = true; else Includes = false; } catch (Exception e) { System.err.println("Failure ! " + e.toString()); }
public boolean isEqualTo(java.lang.Object match)
Checks for equality between MQeFields objects.
If the parameter is an MQeFields (or descendent) object, the isEqualTo()
method checks that the MQeFields object has exactly the same fields as the
parameter. Each field in the MQeFields object should have a matching field
in the parameter and each field in the parameter should have a matching
field in the MQeFields object. In order to match, the field must have the
same name, type and value. If the field is an embedded MQeFields object,
isEqualTo() is used recursively to compare its value.
Hidden fields, in the parameter and in the MQeFields, are ignored when checking for a match.
If the parameter is not an MQeFields (or descendent) object, the value of super.equals(match)is returned.
If the parameter is null , the method returns false .
match
- An object to be compared with the MQeFields object.
MQeFields fields = new MQeFields(); MQeFields test = new MQeFields(); try { fields.putAscii("Data1", "This is some data"); fields.putAscii("Data2", "This is more data"); test.putAscii("Data1", "This is some data"); test.putAscii("Data2", "This is more data"); if (fields.isEqualTo(test)) //should return true IfEquals = true; else IfEquals = false; } catch (Exception e) { System.err.println("Failure ! " + e.toString()); }
|
Websphere MQ Everyplace | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |