git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-analysis/tabulardata/cube-manager-parent/3.5@130370 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fb77e1f630
commit
751f4f4621
|
@ -347,28 +347,32 @@ public class SQLDatabaseWrangler implements DatabaseWrangler {
|
|||
public static class RandomString {
|
||||
|
||||
private static final char[] symbols;
|
||||
private static final char[] startingSymbols;
|
||||
|
||||
static {
|
||||
StringBuilder tmp = new StringBuilder();
|
||||
for (char ch = '0'; ch <= '9'; ++ch)
|
||||
tmp.append(ch);
|
||||
for (char ch = 'a'; ch <= 'z'; ++ch)
|
||||
tmp.append(ch);
|
||||
startingSymbols = tmp.toString().toCharArray();
|
||||
for (char ch = '0'; ch <= '9'; ++ch)
|
||||
tmp.append(ch);
|
||||
symbols = tmp.toString().toCharArray();
|
||||
}
|
||||
|
||||
private final Random random = new Random();
|
||||
private final int length;
|
||||
|
||||
private final char[] buf;
|
||||
private final Random random = new Random();
|
||||
|
||||
public RandomString(int length) {
|
||||
if (length < 1)
|
||||
throw new IllegalArgumentException("length < 1: " + length);
|
||||
buf = new char[length];
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public String nextString() {
|
||||
for (int idx = 0; idx < buf.length; ++idx)
|
||||
public synchronized String nextString() {
|
||||
char[] buf = new char[this.length];
|
||||
buf[0] = startingSymbols[random.nextInt(startingSymbols.length)];
|
||||
for (int idx = 1; idx < buf.length; ++idx)
|
||||
buf[idx] = symbols[random.nextInt(symbols.length)];
|
||||
return new String(buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue