KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > pobjects > fetchgroup > Person


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  */

25
26 package org.objectweb.speedo.pobjects.fetchgroup;
27
28 import java.util.Iterator JavaDoc;
29 import java.util.Set JavaDoc;
30
31 /**
32  * @author Y.Bersihand
33  */

34 public class Person {
35
36     private String JavaDoc name;
37     private Address address;
38     private Set JavaDoc children;
39     private int age;
40     
41     public Person() {
42     }
43     
44     public Person(String JavaDoc name, Address address, Set JavaDoc children, int age){
45         this.name = name;
46         this.address = address;
47         this.children = children;
48         this.age = age;
49     }
50     
51     public Address getAddress() {
52         return address;
53     }
54     
55     public void setAddress(Address address) {
56         this.address = address;
57     }
58     
59     public Set JavaDoc getChildren() {
60         return children;
61     }
62     
63     public void setChildren(Set JavaDoc children) {
64         this.children = children;
65     }
66     
67     public boolean hasChildren(){
68         if(children == null)
69             return false;
70         return !children.isEmpty();
71     }
72     
73     public String JavaDoc getName() {
74         return name;
75     }
76     
77     public void setName(String JavaDoc name) {
78         this.name = name;
79     }
80     
81     public int getAge() {
82         return age;
83     }
84     
85     public void setAge(int age) {
86         this.age = age;
87     }
88     
89     public String JavaDoc toString(){
90         String JavaDoc s = "Person[" + name + ", " + age;
91         if(address != null)
92             s += ", " + address.toString();
93         else
94             s += ", no address";
95         if(hasChildren()){
96             s += "\n";
97             Iterator JavaDoc it = children.iterator();
98             while(it.hasNext()){
99                 Person p = (Person) it.next();
100                 s += "\t" + p.toString() + "\n";
101             }
102         }
103         else{
104             s += ", no child";
105         }
106         s += "]";
107         return s;
108     }
109 }
110
Popular Tags