/**
* Get the value for this attribute. So what we have to do is look through
* the children of this object for a match for this attribute.
*/
public Object get(Object obj) {
Node xmlnode = (Node)obj;
for (Node xmlchild : xmlnode.getTags()){
String childtype = xmlchild.getAttributes().get("type");
if(xmlchild.getName().equals(this.name)){
if(childtype.equalsIgnoreCase("object") ){
if(xmlchild.getTags().size() > 0){
return xmlchild.getTags().get(0);
}
}else if (type == MapType.LIST){
if(subType.isPrimitive()){
List<Object> ret = new ArrayList<Object>();
for(Node listItem : xmlchild.getTags()){
ret.add(listItem.getBody());
}
return ret;
}else{
return xmlchild.getTags();
}
}else if (childtype.equalsIgnoreCase("int")
|| childtype.equalsIgnoreCase("short")
|| childtype.equalsIgnoreCase("integer")
|| childtype.equalsIgnoreCase("long")
|| childtype.equalsIgnoreCase("string")
|| childtype.equalsIgnoreCase("boolean")
|| childtype.equalsIgnoreCase("double")
|| childtype.equalsIgnoreCase("date")){
String v = xmlchild.getBody();
return v;
}else if (type == MapType.MAP){
Map<Object, Object> map = new HashMap<Object,Object>();
for(Node pair : xmlchild.getTags()){
Node keyNode = pair.getTags().get(0);
Node valueNode = pair.getTags().get(1);
Object key = convert(keyNode);
Object value = convert(valueNode);
map.put(key, value);
}
return map;