1 12 package org.displaytag.sample; 13 14 import java.util.Calendar ; 15 import java.util.Date ; 16 import java.util.Random ; 17 18 19 24 public final class RandomSampleUtil 25 { 26 27 30 private static String [] words = new String []{"Lorem", "ipsum", "dolor", "sit", "amet", "consetetur", "sadipscing", "elitr", "sed", "diam", "nonumy", "eirmod", "tempor", "invidunt", "ut", "labore", "et", "dolore", "magna", "aliquyam", "erat", "sed", "diam", "voluptua", "At", "vero", "eos", "et", "accusam", "et", "justo", "duo", "dolores", "et", "ea", "rebum", "Stet", "clita", "kasd", "gubergren", "no", "sea", "takimata", "sanctus", "est"}; 76 79 private static Random random = new Random (); 80 81 84 private RandomSampleUtil() 85 { 86 super(); 87 } 88 89 93 public static String getRandomWord() 94 { 95 return words[random.nextInt(words.length)]; 96 } 97 98 103 public static String getRandomSentence(int wordNumber) 104 { 105 StringBuffer buffer = new StringBuffer (wordNumber * 12); 106 107 int j = 0; 108 while (j < wordNumber) 109 { 110 buffer.append(getRandomWord()); 111 buffer.append(" "); j++; 113 } 114 return buffer.toString(); 115 } 116 117 121 public static String getRandomEmail() 122 { 123 return getRandomWord() + "@" + getRandomWord() + ".com"; } 125 126 130 public static Date getRandomDate() 131 { 132 133 Calendar calendar = Calendar.getInstance(); 134 calendar.add(Calendar.DATE, 365 - random.nextInt(730)); 135 return calendar.getTime(); 136 } 137 } 138 | Popular Tags |