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.node.NodeDescriptor;
9
10 import org.apache.commons.digester.Digester;
11 import org.apache.commons.digester.ObjectCreationFactory;
12 import org.xml.sax.Attributes;
13
14 /***
15 * Digester factory to create ComponentGroupNodes.
16 *
17 * @author Dag Liodden
18 */
19
20 public class ComponentGroupNodeFactory implements ObjectCreationFactory {
21
22 private Digester digester;
23
24 public ComponentGroupNodeFactory() {
25 }
26
27 /* (non-Javadoc)
28 * @see org.apache.commons.digester.ObjectCreationFactory#createObject(org.xml.sax.Attributes)
29 */
30 public Object createObject(Attributes attributes) throws Exception {
31 ComponentGroup f = new ComponentGroup("Created", "");
32 ((ComponentGroup) digester.peek()).addChild(f);
33 String name = attributes.getValue("name");
34 String description = attributes.getValue("description");
35 f.setConfigDescriptor(
36 new NodeDescriptor(
37 name == null ? "Unnamed" : name,
38 description == null ? "No description" : description));
39 return f;
40 }
41
42 /* (non-Javadoc)
43 * @see org.apache.commons.digester.ObjectCreationFactory#getDigester()
44 */
45 public Digester getDigester() {
46 return digester;
47 }
48
49 /* (non-Javadoc)
50 * @see org.apache.commons.digester.ObjectCreationFactory#setDigester(org.apache.commons.digester.Digester)
51 */
52 public void setDigester(Digester digester) {
53 this.digester = digester;
54 }
55 }
This page was automatically generated by Maven