Example usage for java.util UUID getMostSignificantBits

List of usage examples for java.util UUID getMostSignificantBits

Introduction

In this page you can find the example usage for java.util UUID getMostSignificantBits.

Prototype

public long getMostSignificantBits() 

Source Link

Document

Returns the most significant 64 bits of this UUID's 128 bit value.

Usage

From source file:org.apache.jackrabbit.oak.plugins.segment.file.TarReader.java

/**
 * Regenerates a tar file from a list of entries.
 * //from  ww w  .j a  v a2 s  . c o  m
 * @param entries
 * @param file
 * @throws IOException
 */
private static void generateTarFile(LinkedHashMap<UUID, byte[]> entries, File file) throws IOException {
    log.info("Regenerating tar file " + file);
    TarWriter writer = new TarWriter(file);
    for (Map.Entry<UUID, byte[]> entry : entries.entrySet()) {
        UUID uuid = entry.getKey();
        byte[] data = entry.getValue();
        writer.writeEntry(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits(), data, 0, data.length);
    }
    writer.close();
}

From source file:org.primeframework.mvc.parameter.convert.converters.UUIDConverter.java

protected String objectToString(Object value, Type convertFrom, Map<String, String> attributes,
        String expression) throws ConversionException, ConverterStateException {
    UUID uuid = (UUID) value;
    if (uuid.getMostSignificantBits() == 0) {
        return Long.toString(uuid.getLeastSignificantBits());
    }//ww  w  .j a  va2s. co  m
    return value.toString();
}

From source file:org.sakaiproject.nakamura.personal.JCRPersonalTrackingStore.java

private byte[] asShorterByteArray(UUID uuid) {

    long msb = uuid.getMostSignificantBits();
    byte[] buffer = new byte[8];

    for (int i = 0; i < 8; i++) {
        buffer[i] = (byte) (msb >>> 8 * (7 - i));
    }/*from  ww  w  .j a  va 2  s .c  om*/

    return buffer;

}

From source file:org.dashbuilder.dataset.UUIDGeneratorImpl.java

public String uuidToBase64(String str) {
    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: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:org.apache.jackrabbit.oak.segment.file.TarReader.java

/**
 * Regenerates a tar file from a list of entries.
 * //from   w ww . j  av a  2  s .  co  m
 * @param entries
 * @param file
 * @throws IOException
 */
private static void generateTarFile(LinkedHashMap<UUID, byte[]> entries, File file) throws IOException {
    log.info("Regenerating tar file {}", file);
    TarWriter writer = new TarWriter(file);
    for (Map.Entry<UUID, byte[]> entry : entries.entrySet()) {
        UUID uuid = entry.getKey();
        byte[] data = entry.getValue();
        int generation = getGcGeneration(wrap(data), uuid);
        writer.writeEntry(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits(), data, 0, data.length,
                generation);
    }
    writer.close();
}

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.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  w w w .java2 s . c  om*/
        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);
}