KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > Gourmet


1 package org.apache.ojb.broker;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Iterator JavaDoc;
5 import java.util.List JavaDoc;
6 import java.util.Vector JavaDoc;
7
8 /**
9  * 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 JavaDoc
14 {
15     int gourmetId;
16     String JavaDoc name;
17     List JavaDoc favoriteFood = new Vector JavaDoc();
18     /**
19      * Constructor for Gourmet.
20      */

21     public Gourmet()
22     {
23         super();
24     }
25     
26     public Gourmet(String JavaDoc name)
27     {
28         this.name = name;
29     }
30     
31     public List JavaDoc getFavoriteFood()
32     {
33         return favoriteFood;
34     }
35     
36     public void addFavoriteFood(InterfaceFood food)
37     {
38         favoriteFood.add(food);
39     }
40
41     /**
42      * Returns the gourmetId.
43      * @return int
44      */

45     public int getGourmetId()
46     {
47         return gourmetId;
48     }
49     
50     public String JavaDoc toString()
51     {
52      StringBuffer JavaDoc text = new StringBuffer JavaDoc("Gourmet: id = " + gourmetId + "\n");
53      text.append("name = ");
54      text.append(name);
55      text.append("\nFavoriteFood:\n");
56      for(Iterator JavaDoc it = favoriteFood.iterator(); it.hasNext();)
57      {
58         text.append(it.next().toString());
59         text.append("\n-------\n");
60      }
61      return text.toString();
62     }
63
64
65     /**
66      * Returns the name.
67      * @return String
68      */

69     public String JavaDoc getName()
70     {
71         return name;
72     }
73
74     /**
75      * Sets the favoriteFood.
76      * @param favoriteFood The favoriteFood to set
77      */

78     public void setFavoriteFood(List JavaDoc favoriteFood)
79     {
80         this.favoriteFood = favoriteFood;
81     }
82
83     /**
84      * Sets the gourmetId.
85      * @param gourmetId The gourmetId to set
86      */

87     public void setGourmetId(int gourmetId)
88     {
89         this.gourmetId = gourmetId;
90     }
91
92     /**
93      * Sets the name.
94      * @param name The name to set
95      */

96     public void setName(String JavaDoc name)
97     {
98         this.name = name;
99     }
100
101 }
102
Popular Tags