001: /**
002: * Speedo: an implementation of JDO compliant personality on top of JORM generic
003: * I/O sub-system.
004: * Copyright (C) 2001-2004 France Telecom R&D
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: *
021: *
022: * Contact: speedo@objectweb.org
023: *
024: */package org.objectweb.speedo.pobjects.fetchgroup;
025:
026: import java.util.Iterator;
027: import java.util.Set;
028:
029: /**
030: * @author Y.Bersihand
031: */
032: public class Person {
033:
034: private String name;
035: private Address address;
036: private Set children;
037: private int age;
038:
039: public Person() {
040: }
041:
042: public Person(String name, Address address, Set children, int age) {
043: this .name = name;
044: this .address = address;
045: this .children = children;
046: this .age = age;
047: }
048:
049: public Address getAddress() {
050: return address;
051: }
052:
053: public void setAddress(Address address) {
054: this .address = address;
055: }
056:
057: public Set getChildren() {
058: return children;
059: }
060:
061: public void setChildren(Set children) {
062: this .children = children;
063: }
064:
065: public boolean hasChildren() {
066: if (children == null)
067: return false;
068: return !children.isEmpty();
069: }
070:
071: public String getName() {
072: return name;
073: }
074:
075: public void setName(String name) {
076: this .name = name;
077: }
078:
079: public int getAge() {
080: return age;
081: }
082:
083: public void setAge(int age) {
084: this .age = age;
085: }
086:
087: public String toString() {
088: String s = "Person[" + name + ", " + age;
089: if (address != null)
090: s += ", " + address.toString();
091: else
092: s += ", no address";
093: if (hasChildren()) {
094: s += "\n";
095: Iterator it = children.iterator();
096: while (it.hasNext()) {
097: Person p = (Person) it.next();
098: s += "\t" + p.toString() + "\n";
099: }
100: } else {
101: s += ", no child";
102: }
103: s += "]";
104: return s;
105: }
106: }
|