How to use Instance.Reflection.getAllProperties() and Instance.PropertyAtom.get;propertyType;() .
book
Article ID: KB0088882
calendar_today
Updated On:
Products
Versions
TIBCO BusinessEvents Enterprise Edition
-
Not Applicable
-
Description
Description: How to use Instance.Reflection.getAllProperties() and Instance.PropertyAtom.get<propertyType>() .
Issue/Introduction
How to use Instance.Reflection.getAllProperties() and Instance.PropertyAtom.get;propertyType;() .
Resolution
1). The catalog function Instance.Reflection.getAllProperties() returns an object array.
2). To retrieve the values you have to check the property type first before using the related catalog function to return the property name/value.
3). Numeric properties are primitive data types in Java. They can not be Null. This is why the returned property value is "0" when the property is not set. To validate if the property is set, serialize the concept and check for the property tag.
Code Sample (long and string properties):
//Concepts.testsupport c=Concepts.testsupport.testsupport("sExtID1","tvalue1","testvalue2",2,<null>,<null>); Concepts.testsupport c = Instance.createInstance("xslt://...");
Object[] objProps= Instance.Reflection.getAllProperties(c); String[] strPropValue = Instance.Reflection.getAllPropertyNames(c); for (int i=0;i< objProps@length;i++) { if(Instance.Reflection.isPropertyString(objProps[i])) { String sValue= Instance.PropertyAtom.getString(objProps[i],1); if (sValue!=null) System.debugOut("## Property " + strPropValue[i] + " of type String value is: " + sValue); else System.debugOut("## Property " + strPropValue[i] + " of type String value is NULL "); } else if (Instance.Reflection.isPropertyLong(objProps[i])) { String sPropName=strPropValue[i]; if (String.contains(sCptSerialized,"<" + sPropName + ">")) { long lValue= Instance.PropertyAtom.getLong(objProps[i],1); System.debugOut("## Property " + sPropName + " of type long value is: " + String.valueOfLong(lValue)); } else System.debugOut("## Property " + sPropName + " of type long value is Null " ); }