1 12 package org.displaytag.sample; 13 14 import java.util.ArrayList ; 15 import java.util.Date ; 16 import java.util.List ; 17 import java.util.Random ; 18 19 import org.apache.commons.lang.StringUtils; 20 import org.apache.commons.lang.builder.ToStringBuilder; 21 import org.apache.commons.lang.builder.ToStringStyle; 22 23 24 31 public class ListObject 32 { 33 34 37 private static Random random = new Random (); 38 39 42 private int id = -1; 43 44 47 private String name; 48 49 52 private String email; 53 54 57 private Date date; 58 59 62 private double money; 63 64 67 private String description; 68 69 72 private String longDescription; 73 74 77 private String status; 78 79 82 private String url; 83 84 87 private List subList; 88 89 92 public ListObject() 93 { 94 this.id = random.nextInt(99998) + 1; 95 this.money = (random.nextInt(999998) + 1) / 100; 96 97 String firstName = RandomSampleUtil.getRandomWord(); 98 String lastName = RandomSampleUtil.getRandomWord(); 99 100 this.name = StringUtils.capitalize(firstName) + ' ' + StringUtils.capitalize(lastName); 101 102 this.email = firstName + '-' + lastName + '@' + RandomSampleUtil.getRandomWord() + ".com"; 104 this.date = RandomSampleUtil.getRandomDate(); 105 106 this.description = RandomSampleUtil.getRandomWord() + ' ' + RandomSampleUtil.getRandomWord() + "..."; 109 this.longDescription = RandomSampleUtil.getRandomSentence(10); 110 111 this.status = RandomSampleUtil.getRandomWord().toUpperCase(); 112 113 this.subList = new ArrayList (); 115 this.subList.add(new SubListItem()); 116 this.subList.add(new SubListItem()); 117 this.subList.add(new SubListItem()); 118 119 this.url = "http://www." + lastName + ".org/"; } 121 122 126 public int getId() 127 { 128 return this.id; 129 } 130 131 135 public void setId(int value) 136 { 137 this.id = value; 138 } 139 140 144 public String getName() 145 { 146 return this.name; 147 } 148 149 153 public String getEmail() 154 { 155 return this.email; 156 } 157 158 162 public void setEmail(String value) 163 { 164 this.email = value; 165 } 166 167 171 public Date getDate() 172 { 173 return (Date ) this.date.clone(); 174 } 175 176 180 public double getMoney() 181 { 182 return this.money; 183 } 184 185 189 public String getDescription() 190 { 191 return this.description; 192 } 193 194 198 public String getLongDescription() 199 { 200 return this.longDescription; 201 } 202 203 207 public String getStatus() 208 { 209 return this.status; 210 } 211 212 216 public String getUrl() 217 { 218 return this.url; 219 } 220 221 225 public String getNullValue() 226 { 227 return null; 228 } 229 230 234 public String toString() 235 { 236 return "ListObject(" + this.id + ")"; } 238 239 243 public String toDetailedString() 244 { 245 return "ID: " + this.id + "\n" + "Name: " + this.name + "\n" + "Email: " + this.email + "\n" + "Date: " + this.date + "\n" + "Money: " + this.money + "\n" + "Description: " + this.description + "\n" + "Status: " + this.status + "\n" + "URL: " + this.url + "\n"; } 262 263 267 public List getSubList() 268 { 269 return this.subList; 270 } 271 272 276 public static class SubListItem 277 { 278 279 282 private String itemName; 283 284 287 private String itemEmail; 288 289 292 public SubListItem() 293 { 294 this.itemName = RandomSampleUtil.getRandomWord(); 295 this.itemEmail = RandomSampleUtil.getRandomEmail(); 296 } 297 298 302 public String getName() 303 { 304 return this.itemName; 305 } 306 307 311 public String getEmail() 312 { 313 return this.itemEmail; 314 } 315 316 319 public String toString() 320 { 321 return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE) .append("name", this.itemName) .append("email", this.itemEmail) .toString(); 325 } 326 } 327 328 } 329 | Popular Tags |