1 /*
2 * Created on 09.mar.2003
3 *
4 */
5 package net.sf.panoptes.controller.digester;
6
7 import net.sf.panoptes.model.component.ComponentGroup;
8 import net.sf.panoptes.model.component.registry.ComponentName;
9 import net.sf.panoptes.model.component.registry.ComponentRegistry;
10 import net.sf.panoptes.model.node.SymLinkNode;
11 import net.sf.panoptes.model.node.Node;
12 import net.sf.panoptes.model.node.NodeDescriptor;
13
14 import org.apache.commons.digester.Digester;
15 import org.apache.commons.digester.ObjectCreationFactory;
16 import org.xml.sax.Attributes;
17
18 /***
19 * Digester factory to create ComponentNodes connected to Components
20 *
21 * @author Dag Liodden
22 *
23 */
24
25 public class SymLinkFactory implements ObjectCreationFactory {
26
27 private Digester digester;
28 ComponentRegistry componentRegistry;
29
30 public SymLinkFactory(ComponentRegistry componentRegistry) {
31 this.componentRegistry = componentRegistry;
32 }
33
34 /* (non-Javadoc)
35 * @see org.apache.commons.digester.ObjectCreationFactory#createObject(org.xml.sax.Attributes)
36 */
37 public Object createObject(Attributes attributes) throws Exception {
38 ComponentName componentName = new ComponentName(attributes.getValue("ref-id"));
39 SymLinkNode p = new SymLinkNode(componentRegistry, componentName);
40 ((ComponentGroup) digester.peek()).addChild(p);
41
42 String name = attributes.getValue("name");
43 String description = attributes.getValue("description");
44
45 if (name != null) {
46 p.setConfigDescriptor(new NodeDescriptor(name, description));
47 }
48
49 String iconName = attributes.getValue("icon");
50 if (iconName != null) p.setIcon(Node.createImage(iconName));
51
52 String script = attributes.getValue("script");
53 if (script != null) p.addConfiguratorScript(script);
54 return p;
55 }
56
57 /* (non-Javadoc)
58 * @see org.apache.commons.digester.ObjectCreationFactory#getDigester()
59 */
60 public Digester getDigester() {
61 return digester;
62 }
63
64 /* (non-Javadoc)
65 * @see org.apache.commons.digester.ObjectCreationFactory#setDigester(org.apache.commons.digester.Digester)
66 */
67 public void setDigester(Digester digester) {
68 this.digester = digester;
69 }
70 }
This page was automatically generated by Maven