0
UUID
Tomoki Yamashita
2014.4.9 potatotips #6
Self-Introduction
• @tomorrowkey / Tomoki Yamashita
• Android Developer at COOKPAD
• http://blog.tomorrowkey.jp / 明日の
Agenda
• What is UUID?
• How to use it in Java
• Versions of UUID
• Which version can we use in Java
• To use version 1 in...
What is UUID
What is UUID?
• Universally Unique Identifier
• RFC 4122
• Generate Unique ID without servers.
How to use in
Java
How to use it in Java
import java.util.UUID;



public class Main {

public static void main(String... args) {

UUID uuid ...
Versions of UUID
Versions of UUID
• There are 5 versions of UUID.
Version 1
• Original version
• Use time(nano-seconds) and Mac
Address
• It won't duplicate because depends on
mac address.
Version 2
• Version for DCE(Distributed
Computing Environment) Security
Version 3
• Name and MD5 Hash
• If use the same name, it duplicate.
Version 4
• Random value
• It may not duplicate.
Version 5
• Name and SHA1 Hash
• If use the same name, it duplicate.
Which version can
we use in Java?
Which version can we
use in Java?
• Version 3

UUID.nameUUIDFromBytes(byte[] name)
• Version 4

UUID.randomUUID();
To use version1
in Java
To use version1
in Java
stephenc/eaio-uuid 

https://github.com/stephenc/eaio-uuid
To use version1
in Java
build.gradle

compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0'	
Main.java

com.eaio.uuid.UUID uu...
To use version1
in Android
To use version1
in Android
build.gradle

compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0'	
Main.java

com.eaio.uuid.UUID...
To use version1
in Android
build.gradle

compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0'	
Main.java

com.eaio.uuid.UUID...
Why...?
The library use a api which is not
supported in Android.
omg.CORBA.portable.IDLEntity
To use version1
in Android
• clone eaio-uuid
• remove CORBA api from source code.
• add a permission INTERNET
End
Understand principle about UUID and
then use it.
Thank you for listening
Referred links
RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace 

http://tools.ietf.org/html/rfc4122
Univers...
Upcoming SlideShare
Loading in...5
×

UUID

534

Published on

How to use UUID in Java and Android.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
534
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "UUID"

  1. 1. UUID Tomoki Yamashita 2014.4.9 potatotips #6
  2. 2. Self-Introduction • @tomorrowkey / Tomoki Yamashita • Android Developer at COOKPAD • http://blog.tomorrowkey.jp / 明日の
  3. 3. Agenda • What is UUID? • How to use it in Java • Versions of UUID • Which version can we use in Java • To use version 1 in Java • To use version 1 in Android
  4. 4. What is UUID
  5. 5. What is UUID? • Universally Unique Identifier • RFC 4122 • Generate Unique ID without servers.
  6. 6. How to use in Java
  7. 7. How to use it in Java import java.util.UUID;
 
 public class Main {
 public static void main(String... args) {
 UUID uuid = UUID.randomUUID();
 System.out.println(“uuid=” + uuid.toString());
 }
 } # 53da3b97-075f-4bcd-af62-148b1a7d6712
  8. 8. Versions of UUID
  9. 9. Versions of UUID • There are 5 versions of UUID.
  10. 10. Version 1 • Original version • Use time(nano-seconds) and Mac Address • It won't duplicate because depends on mac address.
  11. 11. Version 2 • Version for DCE(Distributed Computing Environment) Security
  12. 12. Version 3 • Name and MD5 Hash • If use the same name, it duplicate.
  13. 13. Version 4 • Random value • It may not duplicate.
  14. 14. Version 5 • Name and SHA1 Hash • If use the same name, it duplicate.
  15. 15. Which version can we use in Java?
  16. 16. Which version can we use in Java? • Version 3
 UUID.nameUUIDFromBytes(byte[] name) • Version 4
 UUID.randomUUID();
  17. 17. To use version1 in Java
  18. 18. To use version1 in Java stephenc/eaio-uuid 
 https://github.com/stephenc/eaio-uuid
  19. 19. To use version1 in Java build.gradle
 compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0' Main.java
 com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
 System.out.println(“uuid=” + uuid.toString());
  20. 20. To use version1 in Android
  21. 21. To use version1 in Android build.gradle
 compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0' Main.java
 com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
 System.out.println(“uuid=” + uuid.toString());
  22. 22. To use version1 in Android build.gradle
 compile ‘com.github.stephenc.eaio-uuid:uuid:3.4.0' Main.java
 com.eaio.uuid.UUID uuid = new com.eaio.uuid.UUID();
 System.out.println(“uuid=” + uuid.toString()); NoClassDefFoundError: com.eaio.uuid.UUID
  23. 23. Why...? The library use a api which is not supported in Android. omg.CORBA.portable.IDLEntity
  24. 24. To use version1 in Android • clone eaio-uuid • remove CORBA api from source code. • add a permission INTERNET
  25. 25. End Understand principle about UUID and then use it. Thank you for listening
  26. 26. Referred links RFC 4122 - A Universally Unique IDentifier (UUID) URN Namespace 
 http://tools.ietf.org/html/rfc4122 Universally unique identifier - Wikipedia, the free encyclopedia 
 http://en.wikipedia.org/wiki/UUID#Variants_and_versions UUIDはなぜ、分散環境で好き勝手に生成しても衝突しないのか。RFC4122規格とUUIDの性質。 ¦ 三 度の飯とエレクトロン 
 http://blog.katty.in/5124
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×