1 12 package org.displaytag.sample; 13 14 import java.util.Random ; 15 16 import org.apache.commons.lang.builder.CompareToBuilder; 17 import org.apache.commons.lang.builder.ToStringBuilder; 18 import org.apache.commons.lang.builder.ToStringStyle; 19 20 21 27 public class ReportableListObject extends Object implements Comparable 28 { 29 30 33 private static Random random = new Random (); 34 35 38 private static String [] cities = {"Roma", "Olympia", "Neapolis", "Carthago"}; 41 44 private static String [] projects = {"Taxes", "Arts", "Army", "Gladiators"}; 47 50 private String city; 51 52 55 private String project; 56 57 60 private String task; 61 62 65 private double amount; 66 67 70 private int count; 71 72 75 public ReportableListObject() 76 { 77 this.amount = (random.nextInt(99999) + 1) / 100; 78 this.city = cities[random.nextInt(cities.length)]; 79 this.project = projects[random.nextInt(projects.length)]; 80 this.task = RandomSampleUtil.getRandomSentence(4); 81 this.count = random.nextInt(10); 82 } 83 84 88 public String getCity() 89 { 90 return this.city; 91 } 92 93 97 public int getCount() 98 { 99 return this.count; 100 } 101 102 106 public String getProject() 107 { 108 return this.project; 109 } 110 111 115 public String getTask() 116 { 117 return this.task; 118 } 119 120 124 public double getAmount() 125 { 126 return this.amount; 127 } 128 129 132 public int compareTo(Object object) 133 { 134 ReportableListObject myClass = (ReportableListObject) object; 135 return new CompareToBuilder().append(this.project, myClass.project).append(this.amount, myClass.amount).append( 136 this.city, 137 myClass.city).append(this.task, myClass.task).toComparison(); 138 } 139 140 143 public String toString() 144 { 145 return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE) .append("project", this.project) .append("amount", this.amount) .append("city", this.city) .append("task", this.task) .toString(); 151 } 152 153 } 154 | Popular Tags |