@Override public Object createObject(Attributes attributes) { String name = attributes.getValue("name"); String value = attributes.getValue("value"); return new SetPropertyRule( name, value); } }
public void begin(Attributes attributes) throws Exception { if (attributes.getIndex("key") == -1) { super.begin(attributes); return; } if (attributes.getIndex("property") != -1) { throw new IllegalArgumentException( "<set-property> accepts only one of 'key' or 'property' attributes."); } Object topOfStack = digester.peek(); if (topOfStack instanceof BaseConfig) { BaseConfig config = (BaseConfig) topOfStack; config.setProperty(attributes.getValue("key"), attributes.getValue("value")); } else { throw new IllegalArgumentException( "'key' attribute of <set-property> only applicable to subclasses of BaseConfig; " + "object on top of stack is " + topOfStack + " [key: " + attributes.getValue("key") + ", value: " + attributes.getValue("value") + "]"); } } }
/** * Add a "set property" rule for the specified parameters. * * @param pattern Element matching pattern * @param name Attribute name containing the property name to be set * @param value Attribute name containing the property value to set * @see SetPropertyRule */ public void addSetProperty(String pattern, String name, String value) { addRule(pattern, new SetPropertyRule(name, value)); }
public Object createObject(Attributes attributes) { String name = attributes.getValue("name"); String value = attributes.getValue("value"); return new SetPropertyRule( name, value); } }
/** * Add a "set property" rule for the specified parameters. * * @param pattern Element matching pattern * @param name Attribute name containing the property name to be set * @param value Attribute name containing the property value to set * @see SetPropertyRule */ public void addSetProperty(String pattern, String name, String value) { addRule(pattern, new SetPropertyRule(name, value)); }