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 {
|
public static class RandomString {
|
||||||
|
|
||||||
private static final char[] symbols;
|
private static final char[] symbols;
|
||||||
|
private static final char[] startingSymbols;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
StringBuilder tmp = new StringBuilder();
|
StringBuilder tmp = new StringBuilder();
|
||||||
for (char ch = '0'; ch <= '9'; ++ch)
|
|
||||||
tmp.append(ch);
|
|
||||||
for (char ch = 'a'; ch <= 'z'; ++ch)
|
for (char ch = 'a'; ch <= 'z'; ++ch)
|
||||||
tmp.append(ch);
|
tmp.append(ch);
|
||||||
|
startingSymbols = tmp.toString().toCharArray();
|
||||||
|
for (char ch = '0'; ch <= '9'; ++ch)
|
||||||
|
tmp.append(ch);
|
||||||
symbols = tmp.toString().toCharArray();
|
symbols = tmp.toString().toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final int length;
|
||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
|
|
||||||
private final char[] buf;
|
|
||||||
|
|
||||||
public RandomString(int length) {
|
public RandomString(int length) {
|
||||||
if (length < 1)
|
if (length < 1)
|
||||||
throw new IllegalArgumentException("length < 1: " + length);
|
throw new IllegalArgumentException("length < 1: " + length);
|
||||||
buf = new char[length];
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String nextString() {
|
public synchronized String nextString() {
|
||||||
for (int idx = 0; idx < buf.length; ++idx)
|
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)];
|
buf[idx] = symbols[random.nextInt(symbols.length)];
|
||||||
return new String(buf);
|
return new String(buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue