This method will illustrate how to update the object in object map.
/**
* This method shows an example how you can update a object property in Test
* object map.<br>
* This method will update an object that has property .class="Html.A" and
* .classIndex="12".<br>
* It will update the .text property to "381176".<br>
* Jul 9, 2015
*
* @author mrCoolK
*/
public void updateObjectPropertyInTestObject() {
Enumeration<MappedTestObject> elts = getMap().elements();
while (elts.hasMoreElements()) {
MappedTestObject obj = elts.nextElement();
MappedTestObjectProperty toProperty1 = obj
.getPropertyData(".class");
MappedTestObjectProperty toProperty2 = obj
.getPropertyData(".classIndex");
try { // try catch because all object might not have the property
// you are trying to find.
System.out.println(".class :" + toProperty1.getValue());
System.out.println(".classIndex :" + toProperty2.getValue());
if ((toProperty1 != null)
&& (toProperty1.getValue().toString().equals("Html.A"))
&& (toProperty2.getValue().toString().equals("12"))) {
obj.setProperty(".text", "381176", 100);// Property,value,weight
System.out.println("Properties changed !!");
break;
}
} catch (NullPointerException e) {
}
}
// store back in file for future use.
ObjectMap.store(getMap(), getMap().getFile());
}
}