private static Map getMap(Element mapElement, Map map) { Class keyClass = classForAttributeValue(mapElement, "key-type"); Class valueClass = classForAttributeValue(mapElement, "value-type"); for (Iterator iter = mapElement.elementIterator(); iter.hasNext();) { Element element = (Element) iter.next(); Element keyElement = element.element("key"); Element valueElement = element.element("value"); map.put(getValue(keyClass, keyElement), getValue(valueClass, valueElement)); } return map; }
private static Map getMap(Element mapElement, Map map) { Class keyClass = classForAttributeValue(mapElement, "key-type"); Class valueClass = classForAttributeValue(mapElement, "value-type"); for (Iterator iter = mapElement.elementIterator(); iter.hasNext();) { Element element = (Element) iter.next(); Element keyElement = element.element("key"); Element valueElement = element.element("value"); map.put(getValue(keyClass, keyElement), getValue(valueClass, valueElement)); } return map; }
private static Object getCollection(Element collectionElement, Collection collection) { Class elementClass = classForAttributeValue(collectionElement, "element-type"); for (Iterator iter = collectionElement.elementIterator(); iter.hasNext();) { Element element = (Element) iter.next(); collection.add(getValue(elementClass, element)); } return collection; }
private static Object getCollection(Element collectionElement, Collection collection) { Class elementClass = classForAttributeValue(collectionElement, "element-type"); for (Iterator iter = collectionElement.elementIterator(); iter.hasNext();) { Element element = (Element) iter.next(); collection.add(getValue(elementClass, element)); } return collection; }
protected void setPropertyValue(Class clazz, Object instance, String propertyName, Element propertyElement) { Field field = findField(clazz, propertyName); if (field != null) { field.setAccessible(true); Object value = getValue(field.getType(), propertyElement); try { field.set(instance, value); } catch (IllegalArgumentException e) { log.error("could not set '" + propertyName + "' to: " + value, e); } catch (IllegalAccessException e) { log.error(getClass() + " has no access to " + field, e); } } else { log.error("field not found: " + propertyName); } }
protected void setPropertyValue(Class clazz, Object instance, String propertyName, Element propertyElement) { Field field = findField(clazz, propertyName); if (field != null) { field.setAccessible(true); Object value = getValue(field.getType(), propertyElement); try { field.set(instance, value); } catch (IllegalArgumentException e) { log.error("could not set '" + propertyName + "' to: " + value, e); } catch (IllegalAccessException e) { log.error(getClass() + " has no access to " + field, e); } } else { log.error("field not found: " + propertyName); } }