001: /*
002: * Jalisto - JAva LIght STOrage
003: * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
018: *
019: * Xcalia
020: * 71, rue Desnouettes
021: * 75014 Paris - France
022: * http://www.xcalia.com
023: */
024: package org.objectweb.jalisto.se.test.data;
025:
026: import org.objectweb.jalisto.se.api.ClassDescription;
027: import org.objectweb.jalisto.se.JalistoFactory;
028: import org.objectweb.jalisto.se.impl.meta.type.MetaTypeFactory;
029:
030: public class Client {
031:
032: private Client() {
033: }
034:
035: private Client(String firstName, String lastName) {
036: this .firstName = firstName;
037: this .lastName = lastName;
038: }
039:
040: public String getFirstName() {
041: return firstName;
042: }
043:
044: public void setFirstName(String firstName) {
045: this .firstName = firstName;
046: }
047:
048: public String getLastName() {
049: return lastName;
050: }
051:
052: public void setLastName(String lastName) {
053: this .lastName = lastName;
054: }
055:
056: public boolean equals(Object o) {
057: try {
058: Client candidate = (Client) o;
059: return (candidate.firstName.equals(firstName) && candidate.lastName
060: .equals(lastName));
061: } catch (Exception e) {
062: }
063: return false;
064: }
065:
066: public Object[] toArray() {
067: Object[] result = new Object[2];
068: result[0] = firstName;
069: result[1] = lastName;
070: return result;
071: }
072:
073: public static Client toClient(Object[] array) {
074: Client client = new Client();
075: client.setFirstName((String) array[0]);
076: client.setLastName((String) array[1]);
077: return client;
078: }
079:
080: public static ClassDescription getMetaDescription() {
081: ClassDescription meta = JalistoFactory
082: .createClassDescription(Client.class.getName());
083: meta.addField(JalistoFactory.createFieldDescription(
084: "firstName", MetaTypeFactory.StringType));
085: meta.addField(JalistoFactory.createFieldDescription("lastName",
086: MetaTypeFactory.StringType));
087: return meta;
088: }
089:
090: public static Client newClient() {
091: counter++;
092: return new Client(getNewFirstName(counter),
093: getNewLastName(counter));
094: }
095:
096: private static String getNewFirstName(int c) {
097: return firstNames[c % firstNames.length];
098: }
099:
100: private static String getNewLastName(int c) {
101: return lastNames[c % lastNames.length];
102: }
103:
104: private String firstName;
105: private String lastName;
106:
107: public static int counter = -1;
108:
109: public static final String[] firstNames = { "Katharina",
110: "Sigourney", "Winona", "Jody", "Famke" };
111:
112: public static final String[] lastNames = { "Hepburn", "Weaver",
113: "Rider", "Foster", "Janssen", "Seymour", "Scott Thommas",
114: "Harlow", "Kruegger", "Sastre", "Pfeiffer", "Jovovitch",
115: "Valetta" };
116: }
|