public synchronized Object next(StoreContext ctx, ClassMetaData meta) { _last = UUIDGenerator.nextHex(UUIDGenerator.TYPE1); return _last; }
public synchronized Object next(StoreContext ctx, ClassMetaData meta) { _last = UUIDGenerator.nextString(UUIDGenerator.TYPE4); return _last; }
/** * Get the timestamp to be used for this uuid. Must be called from * a synchronized block. * * @return long timestamp */ // package-visibility for testing static long getTime() { if (RANDOM == null) initializeForType1(); long newTime = getUUIDTime(); if (newTime <= _lastMillis) { incrementSequence(); newTime = getUUIDTime(); } _lastMillis = newTime; return newTime; }
/** * Return a unique UUID value. */ public static byte[] next(int type) { if (type == TYPE4) { return createType4(); } return createType1(); }
/** * Get the timestamp to be used for this uuid. Must be called from * a synchronized block. * * @return long timestamp */ // package-visibility for testing static long getTime() { long newTime = getUUIDTime(); if (newTime <= _lastMillis) { incrementSequence(); newTime = getUUIDTime(); } _lastMillis = newTime; return newTime; }
/** * Generate a value for the given metadaa. */ private static Object generateValue(StoreContext ctx, ClassMetaData meta, FieldMetaData fmd, int typeCode) { int strategy = (fmd == null) ? meta.getIdentityStrategy() : fmd.getValueStrategy(); switch (strategy) { case ValueStrategies.SEQUENCE: SequenceMetaData smd = (fmd == null) ? meta.getIdentitySequenceMetaData() : fmd.getValueSequenceMetaData(); return JavaTypes.convert(smd.getInstance(ctx.getClassLoader()). next(ctx, meta), typeCode); case ValueStrategies.UUID_STRING: return UUIDGenerator.nextString(UUIDGenerator.TYPE1); case ValueStrategies.UUID_HEX: return UUIDGenerator.nextHex(UUIDGenerator.TYPE1); case ValueStrategies.UUID_TYPE4_STRING: return UUIDGenerator.nextString(UUIDGenerator.TYPE4); case ValueStrategies.UUID_TYPE4_HEX: return UUIDGenerator.nextHex(UUIDGenerator.TYPE4); default: return null; } }
public static byte[] createType1() { if (type1Initialized == false) { initializeForType1(); now = getTime();
/** * Return the next unique uuid value as a 16-character string. */ public static String nextString(int type) { byte[] bytes = next(type); try { return new String(bytes, "ISO-8859-1"); } catch (Exception e) { return new String(bytes); } }
private static byte[] createType4() { UUID type4 = UUID.randomUUID(); byte[] uuid = new byte[16]; longToBytes(type4.getMostSignificantBits(), uuid, 0); longToBytes(type4.getLeastSignificantBits(), uuid, 8); return uuid; }
/** * Generate a value for the given metadaa. */ private static Object generateValue(StoreContext ctx, ClassMetaData meta, FieldMetaData fmd, int typeCode) { int strategy = (fmd == null) ? meta.getIdentityStrategy() : fmd.getValueStrategy(); switch (strategy) { case ValueStrategies.SEQUENCE: SequenceMetaData smd = (fmd == null) ? meta.getIdentitySequenceMetaData() : fmd.getValueSequenceMetaData(); return JavaTypes.convert(smd.getInstance(ctx.getClassLoader()). next(ctx, meta), typeCode); case ValueStrategies.UUID_STRING: return UUIDGenerator.nextString(UUIDGenerator.TYPE1); case ValueStrategies.UUID_HEX: return UUIDGenerator.nextHex(UUIDGenerator.TYPE1); case ValueStrategies.UUID_TYPE4_STRING: return UUIDGenerator.nextString(UUIDGenerator.TYPE4); case ValueStrategies.UUID_TYPE4_HEX: return UUIDGenerator.nextHex(UUIDGenerator.TYPE4); default: return null; } }
public static byte[] createType1() { if (type1Initialized == false) { initializeForType1(); now = getTime();
/** * Return the next unique uuid value as a 16-character string. */ public static String nextString(int type) { byte[] bytes = next(type); try { return new String(bytes, "ISO-8859-1"); } catch (Exception e) { return new String(bytes); } }
/** * Return a unique UUID value. */ public static byte[] next(int type) { if (type == TYPE4) { return createType4(); } return createType1(); }
private static byte[] createType4() { UUID type4 = UUID.randomUUID(); byte[] uuid = new byte[16]; longToBytes(type4.getMostSignificantBits(), uuid, 0); longToBytes(type4.getLeastSignificantBits(), uuid, 8); return uuid; }
/** * Generate a value for the given metadaa. */ private static Object generateValue(StoreContext ctx, ClassMetaData meta, FieldMetaData fmd, int typeCode) { int strategy = (fmd == null) ? meta.getIdentityStrategy() : fmd.getValueStrategy(); switch (strategy) { case ValueStrategies.SEQUENCE: SequenceMetaData smd = (fmd == null) ? meta.getIdentitySequenceMetaData() : fmd.getValueSequenceMetaData(); return JavaTypes.convert(smd.getInstance(ctx.getClassLoader()). next(ctx, meta), typeCode); case ValueStrategies.UUID_STRING: return UUIDGenerator.nextString(UUIDGenerator.TYPE1); case ValueStrategies.UUID_HEX: return UUIDGenerator.nextHex(UUIDGenerator.TYPE1); case ValueStrategies.UUID_TYPE4_STRING: return UUIDGenerator.nextString(UUIDGenerator.TYPE4); case ValueStrategies.UUID_TYPE4_HEX: return UUIDGenerator.nextHex(UUIDGenerator.TYPE4); default: return null; } }
/** * Get the timestamp to be used for this uuid. Must be called from * a synchronized block. * * @return long timestamp */ // package-visibility for testing static long getTime() { if (RANDOM == null) initializeForType1(); long newTime = getUUIDTime(); if (newTime <= _lastMillis) { incrementSequence(); newTime = getUUIDTime(); } _lastMillis = newTime; return newTime; }
public synchronized Object next(StoreContext ctx, ClassMetaData meta) { _last = UUIDGenerator.nextString(UUIDGenerator.TYPE4); return _last; }
public synchronized Object next(StoreContext ctx, ClassMetaData meta) { _last = UUIDGenerator.nextHex(UUIDGenerator.TYPE1); return _last; }
public static byte[] createType1() { if (type1Initialized == false) { initializeForType1(); now = getTime();