1 8 package org.codehaus.aspectwerkz.proxy; 9 10 33 public final class Uuid { 34 35 public static final long UUID_NONE = 0; 36 public static final long UUID_WILD = -1; 37 public static final long UUID_MAGICMASK = 0xff << 56; 38 public static final long UUID_MAGIC = 'U' << 56; 39 40 protected static long lastTime; 41 42 46 public synchronized static long newUuid() { 47 long time = System.currentTimeMillis(); 48 49 if (time <= lastTime) { 50 time = lastTime + 1; 51 } 52 lastTime = time; 53 return UUID_MAGIC | time; 54 } 55 56 59 public static boolean isValid(final long uuid) { 60 return (uuid & UUID_MAGICMASK) == UUID_MAGIC 61 && (uuid & ~UUID_MAGICMASK) != 0; 62 } 63 } 64 65 | Popular Tags |