Code example for UUID

0
    } 
     
    /** creates a type 1 uuid from raw bytes. */ 
    public static UUID getUUID(ByteBuffer raw)
    { 
        return new UUID(raw.getLong(raw.position()), raw.getLong(raw.position() + 8));
    } 
 
    /** decomposes a uuid into raw bytes. */ 
    public static byte[] decompose(UUID uuid)
    { 
        long most = uuid.getMostSignificantBits();
        long least = uuid.getLeastSignificantBits();
        byte[] b = new byte[16];
        for (int i = 0; i < 8; i++)
        { 
            b[i] = (byte)(most >>> ((7-i) * 8));
            b[8+i] = (byte)(least >>> ((7-i) * 8));
        } 
        return b;
    }