Methods Summary |
---|
private static java.lang.String | addRandomTo(java.lang.String hexString)
long hexAsLong = convertToLong(hexString);
int nextRandom = getNextInt();
long resultInt = hexAsLong + nextRandom;
String result = Long.toHexString(resultInt);
// START PWC 6425338
// Always return a length of 7
int len = result.length();
if (len < 7) {
result = padto7(result);
} else {
result = result.substring(len - 7, len);
}
// END PWC 6425338
return result;
|
private static long | convertToLong(java.lang.String hexString)
long result = 0;
try
{
result = (Long.valueOf(hexString, 16)).longValue();
} catch (NumberFormatException ex) {
}
return result;
|
private static java.lang.String | formatHexString(int inputInt)
String result = null;
String s = Integer.toHexString(inputInt);
/* PWC 6425338
if(s.length() < 8)
{
result = s;
} else {
result = s.substring(0, 7);
}
*/
// START PWC 6425338
// Always return a length of 7
int len = s.length();
if (len < 7) {
result = padto7(s);
} else {
result = s.substring(len - 7, len);
}
// END PWC 6425338
return result;
|
public static java.lang.String | generateUuid()
return generateUuid(new Object());
|
public static java.lang.String | generateUuid(java.lang.Object obj)
//low order time bits
long presentTime = System.currentTimeMillis();
int presentTimeLow = (int) presentTime & 0xFFFFFFFF;
String presentTimeStringLow = formatHexString(presentTimeLow);
StringBuffer sb = new StringBuffer(50);
sb.append(presentTimeStringLow);
//sb.append(":");
sb.append(getIdentityHashCode(obj));
//sb.append(":");
//sb.append(_inetAddr);
sb.append(addRandomTo(_inetAddr));
//sb.append(":");
sb.append(getNextRandomString());
return sb.toString();
|
public static java.lang.String | generateUuidMM()
//first method (from MarketMaker Guid)
return new StringBuffer(new UID().toString()).reverse().append(':").append(_inetAddr).toString();
|
private static java.lang.String | getIdentityHashCode(java.lang.Object obj)Method getIdentityHashCode
String result = null;
try {
int hc = System.identityHashCode(obj);
return formatHexString(hc);
} catch (Exception ex) {
//must return a value
//return null;
return "8AF5182";
}
|
private static synchronized int | getNextInt()
return _seeder.nextInt();
|
private static java.lang.String | getNextRandomString()
int nextInt = getNextInt();
return formatHexString(nextInt);
|
private static java.lang.String | initInetAddr()Method initInetAddr
try {
byte[] bytes = InetAddress.getLocalHost().getAddress();
StringBuffer b = new StringBuffer();
String s = null;
for (int i = 0; i < bytes.length; i++) {
s = Integer.toHexString(bytes[i]);
if (bytes[i] < 0) {
b.append(s.substring(s.length() - 2));
} else {
b.append(s);
}
}
return b.toString();
} catch (Exception ex) {
//must return a value
return "a48eb993";
//return null;
}
|
public static void | main(java.lang.String[] args)Method main
System.out.println(UuidUtil.generateUuidMM());
System.out.println(UuidUtil.generateUuid());
System.out.println(UuidUtil.generateUuid(new Object()));
|
private static java.lang.String | padto7(java.lang.String s)
int i = 0;
char[] chars = new char[7];
int len = s.length();
while (i < len) {
chars[i] = s.charAt(i);
i++;
}
while (i < 7) {
chars[i++] = '0";
}
return new String(chars);
|