Nonexistent Properties

If a JMS client attempts to access a nonexistent property using getObjectProperty( ), null is returned. The rest of the property methods attempt to convert the null value to the requested type using the valueOf( ) operations. This results in some interesting behavior. The getStringProperty( ) returns a null or possibly an empty String ("") depending on the implementation. The getBooleanProperty( ) method returns false for null values, while the other primitive property methods throw the java.lang.NumberFormatException.

The propertyExists( ) method can be used to avoid erroneous values or exceptions for properties that have not been set on the message. Here is an example of how it's used:

if (message.propertyExists("Age"))
	age = message.getIntProperty("Age");
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset