Android Open Source - Curio_android_SDK U U I D Generator






From Project

Back to project page Curio_android_SDK.

License

The source code is released under:

Apache License

If you think the Android project Curio_android_SDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2014 Turkcell//from  w ww .  j  av  a  2s  .  c  om
 * 
 * Created by Can Ciloglu on 14 Tem 2014
 *
 */
package com.turkcell.curio.utils;

import java.util.UUID;

/**
 * UUID Generator class. Particularly used for generating time-based UUID.
 * 
 * @author Can Ciloglu
 *
 */
public class UUIDGenerator
{
  /**
   * Offset for converting Epoch time to 15 October 1582 00:00:000000000
   */
  private static final long TIME_OFFSET = 122192928000000000l;
  private static final long MS_NANO = 10000l;
  
    /**
     * Creates a type 1 UUID (time-based UUID) with the timestamp of @param rawTimestamp, in milliseconds.
     *
     * @return a UUID instance
     */
    public static UUID generateTimeBasedUUID(long rawTimestamp)
    {
      long modifiedTimeStamp = (rawTimestamp * MS_NANO) + TIME_OFFSET;
      
        // Time field components are hi, low, mid
        int clockHi = (int) (modifiedTimeStamp >>> 32);
        int clockLo = (int) modifiedTimeStamp;
        int midhi = (clockHi << 16) | (clockHi >>> 16);
        
        // need to squeeze in type (4 MSBs in byte 6, clock hi)
        midhi &= ~0xF000; // remove high nibble of 6th byte
        midhi |= 0x1000; // type 1
        long midhiL = (long) midhi;
        midhiL = ((midhiL << 32) >>> 32); // to get rid of sign extension
        // and reconstruct
        long mostSignificantBits = (((long) clockLo) << 32) | midhiL;
        
        return new UUID(mostSignificantBits, UUID.randomUUID().getLeastSignificantBits());
    }
}




Java Source Code List

com.turkcell.curio.CurioClient.java
com.turkcell.curio.CurioRequestProcessor.java
com.turkcell.curio.DBRequestProcessor.java
com.turkcell.curio.ICurioResultListener.java
com.turkcell.curio.INetworkConnectivityChangeListener.java
com.turkcell.curio.model.OfflineRequest.java
com.turkcell.curio.model.OnlineRequest.java
com.turkcell.curio.model.Screen.java
com.turkcell.curio.utils.Constants.java
com.turkcell.curio.utils.CurioClientSettings.java
com.turkcell.curio.utils.CurioDBContract.java
com.turkcell.curio.utils.CurioDBHelper.java
com.turkcell.curio.utils.CurioLogger.java
com.turkcell.curio.utils.CurioUtil.java
com.turkcell.curio.utils.NetworkUtil.java
com.turkcell.curio.utils.ParameterLoader.java
com.turkcell.curio.utils.PushUtil.java
com.turkcell.curio.utils.UUIDGenerator.java
com.turkcell.curio.utils.VisitorCodeManager.java
com.turkcell.curiosample.BlankActivity.java
com.turkcell.curiosample.MainActivity.java
com.turkcell.curiosample.PushNotificationBroadcastReceiver.java
com.turkcell.curiosample.PushNotificationIntentService.java