1 /*
2 * Created on 22.mar.2003
3 *
4 */
5 package net.sf.panoptes.controller.digester;
6
7 import java.util.HashMap;
8
9 import org.apache.commons.digester.Digester;
10 import org.apache.commons.digester.ObjectCreationFactory;
11 import org.xml.sax.Attributes;
12
13 import net.sf.panoptes.model.component.registry.ConfiguratorRegistry;
14
15 /***
16 *
17 *
18 * @author Dag Liodden
19 * @version 0.1
20 */
21 public class ConfiguratorFactory implements ObjectCreationFactory {
22
23 private Digester digester;
24 ConfiguratorRegistry configRegistry;
25
26 public ConfiguratorFactory(ConfiguratorRegistry configRegistry) {
27 this.configRegistry = configRegistry;
28 }
29
30 /* (non-Javadoc)
31 * @see org.apache.commons.digester.ObjectCreationFactory#createObject(org.xml.sax.Attributes)
32 */
33 public Object createObject(Attributes attributes) throws Exception {
34 String name = attributes.getValue("name");
35 String className = attributes.getValue("class");
36 String patterns = attributes.getValue("patterns");
37
38 HashMap atts = new HashMap();
39 for (int i = 0; i < attributes.getLength(); i++) {
40 atts.put(attributes.getQName(i), attributes.getValue(i));
41 }
42
43 return configRegistry.addConfigurator(name, className, patterns, atts);
44
45 }
46
47 /* (non-Javadoc)
48 * @see org.apache.commons.digester.ObjectCreationFactory#getDigester()
49 */
50 public Digester getDigester() {
51 return digester;
52 }
53
54 /* (non-Javadoc)
55 * @see org.apache.commons.digester.ObjectCreationFactory#setDigester(org.apache.commons.digester.Digester)
56 */
57 public void setDigester(Digester digester) {
58 this.digester = digester;
59 }
60 }
This page was automatically generated by Maven