List of usage examples for java.util UUID getMostSignificantBits
public long getMostSignificantBits()
From source file:org.linguafranca.pwdb.kdbx.Helpers.java
public static String base64FromUuid(UUID uuid) { byte[] buffer = new byte[16]; ByteBuffer b = ByteBuffer.wrap(buffer); b.putLong(uuid.getMostSignificantBits()); b.putLong(8, uuid.getLeastSignificantBits()); // round the houses for Android return new String(Base64.encodeBase64(buffer)); }
From source file:org.linguafranca.pwdb.kdbx.Helpers.java
public static String hexStringFromUuid(UUID uuid) { byte[] buffer = new byte[16]; ByteBuffer b = ByteBuffer.wrap(buffer); b.putLong(uuid.getMostSignificantBits()); b.putLong(8, uuid.getLeastSignificantBits()); // round the houses for Android return new String(Hex.encodeHex(buffer)); }
From source file:com.enonic.cms.framework.util.UUIDGenerator.java
/** * Generate random uuid./*w ww .j a v a 2s. com*/ */ public static String randomUUID() { UUID uuid = UUID.randomUUID(); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(out); dataOut.writeLong(uuid.getMostSignificantBits()); dataOut.writeLong(uuid.getLeastSignificantBits()); dataOut.close(); return new String(Hex.encodeHex(out.toByteArray())); } catch (Exception e) { return uuid.toString(); } }
From source file:net.geertvos.theater.core.util.UUIDGen.java
/** 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)); }/*from ww w . ja v a 2 s.c o m*/ return b; }
From source file:com.networknt.utility.Util.java
/** * Generate UUID across the entire app and it is used for correlationId. * * @return String correlationId//from www. j a va2s. c om */ public static String getUUID() { UUID id = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(id.getMostSignificantBits()); bb.putLong(id.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:net.geertvos.theater.core.util.UUIDGen.java
/** writes a uuid to an output stream. */ public static void write(UUID uuid, DataOutput dos) throws IOException { dos.writeLong(uuid.getMostSignificantBits()); dos.writeLong(uuid.getLeastSignificantBits()); }
From source file:Main.java
/** * Check whether the given parcelUuid can be converted to 32 bit bluetooth uuid. * * @param parcelUuid// ww w . jav a2 s .c om * @return true if the parcelUuid can be converted to 32 bit uuid, false otherwise. */ public static boolean is32BitUuid(ParcelUuid parcelUuid) { UUID uuid = parcelUuid.getUuid(); if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) { return false; } if (is16BitUuid(parcelUuid)) { return false; } return ((uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L); }
From source file:org.zper.ZPUtils.java
synchronized public static byte[] genTopicIdentity(String topic, int flag) { byte[] identity = new byte[1 + 2 + topic.length() + 16]; ByteBuffer buf = ByteBuffer.wrap(identity); UUID uuid = UUID.randomUUID(); buf.put((byte) topic.hashCode()); buf.put((byte) flag); buf.put((byte) topic.length()); buf.put(topic.getBytes());//from w ww .j a v a 2s .c om buf.putLong(uuid.getMostSignificantBits()); buf.putLong(uuid.getLeastSignificantBits()); return identity; }
From source file:com.scf.utils.UUIDUtilies.java
protected static String base64Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.scf.utils.UUIDUtilies.java
protected static String base58Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base58.encode(bb.array()); }