/** * Sets the named attribute in the given element, which is part of the * given project. * * @param p The project containing the element. This is used when files * need to be resolved. Must not be <code>null</code>. * @param element The element to set the attribute in. Must not be * <code>null</code>. * @param attributeName The name of the attribute to set. Must not be * <code>null</code>. * @param value The value to set the attribute to. This may be interpreted * or converted to the necessary type if the setter method * doesn't just take a string. Must not be <code>null</code>. * * @exception BuildException if the introspected class doesn't support * the given attribute, or if the setting * method fails. */ public void setAttribute(final Project p, final Object element, final String attributeName, final String value) throws BuildException { setAttribute(p, element, attributeName, (Object) value); }
/** * Try to set a value on an object using reflection. * Helper method for easier access to IntrospectionHelper.setAttribute(). * @param obj the object on which the attribute should be set * @param name the attributename * @param value the new value */ protected void tryToSetAParameter(Object obj, String name, String value) { Project prj = (getProject() != null) ? getProject() : new Project(); IntrospectionHelper iHelper = IntrospectionHelper.getHelper(prj, obj.getClass()); try { iHelper.setAttribute(prj, obj, name, value); } catch (BuildException e) { // no-op } }
ih.setAttribute(project, target, attrs.getName(i).toLowerCase(Locale.ENGLISH), value); } catch (BuildException be) {
ih.setAttribute(p, target, name, attrValue); } catch (UnsupportedAttributeException be) {
@Override void invoke(Task taskInstance, Object arg, IntrospectionHelper helper) { if (TypeCategory.ENUM == _typeCategory) { arg = EnumeratedAttribute.getInstance(_type, arg.toString().toLowerCase()); } helper.setAttribute(null, taskInstance, _helperKey, arg); }
/** * Copies the properties into the Ant task. */ public void configure(Object antObject) { IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); // set attributes first for (Iterator itr = attributes.entrySet().iterator(); itr.hasNext();) { Entry att = (Entry)itr.next(); ih.setAttribute(getProject(), antObject, (String)att.getKey(), (String)att.getValue()); } // then nested elements for (Iterator itr = elements.iterator(); itr.hasNext();) { AntElement e = (AntElement) itr.next(); Object child = ih.createElement(getProject(), antObject, e.name); e.configure(child); ih.storeElement(getProject(), antObject, child, e.name); } } }
/** * Copies the properties into the Ant task. */ public void configure(Object antObject) { IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); // set attributes first for (Iterator itr = attributes.entrySet().iterator(); itr.hasNext();) { Entry att = (Entry)itr.next(); ih.setAttribute(getProject(), antObject, (String)att.getKey(), (String)att.getValue()); } // then nested elements for (Iterator itr = elements.iterator(); itr.hasNext();) { AntElement e = (AntElement) itr.next(); Object child = ih.createElement(getProject(), antObject, e.name); e.configure(child); ih.storeElement(getProject(), antObject, child, e.name); } } }
/** * Copies the properties into the Ant task. */ public void configure(Object antObject) { IntrospectionHelper ih = IntrospectionHelper.getHelper(antObject.getClass()); // set attributes first for (Iterator itr = attributes.entrySet().iterator(); itr.hasNext();) { Entry att = (Entry)itr.next(); ih.setAttribute(getProject(), antObject, (String)att.getKey(), (String)att.getValue()); } // then nested elements for (Iterator itr = elements.iterator(); itr.hasNext();) { AntElement e = (AntElement) itr.next(); Object child = ih.createElement(getProject(), antObject, e.name); e.configure(child); ih.storeElement(getProject(), antObject, child, e.name); } } }