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.tutorial.pobjects.additional.queries;
025:
026: import java.util.HashSet;
027: import java.util.Iterator;
028: import java.util.Set;
029:
030: /**
031: * @author Y.Bersihand
032: */
033: public class Person {
034:
035: private String name;
036: private Set children;
037: private int age;
038: private ContactDetails contactDetails;
039:
040: public Person(String name, int age, ContactDetails contactDetails) {
041: this .name = name;
042: this .age = age;
043: this .children = new HashSet();
044: this .contactDetails = contactDetails;
045: }
046:
047: public Person(String name, String type, int age,
048: ContactDetails contactDetails) {
049: this .name = name;
050: this .age = age;
051: this .children = new HashSet();
052: this .contactDetails = contactDetails;
053: }
054:
055: public Person(String name, Set children, String type, int age,
056: ContactDetails contactDetails) {
057: this .name = name;
058: this .age = age;
059: this .children = children;
060: this .contactDetails = contactDetails;
061: }
062:
063: public Set getChildren() {
064: return children;
065: }
066:
067: public void setChildren(Set children) {
068: this .children = children;
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 void addChild(Person p) {
080: if (children == null) {
081: children = new HashSet();
082: }
083: children.add(p);
084: }
085:
086: public int getAge() {
087: return age;
088: }
089:
090: public void setAge(int age) {
091: this .age = age;
092: }
093:
094: public ContactDetails getContactDetails() {
095: return contactDetails;
096: }
097:
098: public void setContactDetails(ContactDetails contactDetails) {
099: this .contactDetails = contactDetails;
100: }
101:
102: public String toString() {
103: String s = name + ", age=" + age + ", children=[";
104: Iterator it = children.iterator();
105: while (it.hasNext()) {
106: Person p = (Person) it.next();
107: s += p.getName() + ", ";
108: }
109: if (!children.isEmpty())
110: s = s.substring(0, s.length() - 2);
111: s += "]";
112: s += ", contact details=[" + contactDetails.toString() + "]";
113: return s;
114: }
115: }
|