01: package org.apache.ojb.broker;
02:
03: import java.io.Serializable;
04: import java.util.Iterator;
05: import java.util.List;
06: import java.util.Vector;
07:
08: /**
09: * class used in testing polymorphic m:n collections
10: * @author <a href="mailto:schneider@mendel.imp.univie.ac.at">Georg Schneider</a>
11: *
12: */
13: public class Gourmet implements Serializable {
14: int gourmetId;
15: String name;
16: List favoriteFood = new Vector();
17:
18: /**
19: * Constructor for Gourmet.
20: */
21: public Gourmet() {
22: super ();
23: }
24:
25: public Gourmet(String name) {
26: this .name = name;
27: }
28:
29: public List getFavoriteFood() {
30: return favoriteFood;
31: }
32:
33: public void addFavoriteFood(InterfaceFood food) {
34: favoriteFood.add(food);
35: }
36:
37: /**
38: * Returns the gourmetId.
39: * @return int
40: */
41: public int getGourmetId() {
42: return gourmetId;
43: }
44:
45: public String toString() {
46: StringBuffer text = new StringBuffer("Gourmet: id = "
47: + gourmetId + "\n");
48: text.append("name = ");
49: text.append(name);
50: text.append("\nFavoriteFood:\n");
51: for (Iterator it = favoriteFood.iterator(); it.hasNext();) {
52: text.append(it.next().toString());
53: text.append("\n-------\n");
54: }
55: return text.toString();
56: }
57:
58: /**
59: * Returns the name.
60: * @return String
61: */
62: public String getName() {
63: return name;
64: }
65:
66: /**
67: * Sets the favoriteFood.
68: * @param favoriteFood The favoriteFood to set
69: */
70: public void setFavoriteFood(List favoriteFood) {
71: this .favoriteFood = favoriteFood;
72: }
73:
74: /**
75: * Sets the gourmetId.
76: * @param gourmetId The gourmetId to set
77: */
78: public void setGourmetId(int gourmetId) {
79: this .gourmetId = gourmetId;
80: }
81:
82: /**
83: * Sets the name.
84: * @param name The name to set
85: */
86: public void setName(String name) {
87: this.name = name;
88: }
89:
90: }
|