< prev index next >

src/java.base/share/classes/java/util/UUID.java

Print this page




 375      * {@code
 376      * UUID                   = <time_low> "-" <time_mid> "-"
 377      *                          <time_high_and_version> "-"
 378      *                          <variant_and_sequence> "-"
 379      *                          <node>
 380      * time_low               = 4*<hexOctet>
 381      * time_mid               = 2*<hexOctet>
 382      * time_high_and_version  = 2*<hexOctet>
 383      * variant_and_sequence   = 2*<hexOctet>
 384      * node                   = 6*<hexOctet>
 385      * hexOctet               = <hexDigit><hexDigit>
 386      * hexDigit               =
 387      *       "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
 388      *       | "a" | "b" | "c" | "d" | "e" | "f"
 389      *       | "A" | "B" | "C" | "D" | "E" | "F"
 390      * }</pre></blockquote>
 391      *
 392      * @return  A string representation of this {@code UUID}
 393      */
 394     public String toString() {
 395         char[] chars = new char[36];
 396         jla.formatUnsignedLong(mostSigBits >> 32, 4, chars, 0, 8);
 397         chars[8] = '-';
 398         jla.formatUnsignedLong(mostSigBits >> 16, 4, chars, 9, 4);
 399         chars[13] = '-';
 400         jla.formatUnsignedLong(mostSigBits, 4, chars, 14, 4);
 401         chars[18] = '-';
 402         jla.formatUnsignedLong(leastSigBits >> 48, 4, chars, 19, 4);
 403         chars[23] = '-';
 404         jla.formatUnsignedLong(leastSigBits, 4, chars, 24, 12);
 405         return jla.newStringUnsafe(chars);
 406     }
 407 
 408     /**
 409      * Returns a hash code for this {@code UUID}.
 410      *
 411      * @return  A hash code value for this {@code UUID}
 412      */
 413     public int hashCode() {
 414         long hilo = mostSigBits ^ leastSigBits;
 415         return ((int)(hilo >> 32)) ^ (int) hilo;
 416     }
 417 
 418     /**
 419      * Compares this object to the specified object.  The result is {@code
 420      * true} if and only if the argument is not {@code null}, is a {@code UUID}
 421      * object, has the same variant, and contains the same value, bit for bit,
 422      * as this {@code UUID}.
 423      *
 424      * @param  obj
 425      *         The object to be compared




 375      * {@code
 376      * UUID                   = <time_low> "-" <time_mid> "-"
 377      *                          <time_high_and_version> "-"
 378      *                          <variant_and_sequence> "-"
 379      *                          <node>
 380      * time_low               = 4*<hexOctet>
 381      * time_mid               = 2*<hexOctet>
 382      * time_high_and_version  = 2*<hexOctet>
 383      * variant_and_sequence   = 2*<hexOctet>
 384      * node                   = 6*<hexOctet>
 385      * hexOctet               = <hexDigit><hexDigit>
 386      * hexDigit               =
 387      *       "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
 388      *       | "a" | "b" | "c" | "d" | "e" | "f"
 389      *       | "A" | "B" | "C" | "D" | "E" | "F"
 390      * }</pre></blockquote>
 391      *
 392      * @return  A string representation of this {@code UUID}
 393      */
 394     public String toString() {
 395         return jla.fastUUID(leastSigBits, mostSigBits);










 396     }
 397 
 398     /**
 399      * Returns a hash code for this {@code UUID}.
 400      *
 401      * @return  A hash code value for this {@code UUID}
 402      */
 403     public int hashCode() {
 404         long hilo = mostSigBits ^ leastSigBits;
 405         return ((int)(hilo >> 32)) ^ (int) hilo;
 406     }
 407 
 408     /**
 409      * Compares this object to the specified object.  The result is {@code
 410      * true} if and only if the argument is not {@code null}, is a {@code UUID}
 411      * object, has the same variant, and contains the same value, bit for bit,
 412      * as this {@code UUID}.
 413      *
 414      * @param  obj
 415      *         The object to be compared


< prev index next >