Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Wikipedia offers two versions of Base64 that are usable in XML namespaces.</p> <p><a href="http://en.wikipedia.org/wiki/Base64#XML" rel="nofollow">http://en.wikipedia.org/wiki/Base64#XML</a>. I wrote the following JAVA that follows to do URLSafe, UUIDs in Java, (call theObjectReturned.toString() to get it as a guid string).</p> <p>I've seen other code for Java that is supposed to be very fast and could be easily modified to do the XML safe variants:</p> <p><a href="http://iharder.sourceforge.net/current/java/base64/" rel="nofollow">http://iharder.sourceforge.net/current/java/base64/</a></p> <p>code follows. Save in a file called UUIDUtil.java</p> <pre><code>public class UUIDUtil{ public static UUID combUUID(){ private UUID srcUUID = UUID.randomUUID();; private java.sql.Timestamp ts = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); long upper16OfLowerUUID = this.zeroLower48BitsOfLong( srcUUID.getLeastSignificantBits() ); long lower48Time = UUIDUtil.zeroUpper16BitsOfLong( ts ); long lowerLongForNewUUID = upper16OfLowerUUID | lower48Time; return new UUID( srcUUID.getMostSignificantBits(), lowerLongForNewUUID ); } public static base64URLSafeOfUUIDObject( UUID uuid ){ byte[] bytes = ByteBuffer.allocate(16).putLong(0, uuid.getLeastSignificantBits()).putLong(8, uuid.getMostSignificantBits()).array(); return Base64.encodeBase64URLSafeString( bytes ); } public static base64URLSafeOfUUIDString( String uuidString ){ UUID uuid = UUID.fromString( uuidString ); return UUIDUtil.base64URLSafeOfUUIDObject( uuid ); } private static long zeroLower48BitsOfLong( long longVar ){ long upper16BitMask = -281474976710656L; return longVar &amp; upper16BitMask; } private static void zeroUpper16BitsOfLong( long longVar ){ long lower48BitMask = 281474976710656L-1L; return longVar &amp; lower48BitMask; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload