private Object itemValue(Object obj, Object item) throws Exception { // String value if (item instanceof String) return item; XmlParser.Node node = (XmlParser.Node)item; String tag = node.getTag(); if ("Call".equals(tag)) return call(obj,node); if ("Get".equals(tag)) return get(obj,node); if ("New".equals(tag)) return newObj(obj,node); if ("Ref".equals(tag)) return refObj(obj,node); if ("Array".equals(tag)) return newArray(obj,node); if ("Map".equals(tag)) return newMap(obj,node); if ("Property".equals(tag)) return propertyObj(node); if ("SystemProperty".equals(tag)) return systemPropertyObj(node); if ("Env".equals(tag)) return envObj(node); LOG.warn("Unknown value tag: " + node,new Throwable()); return null; }
/** * @param array the array to convert * @param collectionType the desired collection type * @return a collection of the desired type if the array can be converted */ private static Collection<?> convertArrayToCollection(Object array, Class<?> collectionType) { Collection<?> collection = null; if (array.getClass().isArray()) { if (collectionType.isAssignableFrom(ArrayList.class)) collection = convertArrayToArrayList(array); else if (collectionType.isAssignableFrom(HashSet.class)) collection = new HashSet<Object>(convertArrayToArrayList(array)); else if (collectionType.isAssignableFrom(ArrayQueue.class)) { ArrayQueue<Object> q= new ArrayQueue<Object>(); q.addAll(convertArrayToArrayList(array)); collection=q; } } if (collection==null) throw new IllegalArgumentException("Can't convert \"" + array.getClass() + "\" to " + collectionType); return collection; }
Object value = value(obj,node); Object[] arg = { value }; Class<?> oClass = nodeClass(node); if (oClass != null) obj = null; if (paramTypes[0].isAssignableFrom(c)) sets[s].invoke(obj,convertArrayToCollection(value,c)); return;
Object value = value(obj,node); Object[] arg = { value }; Class<?> oClass = nodeClass(node); if (oClass != null) obj = null; if (paramTypes[0].isAssignableFrom(c)) sets[s].invoke(obj,convertArrayToCollection(value,c)); return;
Object value = value(obj,node); Object[] arg = { value }; Class<?> oClass = nodeClass(node); if (oClass != null) obj = null; if (paramTypes[0].isAssignableFrom(c)) sets[s].invoke(obj,convertArrayToCollection(value,c)); return;
Object value = value(obj,node); Object[] arg = { value }; Class<?> oClass = nodeClass(node); if (oClass != null) obj = null; if (paramTypes[0].isAssignableFrom(c)) sets[s].invoke(obj,convertArrayToCollection(value,c)); return;
Object value = value(obj,node); Object[] arg = { value }; Class<?> oClass = nodeClass(node); if (oClass != null) obj = null; if (paramTypes[0].isAssignableFrom(c)) sets[s].invoke(obj,convertArrayToCollection(value,c)); return;
Object value = value(obj,node); Object[] arg = { value }; Class<?> oClass = nodeClass(node); if (oClass != null) obj = null; if (paramTypes[0].isAssignableFrom(c)) sets[s].invoke(obj,convertArrayToCollection(value,c)); return;
value = itemValue(obj,node.get(first)); else buf.append(itemValue(obj,item)); if (isTypeMatchingClass(type,String.class)) return value.toString(); return TypeUtil.valueOf(pClass,value.toString()); if (isTypeMatchingClass(type,URL.class)) if (isTypeMatchingClass(type,InetAddress.class)) if (isTypeMatchingClass(type,collectionClass)) return convertArrayToCollection(value,collectionClass);
value = itemValue(obj,node.get(first)); else buf.append(itemValue(obj,item)); if (isTypeMatchingClass(type,String.class)) return value.toString(); return TypeUtil.valueOf(pClass,value.toString()); if (isTypeMatchingClass(type,URL.class)) if (isTypeMatchingClass(type,InetAddress.class)) if (isTypeMatchingClass(type,collectionClass)) return convertArrayToCollection(value,collectionClass);
value = itemValue(obj,node.get(first)); else buf.append(itemValue(obj,item)); if (isTypeMatchingClass(type,String.class)) return value.toString(); return TypeUtil.valueOf(pClass,value.toString()); if (isTypeMatchingClass(type,URL.class)) if (isTypeMatchingClass(type,InetAddress.class)) if (isTypeMatchingClass(type,collectionClass)) return convertArrayToCollection(value,collectionClass);
value = itemValue(obj,node.get(first)); else buf.append(itemValue(obj,item)); if (isTypeMatchingClass(type,String.class)) return value.toString(); return TypeUtil.valueOf(pClass,value.toString()); if (isTypeMatchingClass(type,URL.class)) if (isTypeMatchingClass(type,InetAddress.class)) if (isTypeMatchingClass(type,collectionClass)) return convertArrayToCollection(value,collectionClass);
value = itemValue(obj,node.get(first)); else buf.append(itemValue(obj,item)); if (isTypeMatchingClass(type,String.class)) return value.toString(); return TypeUtil.valueOf(pClass,value.toString()); if (isTypeMatchingClass(type,URL.class)) if (isTypeMatchingClass(type,InetAddress.class)) if (isTypeMatchingClass(type,collectionClass)) return convertArrayToCollection(value,collectionClass);
value = itemValue(obj,node.get(first)); else buf.append(itemValue(obj,item)); if (isTypeMatchingClass(type,String.class)) return value.toString(); return TypeUtil.valueOf(pClass,value.toString()); if (isTypeMatchingClass(type,URL.class)) if (isTypeMatchingClass(type,InetAddress.class)) if (isTypeMatchingClass(type,collectionClass)) return convertArrayToCollection(value,collectionClass);
set(obj, node); break; case "Put": put(obj, node); break; case "Call": call(obj, node); break; case "Get": get(obj, node); break; case "New": newObj(obj, node); break; case "Array": newArray(obj, node); break; case "Map": newMap(obj,node); break; case "Ref": refObj(obj, node); break; case "Property": propertyObj(node); break; case "SystemProperty": systemPropertyObj(node); break;