01: /*
02: * User: Michael Rettig
03: * Date: Sep 1, 2002
04: * Time: 9:27:05 PM
05: */
06: package net.sourceforge.jaxor.parser;
07:
08: import java.util.ArrayList;
09: import java.util.Collections;
10: import java.util.Iterator;
11: import java.util.List;
12:
13: public class Aggregate {
14: private final List _attributes = new ArrayList();
15: private String _type;
16: private String _alias;
17: private String _mapper;
18:
19: public Aggregate() {
20: }
21:
22: public Aggregate(String _type, String _alias, String _mapper) {
23: this ._type = _type;
24: this ._alias = _alias;
25: this ._mapper = _mapper;
26: }
27:
28: public void setType(String type) {
29: _type = type;
30: }
31:
32: public void setAlias(String alias) {
33: _alias = alias;
34: }
35:
36: public void setMapper(String mapper) {
37: _mapper = mapper;
38: }
39:
40: public void addAttribute(Attribute attribute) {
41: attribute.setAggregate(true);
42: _attributes.add(attribute);
43: }
44:
45: public List getAttributes() {
46: return Collections.unmodifiableList(_attributes);
47: }
48:
49: public String getGetterSig() {
50: return "public " + _type + " " + "get" + _alias + "()";
51: }
52:
53: public String getSetterSig() {
54: return "public void set" + _alias + "(" + _type + " arg)";
55: }
56:
57: public String getMapperName(Jaxor jaxor) {
58: if (_mapper != null)
59: return _mapper;
60: return jaxor.getMapperName(_type);
61: }
62:
63: public String getAlias() {
64: return _alias;
65: }
66:
67: public String getType() {
68: return _type;
69: }
70:
71: public String getContructorArgs() {
72: String output = "";
73: for (Iterator iterator = _attributes.iterator(); iterator
74: .hasNext();) {
75: Attribute attribute = (Attribute) iterator.next();
76: output += attribute.getName();
77: if (iterator.hasNext())
78: output += ", ";
79:
80: }
81: return output;
82: }
83: }
|