treilly     2004/06/14 05:49:15

  Modified:    id/src/java/org/apache/commons/id/uuid
                        VersionFourGenerator.java
  Log:
  Fixes bugs in version and variant assignment
  
  Revision  Changes    Path
  1.7       +4 -8      
jakarta-commons-sandbox/id/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java
  
  Index: VersionFourGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/id/src/java/org/apache/commons/id/uuid/VersionFourGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- VersionFourGenerator.java 31 May 2004 07:05:50 -0000      1.6
  +++ VersionFourGenerator.java 14 Jun 2004 12:49:15 -0000      1.7
  @@ -40,12 +40,6 @@
    */
   public final class VersionFourGenerator implements IdentifierGenerator, Constants {
   
  -    /** Byte position of the clock sequence and reserved field */
  -    private static final short TIME_HI_AND_VERSION_BYTE_6 = 6;
  -
  -    /** Byte position of the clock sequence and reserved field */
  -    private static final short CLOCK_SEQ_HI_AND_RESERVED_BYTE_8 = 8;
  -
           /** Random used to generate UUID's */
           private static final Random regularRandom = new Random();
   
  @@ -130,9 +124,11 @@
                   regularRandom.nextBytes(raw);
               }
   
  -            raw[CLOCK_SEQ_HI_AND_RESERVED_BYTE_8] &= UUID.VARIANT_IETF_DRAFT;
               raw[TIME_HI_AND_VERSION_BYTE_6] &= 0x0F;
               raw[TIME_HI_AND_VERSION_BYTE_6] |= (UUID.VERSION_FOUR << 4);
  +
  +            raw[CLOCK_SEQ_HI_AND_RESERVED_BYTE_8] &= 0x3F; //0011 1111
  +            raw[CLOCK_SEQ_HI_AND_RESERVED_BYTE_8] |= 0x80; //1000 0000
   
               return new UUID(raw);
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to