/** * Apply a method on a object with the value found in the XML element If the * element is null, the method does nothing. * * @param e * @param o * @param method * @return * @throws SecurityException * @throws NoSuchMethodException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException * @throws InstantiationException */ public boolean setMethod(JrdsElement e, Object o, String method) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { return setMethod(e, o, method, String.class); }
public <BuildObject> Map<String, BuildObject> getObjectMap(ConfigObjectBuilder<BuildObject> ob, Map<String, JrdsDocument> nodeMap) { Map<String, BuildObject> objectMap = new HashMap<String, BuildObject>(); for(Map.Entry<String, JrdsDocument> e: nodeMap.entrySet()) { JrdsDocument n = e.getValue(); BuildObject o; String name = ob.ct.getName(n); try { o = ob.build(n); if(o != null && name != null) { objectMap.put(name, o); } } catch (InvocationTargetException ex) { logger.error("Fatal error for object of type " + ob.ct + " and name " + name + ":" + ex.getCause()); } // Remove DOM object as soon as it's not needed any more nodeMap.remove(e.getKey()); } return objectMap; }
/** * Apply a method on a object with the value found in a collection of XML * elements If the element is null, the method does nothing. * * @param e * @param o * @param method * @param argType * @return true if a least one set method succed * @throws SecurityException * @throws NoSuchMethodException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException * @throws InstantiationException */ public boolean setMethod(Iterable<JrdsElement> e, Object o, String method, Class<?> argType) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { if(e == null) return false; boolean setted = false; for(JrdsElement elem: e) { setted |= setMethod(elem, o, method, argType); } return setted; }