Example usage for java.util UUID UUID

List of usage examples for java.util UUID UUID

Introduction

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

Prototype

public UUID(long mostSigBits, long leastSigBits) 

Source Link

Document

Constructs a new UUID using the specified data.

Usage

From source file:org.slc.sli.common.util.uuid.DeterministicUUIDGeneratorStrategy.java

protected static UUID generateUuid(byte[] data) {
    ByteBuffer byteBuffer = ByteBuffer.wrap(data);

    long msb = byteBuffer.getLong(0);
    long lsb = byteBuffer.getLong(8);

    UUID uuid = new UUID(msb, lsb);

    return uuid;/*from w  w w . jav a  2  s  . co  m*/
}

From source file:com.joyent.manta.client.multipart.ServerSideMultipartManagerIT.java

public void nonExistentFileHasNotStarted() throws IOException {
    String path = testPathPrefix + UUID.randomUUID().toString();
    UUID unknownId = new UUID(0L, -1L);
    ServerSideMultipartUpload upload = new ServerSideMultipartUpload(unknownId, path, null);
    assertEquals(multipart.getStatus(upload), MantaMultipartStatus.UNKNOWN);
}

From source file:com.github.seqware.queryengine.util.SGID.java

/**
 * Clone a given SGID//  ww w  . j  av  a2 s  .  com
 *
 * @param sgid a {@link com.github.seqware.queryengine.util.SGID} object.
 */
public SGID(SGID sgid) {
    uuid = new UUID(sgid.uuid.getMostSignificantBits(), sgid.uuid.getLeastSignificantBits());
    backendTimestamp = new Date(sgid.getBackendTimestamp().getTime());
    friendlyRowKey = sgid.friendlyRowKey;
}

From source file:org.diorite.entity.attrib.BasicAttributeModifier.java

/**
 * Deserialize BasicAttributeModifier from {@link NbtTagCompound}.
 *
 * @param tag data to deserialize.//from   w  w  w  . j a  v  a 2 s .c om
 */
public BasicAttributeModifier(final NbtTagCompound tag) {
    this.uuid = new UUID(tag.getLong("UUIDMost"), tag.getLong("UUIDLeast"));
    this.name = tag.getString("Name", (String) null);
    this.value = tag.getDouble("Amount");
    this.operation = ModifierOperation.getByEnumOrdinal(tag.getInt("Operation"));
    this.slot = ModifierSlot.getByTypeName(tag.getString("Slot", ""));
    this.type = tag.containsTag("AttributeName") ? AttributeType.getByKey(tag.getString("AttributeName"))
            : null;
}

From source file:com.joyent.manta.client.multipart.JobsMultipartManagerIT.java

public void nonExistentFileHasNotStarted() throws IOException {
    JobsMultipartUpload upload = new JobsMultipartUpload(new UUID(0L, -1L), "/dev/null");
    assertEquals(multipart.getStatus(upload), MantaMultipartStatus.UNKNOWN);
}

From source file:au.com.websitemasters.schools.lcps.push.RegistrationIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    try {/* w  w w.  j  a  v a 2 s.  c o  m*/
        // [START register_for_gcm]
        // Initially this call goes out to the network to retrieve the token, subsequent calls
        // are local.
        // R.string.gcm_defaultSenderId (the Sender ID) is typically derived from google-services.json.
        // See https://developers.google.com/cloud-messaging/android/start for details on this file.
        // [START get_token]

        InstanceID instanceID = InstanceID.getInstance(this);
        String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

        String uid;
        try {
            uid = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
        } catch (NullPointerException e) {
            final TelephonyManager tm = (TelephonyManager) getBaseContext()
                    .getSystemService(Context.TELEPHONY_SERVICE);
            final String tmDevice, tmSerial, androidId;
            tmDevice = "" + tm.getDeviceId();
            tmSerial = "" + tm.getSimSerialNumber();
            androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(),
                    android.provider.Settings.Secure.ANDROID_ID);
            UUID deviceUuid = new UUID(androidId.hashCode(),
                    ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
            uid = deviceUuid.toString();
        }

        Log.d("rklogs", "uid: " + uid);
        Log.d("rklogs", "GCM Reg Token: " + token);

        RetrofitClient client = new RetrofitClient();
        client.postToken(token, uid);

        // [END get_token]
        // TODO: Implement this method to send any registration to your app's servers.
        sendRegistrationToServer(token);

        // Subscribe to topic channels
        subscribeTopics(token);

        // You should store a boolean that indicates whether the generated token has been
        // sent to your server. If the boolean is false, send the token to your server,
        // otherwise your server should have already received the token.
        sharedPreferences.edit().putBoolean(getResources().getString(R.string.sent_token_to_server), true)
                .apply();
        // [END register_for_gcm]
    } catch (Exception e) {
        Log.d(TAG, "Failed to complete token refresh", e);
        // If an exception happens while fetching the new token or updating our registration data
        // on a third-party server, this ensures that we'll attempt the update at a later time.
        sharedPreferences.edit().putBoolean(getResources().getString(R.string.sent_token_to_server), false)
                .apply();
    }
    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(getResources().getString(R.string.registration_complete));
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

From source file:org.diorite.impl.entity.attrib.SimpleAttributeModifier.java

/**
 * Deserialize BasicAttributeModifier from {@link NbtTagCompound}.
 *
 * @param tag data to deserialize.//from  ww w . ja  va  2 s .  c  o m
 */
public SimpleAttributeModifier(final NbtTagCompound tag) {
    this.uuid = new UUID(tag.getLong("UUIDMost"), tag.getLong("UUIDLeast"));
    this.name = tag.getString("Name", (String) null);
    this.value = tag.getDouble("Amount");
    this.operation = ModifierOperation.getByEnumOrdinal(tag.getInt("Operation"));
    this.slot = ModifierSlot.getByTypeName(tag.getString("Slot", ""));
    this.type = tag.containsTag("AttributeName") ? AttributeType.getByKey(tag.getString("AttributeName"))
            : null;
}

From source file:net.servicestack.client.Utils.java

public static UUID fromGuidBytes(byte[] guidBytes) {
    ByteBuffer buf = ByteBuffer.wrap(guidBytes);

    byte[] first4 = new byte[4];
    buf.get(first4);//from w w w  .  j a va2  s. c o m
    reverse(first4);

    byte[] second2 = new byte[2];
    buf.get(second2);
    reverse(second2);

    byte[] third2 = new byte[2];
    buf.get(third2);
    reverse(third2);

    long lsb = buf.getLong();

    buf = ByteBuffer.wrap(new byte[8]).put(first4).put(second2).put(third2);

    buf.rewind();
    long msb = buf.getLong();

    return new UUID(msb, lsb);
}

From source file:com.strategicgains.docussandra.controller.QueryControllerTest.java

@Before
public void beforeTest() throws Exception {
    f.clearTestTables();//from  w w w  .  j a v a2s  .  co m
    Database testDb = Fixtures.createTestDatabase();
    f.insertDatabase(testDb);
    Table testTable = Fixtures.createTestTable();
    f.insertTable(testTable);
    f.insertIndex(Fixtures.createTestIndexOneField());
    f.insertIndex(Fixtures.createTestIndexTwoField());
    f.insertIndex(Fixtures.createTestIndexWithBulkDataHit());
    f.insertDocument(Fixtures.createTestDocument());
    Document onePrime = Fixtures.createTestDocument();
    onePrime.setUuid(new UUID(onePrime.getUuid().getMostSignificantBits() + 2, 1L));
    f.insertDocument(onePrime);
    f.insertDocument(Fixtures.createTestDocument2());
    Document twoPrime = Fixtures.createTestDocument2();
    twoPrime.setUuid(new UUID(twoPrime.getUuid().getMostSignificantBits() + 3, 2L));
    f.insertDocument(twoPrime);
    f.insertDocuments(Fixtures.getBulkDocuments());
    RestAssured.basePath = "/" + testDb.name() + "/" + testTable.name() + "/queries";
}

From source file:org.spoutcraft.client.packet.PacketEntityInformation.java

public void run(int playerId) {
    if (Minecraft.theMinecraft.theWorld instanceof WorldClient) {
        ByteBuffer rawData = ByteBuffer.allocate(data.length);
        rawData.put(data);//from   w  ww  .  j a v a 2s  . c om
        for (int i = 0; i < data.length / 20; i++) {
            int index = i * 20;
            long lsb = rawData.getLong(index);
            long msb = rawData.getLong(index + 8);
            int id = rawData.getInt(index + 16);

            net.minecraft.src.Entity e = SpoutClient.getInstance().getEntityFromId(id);
            if (e != null) {
                e.uniqueId = new UUID(msb, lsb);
            }
        }
    }
}