test.ca.odell.glazedlists.RandomDataFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
/* Glazed Lists (c) 2003-2006 */
/* http://publicobject.com/glazedlists/ publicobject.com,*/
/* O'Dell Engineering Ltd.*/
package ca.odell.glazedlists;
import java.util.Random;
/**
* Produces random data for test cases to consume.
*
* @author Jesse Wilson
*/
public class RandomDataFactory {
/** the raw random data */
private static Random dice = new Random();
private static String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
/**
* Constructs a random string of the specified length.
*/
public static String nextString(int length) {
StringBuffer result = new StringBuffer();
for(int i = 0; i < length; i++) {
result.append(nextCharacter());
}
return result.toString();
}
/**
* Gets a random character.
*/
public static char nextCharacter() {
return alphabet.charAt(dice.nextInt(alphabet.length()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy