01: package net.sourceforge.jaxor.parser;
02:
03: import net.sourceforge.jaxor.AbstractEntity;
04: import net.sourceforge.jaxor.api.EntityInterface;
05:
06: import java.util.ArrayList;
07: import java.util.Iterator;
08: import java.util.List;
09:
10: /*
11: * User: Mike
12: * Date: Oct 22, 2002
13: * Time: 10:36:57 AM
14: */
15:
16: public class Generator {
17:
18: private final List _attributes = new ArrayList();
19: private Extends _extends = new Extends(AbstractEntity.class
20: .getName());
21: private List _implements = new ArrayList();
22:
23: public void addExtends(Extends val) {
24: _extends = val;
25: }
26:
27: public void addImplements(Implements val) {
28: _implements .add(val);
29: }
30:
31: public void addAttribute(Attribute att) {
32: _attributes.add(att);
33: }
34:
35: public List getAttributes() {
36: return _attributes;
37: }
38:
39: public String getExtends(Entity ent) {
40: if (ent.getExtends() != null)
41: return ent.getExtends();
42: if (_extends != null)
43: return _extends.getName();
44: return null;
45: }
46:
47: public String getImplements(Entity ent) {
48: if (ent.getImplements() != null)
49: return ent.getImplements();
50: String result = "";
51: for (Iterator iterator = _implements .iterator(); iterator
52: .hasNext();) {
53: Implements anImplements = (Implements) iterator.next();
54: result += anImplements.getName();
55: if (iterator.hasNext())
56: result += ",";
57: }
58: return result;
59: }
60:
61: public static Generator createDefault() {
62: Generator gen = new Generator();
63: Extends val = new Extends();
64: val.setName(AbstractEntity.class.getName());
65: gen.addExtends(val);
66: Implements impements = new Implements();
67: impements.setName(EntityInterface.class.getName());
68: gen.addImplements(impements);
69: return gen;
70: }
71: }
|