1 17 18 19 20 package org.apache.lenya.ac.impl; 21 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.configuration.DefaultConfiguration; 25 26 30 public class ItemConfiguration { 31 32 35 public ItemConfiguration() { 36 } 37 38 43 public void save(AbstractItem manageable, DefaultConfiguration configuration) { 44 configuration.setAttribute(CLASS_ATTRIBUTE, manageable.getClass().getName()); 45 configuration.setAttribute(ID_ATTRIBUTE, manageable.getId()); 46 47 DefaultConfiguration child = null; 48 49 child = new DefaultConfiguration(NAME); 51 child.setValue(manageable.getName()); 52 configuration.addChild(child); 53 54 child = new DefaultConfiguration(DESCRIPTION); 56 child.setValue(manageable.getDescription()); 57 configuration.addChild(child); 58 59 } 60 61 public static final String NAME = "name"; 62 public static final String DESCRIPTION = "description"; 63 public static final String ID_ATTRIBUTE = "id"; 64 public static final String CLASS_ATTRIBUTE = "class"; 65 66 72 public void configure(AbstractItem manageable, Configuration configuration) throws ConfigurationException { 73 manageable.setId(configuration.getAttribute(ID_ATTRIBUTE)); 74 manageable.setName(configuration.getChild(NAME).getValue("")); 75 manageable.setDescription(configuration.getChild(DESCRIPTION).getValue("")); 76 } 77 78 } 79 | Popular Tags |