This entry is part of the Maximo Java Development series.
A very common doubt when extending MBOs is what value returns the Mbo.getString() method when the target field has a null value. The answer is: It returns an empty string “”.
Thus to check if the DESCRIPTION of an Mbo is empty or null you can use two basic approaches.
getString("DESCRIPTION").equals("")
or
getString("DESCRIPTION").length()==0
If you need do distinguish between null values and empty string you can use the Mbo.getMboValueData() method.
Thus to check if the DESCRIPTION of an Mbo is null use this code snippet.
getMboValueData("DESCRIPTION").isNull()
If you are in an Mbo class you can perform the same check as follows:
isNull("DESCRIPTION")
How to check for null values
Utility-class psdi.util.StringUtility gives you isEmpty() method that checks if string is empty or null:
if (!psdi.util.StringUtility.isEmpty(getString("DESCRIPTION"))) {
…
}
PS: check also com.ibm.tivoli.maximo.util.StringUtil
also an the mbo you should call isNull("YOUR_ATTRIBUTENAME")… it's shorter 😉
Good tip. I have updated the post