1 24 package org.objectweb.jalisto.se.test.data; 25 26 import org.objectweb.jalisto.se.api.ClassDescription; 27 import org.objectweb.jalisto.se.JalistoFactory; 28 import org.objectweb.jalisto.se.impl.meta.type.MetaTypeFactory; 29 30 import java.util.ArrayList ; 31 32 public class Library { 33 34 private Library(String address, ArrayList clients, ArrayList books) { 35 this.address = address; 36 this.clients = clients; 37 this.books = books; 38 } 39 40 public String getAddress() { 41 return address; 42 } 43 44 public void setAddress(String address) { 45 this.address = address; 46 } 47 48 public ArrayList getBooks() { 49 return books; 50 } 51 52 public void setBooks(ArrayList books) { 53 this.books = books; 54 } 55 56 public ArrayList getClients() { 57 return clients; 58 } 59 60 public void setClients(ArrayList clients) { 61 this.clients = clients; 62 } 63 64 public Object getAuthorMostWanted() { 65 return authorMostWanted; 66 } 67 68 public void setAuthorMostWanted(Object authorMostWantedOid) { 69 this.authorMostWanted = authorMostWantedOid; 70 } 71 72 73 public Object [] toArray() { 74 Object [] result = new Object [4]; 75 result[0] = address; 76 result[1] = clients; 77 result[2] = books; 78 result[3] = authorMostWanted; 79 return result; 80 } 81 82 public static Library toLibrary(Object [] array) { 83 Library library = new Library( 84 (String ) array[0], 85 (ArrayList ) array[1], 86 (ArrayList ) array[2]); 87 library.setAuthorMostWanted(array[3]); 88 return library; 89 } 90 91 92 private String address; 93 private ArrayList clients; 94 private ArrayList books; 95 private Object authorMostWanted; 96 97 98 public static Library newLibrary() { 99 counter++; 100 return new Library(getNewAddress(counter), 101 new ArrayList (), 102 new ArrayList ()); 103 } 104 105 private static String getNewAddress(int c) { 106 return addresses[c % addresses.length]; 107 } 108 109 public static ClassDescription getMetaDescription() { 110 ClassDescription meta = JalistoFactory.createClassDescription(Library.class.getName()); 111 meta.addField(JalistoFactory.createFieldDescription("address", MetaTypeFactory.StringType)); 112 meta.addField(JalistoFactory.createFieldDescription("clients", MetaTypeFactory.CollectionType)); 113 meta.addField(JalistoFactory.createFieldDescription("books", MetaTypeFactory.CollectionType)); 114 meta.addField(JalistoFactory.createFieldDescription("authorMostWanted", MetaTypeFactory.LinkType)); 115 return meta; 116 } 117 118 public static int counter = -1; 119 public static final String [] addresses = {"36 rue de picpus", 120 "107 rue de reuilly", 121 "20 rue de dante", 122 "15 impasse de l'enfer"}; 123 124 static final long serialVersionUID = -7589377092222761459L; 125 } 126 | Popular Tags |