List of usage examples for java.util UUID getLeastSignificantBits
public long getLeastSignificantBits()
From source file:org.dashbuilder.dataset.backend.BackendUUIDGenerator.java
public String uuidToBase64(String str) { Base64 base64 = new Base64(); UUID uuid = UUID.fromString(str); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.crushpaper.UuidlIdGenerator.java
@Override public String getAnotherId() { final UUID uuid = UUID.randomUUID(); final ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:net.servicestack.client.Utils.java
public static byte[] toGuidBytes(UUID theUuid) { ByteBuffer first8 = ByteBuffer.allocate(8); first8.putLong(theUuid.getMostSignificantBits()); first8.rewind();// www . java 2 s. c o m byte[] first4 = new byte[4]; first8.get(first4); reverse(first4); byte[] second2 = new byte[2]; first8.get(second2); reverse(second2); byte[] third2 = new byte[2]; first8.get(third2); reverse(third2); ByteBuffer converted16 = ByteBuffer.allocate(16).put(first4).put(second2).put(third2); ByteBuffer last8 = ByteBuffer.allocate(8); last8.putLong(theUuid.getLeastSignificantBits()); last8.rewind(); converted16.put(last8); return converted16.array(); }
From source file:org.spout.engine.filesystem.fields.UUIDField.java
public Tag<?> getValue(String name, UUID value) { List<LongTag> list = new ArrayList<LongTag>(); list.add(new LongTag("", value.getMostSignificantBits())); list.add(new LongTag("", value.getLeastSignificantBits())); return new ListTag<LongTag>(name, LongTag.class, list); }
From source file:org.echocat.jomon.net.cluster.channel.multicast.MulticastClusterChannelIntegrationTest.java
@Nonnull @Override// w w w .j a v a 2s. c o m protected MulticastNode createNode(@Nonnull UUID uuid) { return new MulticastNode((short) uuid.getLeastSignificantBits(), uuid, new InetSocketAddress(HOST, PORT)); }
From source file:natalia.dymnikova.cluster.scheduler.impl.AkkaBackedScheduler.java
private String makeFlowName(String descriptor) { final UUID uuid = UUID.randomUUID(); return format("%s%016x%016x", descriptor, uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()); }
From source file:org.lilyproject.repository.impl.DFSBlobStoreAccess.java
@Override public OutputStream getOutputStream(Blob blob) throws BlobException { UUID uuid = UUID.randomUUID(); byte[] blobKey = Bytes.toBytes(uuid.getMostSignificantBits()); blobKey = Bytes.add(blobKey, Bytes.toBytes(uuid.getLeastSignificantBits())); FSDataOutputStream fsDataOutputStream; try {/*from www.j ava 2s. c o m*/ fsDataOutputStream = fileSystem.create(createPath(uuid)); } catch (IOException e) { throw new BlobException("Failed to open an outputstream for blob '" + blob + "' on the DFS blobstore", e); } return new DFSBlobOutputStream(fsDataOutputStream, blobKey, blob); }
From source file:org.lilyproject.repository.impl.HBaseBlobStoreAccess.java
@Override public OutputStream getOutputStream(Blob blob) throws BlobException { UUID uuid = UUID.randomUUID(); byte[] blobKey = Bytes.toBytes(uuid.getMostSignificantBits()); blobKey = Bytes.add(blobKey, Bytes.toBytes(uuid.getLeastSignificantBits())); return new HBaseBlobOutputStream(table, blobKey, blob); }
From source file:com.github.sebhoss.identifier.service.SuppliedIdentifiers.java
private String convertUuidToBase64(final UUID uuid) { final ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return removePadding(encoder.encodeToString(bb.array())); }
From source file:ro.kuberam.libs.java.crypto.CryptoModuleTests.java
@Test public void uuid5NewTest() throws Exception { final String NameSpace_OID_string = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"; final UUID NameSpace_OID_uuid = UUID.fromString(NameSpace_OID_string); final long msb = NameSpace_OID_uuid.getMostSignificantBits(); final long lsb = NameSpace_OID_uuid.getLeastSignificantBits(); final byte[] NameSpace_OID_buffer = new byte[16]; for (int i = 0; i < 8; i++) { NameSpace_OID_buffer[i] = (byte) (msb >>> 8 * (7 - i)); }/*from w w w.ja v a 2 s.c o m*/ for (int i = 8; i < 16; i++) { NameSpace_OID_buffer[i] = (byte) (lsb >>> 8 * (7 - i)); } final String name = "user123"; final byte[] name_buffer = name.getBytes(); try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { outputStream.write(NameSpace_OID_buffer); outputStream.write(name_buffer); final byte byteArray[] = outputStream.toByteArray(); System.out.println(UUID.nameUUIDFromBytes(byteArray).toString()); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }