UUID.st
author Stefan Vogel <sv@exept.de>
Mon, 15 Jun 2009 14:43:41 +0200
changeset 2170 8cd3d9480ab7
parent 2132 c580316610e1
child 2426 5348d3922323
permissions -rw-r--r--
new: #asUUID
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2002 by eXept Software AG
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ByteArray variableByteSubclass:#UUID
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    16
	classVariableNames:'CachedMACAddress Lock SequenceNumber LastTime Increment
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    17
		NameSpaceDNS NameSpaceDN NameSpaceURL NameSpaceOID'
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
1304
1c58aa764724 category
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
    19
	category:'Net-Communication-Support'
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!UUID class methodsFor:'documentation'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 2002 by eXept Software AG
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
              All Rights Reserved
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 This software is furnished under a license and may be used
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 hereby transferred.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    36
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    37
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    38
documentation
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    39
"
1544
6c339f276b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
    40
    128-bit Universal Unique Ids (UUIDs) as defined by OpenGroup/DCE
6c339f276b91 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1543
diff changeset
    41
        http://www.opengroup.org/onlinepubs/9629399/apdxa.htm.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    42
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    43
    See also RFC4122.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    44
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    45
    A UUID is unique in time and space (at least until about Year 3400).
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    46
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    47
    Several fields if the UUID are interpreted as integers, so host/network byte
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    48
    order is relevant. UUIDs are stored in a ByteArray in network byte order (MSB-first),
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    49
    so they may be exported/imported between different machines.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    50
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    51
    You can import UUIDs in host byte order using #fromNativeBytes:
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
    52
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    53
    [author:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    54
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    55
    [instance variables:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    56
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    57
    [class variables:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    58
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    59
    [see also:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    60
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    61
"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    62
! !
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    63
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    64
!UUID class methodsFor:'initialization'!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    65
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    66
initialize
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    67
    "I want to get informed about image restarts"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    68
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    69
    Lock isNil ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    70
        Lock := RecursionLock new name:'UUID'.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    71
        LastTime := 0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    72
        Increment := 0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    73
        ObjectMemory addDependent:self.
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    74
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    75
        NameSpaceDNS := self fromBytes:#[16r6B 16rA7 16rB8 16r10 16r9D 16rAD 16r11 16rD1 16r80 16rB4 16r0 16rC0 16r4F 16rD4 16r30 16rC8].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    76
        NameSpaceURL := self fromBytes:#[16r6B 16rA7 16rB8 16r11 16r9D 16rAD 16r11 16rD1 16r80 16rB4 16r0 16rC0 16r4F 16rD4 16r30 16rC8].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    77
        NameSpaceOID := self fromBytes:#[16r6B 16rA7 16rB8 16r12 16r9D 16rAD 16r11 16rD1 16r80 16rB4 16r0 16rC0 16r4F 16rD4 16r30 16rC8].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
    78
        NameSpaceDN  := self fromBytes:#[16r6B 16rA7 16rB8 16r14 16r9D 16rAD 16r11 16rD1 16r80 16rB4 16r0 16rC0 16r4F 16rD4 16r30 16rC8].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    79
    ]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    80
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    81
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    82
update:something with:aParameter from:changedObject
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    83
    "flush cached MAC address (may have been restarted on another host)"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    84
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    85
    (something == #restarted) ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    86
        CachedMACAddress := nil.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    87
        SequenceNumber := nil.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    88
    ]
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
!UUID class methodsFor:'instance creation'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    93
basicNew
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    94
    ^ super basicNew:16
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    95
!
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    96
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    97
basicNew:size
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    98
    "allow creating with exact size. We need this for XMLStandardDecoder"
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
    99
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   100
    size ~~ 16 ifTrue:[
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   101
        ^ self shouldNotImplement.
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   102
    ].
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   103
    ^ super basicNew:size.
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   104
!
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   105
2017
d08521448dc0 decodeFromLiterlArray
fm
parents: 1923
diff changeset
   106
decodeFromLiteralArray:anArray
2018
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   107
    anArray size == 2 ifTrue:[
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   108
        "/ UUID 'uuid-string'
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   109
        ^ self readFrom:(anArray at:2).
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   110
    ].
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   111
    "/ UUID bytes...
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   112
    ^ super decodeFromLiteralArray:anArray "/ self readFrom:(anArray at:2)
2017
d08521448dc0 decodeFromLiterlArray
fm
parents: 1923
diff changeset
   113
d08521448dc0 decodeFromLiterlArray
fm
parents: 1923
diff changeset
   114
    "
2018
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   115
     (UUID decodeFromLiteralArray:#(UUID '5b023ce0-41f1-11dd-b99f-001558137da0'))
316b0a396e86 decodeFromLiterlArray
fm
parents: 2017
diff changeset
   116
       literalArrayEncoding   
2017
d08521448dc0 decodeFromLiterlArray
fm
parents: 1923
diff changeset
   117
    "
d08521448dc0 decodeFromLiterlArray
fm
parents: 1923
diff changeset
   118
!
d08521448dc0 decodeFromLiterlArray
fm
parents: 1923
diff changeset
   119
1382
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   120
fromBytes:aByteArray
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   121
    "set uuid from aByteArray.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   122
     aByteArray must be 16 bytes in network byte order (MSB-first)"
1382
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   123
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   124
    |uuid|
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   126
    uuid := super basicNew:16.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    uuid replaceFrom:1 to:16 with:aByteArray.
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   128
    ^ uuid.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   130
    "    
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   131
     UUID fromBytes:#[16r01 16r02 16r03 16r04
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   132
                      16r05 16r06 16r07 16r08
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   133
                      16r09 16r10 16r11 16r12
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   134
                      16r13 16r14 16r15 16r16]. 
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   135
    "
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   136
!
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   138
fromBytes:aByteArray msb:msb
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   139
    "Set the UUID from aByteArray. UUIDS are stored internally as MSB-first. 
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   140
     So, alway set
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   141
        msb = true      if reading from network or persistent storage"
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   143
    |uuid|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   144
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   145
    uuid := self fromBytes:aByteArray.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   146
    msb ifFalse:[
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   147
        self adjustByteOrder:uuid.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    ^ uuid
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     UUID fromBytes:#[16r01 16r02 16r03 16r04
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
                      16r05 16r06 16r07 16r08
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
                      16r09 16r10 16r11 16r12
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
                      16r13 16r14 16r15 16r16] msb:false. 
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
     UUID fromBytes:#[16r01 16r02 16r03 16r04
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                      16r05 16r06 16r07 16r08
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                      16r09 16r10 16r11 16r12
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                      16r13 16r14 16r15 16r16] msb:true.    
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   166
fromNativeBytes:aByteArray
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   167
    "convert bytes to uuid.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   168
     aByteArray represents a UUID in host byte order 
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   169
     - e.g. an UUID fetched from the Windows OS"
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   170
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   171
    |uuid|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   172
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   173
    uuid := self fromBytes:aByteArray.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   174
    self isBigEndian ifFalse:[
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   175
        self adjustByteOrder:uuid.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   176
    ].
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   177
    ^ uuid.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   178
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   179
    "    
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   180
     UUID fromNativeBytes:#[16r01 16r02 16r03 16r04
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   181
                              16r05 16r06 16r07 16r08
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   182
                              16r09 16r10 16r11 16r12
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   183
                              16r13 16r14 16r15 16r16]. 
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   184
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   185
    "
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   186
!
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   187
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   188
genRandomUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   189
    "generate a new random UUID"
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   190
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   191
    ^ (super basicNew:16) genRandomUUID
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   192
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   193
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   194
      self genRandomUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   195
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   196
!
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   197
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   198
genUUID
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   199
    "generate a uuid.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   200
     If a physical mac address can be retrieved from the OS,
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   201
     a mac-address/timestamp uuid is generated,
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   202
     otherwise a random uuid will be generated."
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   204
    ^ (super basicNew:16) genUUID
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   205
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   206
    "
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   207
     self genUUID
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   208
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
new
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   212
    ^ (super basicNew:16) genUUID
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   213
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   214
    "
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   215
     self new 
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   216
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
new:size
1320
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   220
    "allow creating with exact size. We need this for XMLStandardDecoder"
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   221
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   222
    size ~~ 16 ifTrue:[
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   223
        ^ self shouldNotImplement.
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   224
    ].
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   225
    ^ super new:size.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   226
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   227
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   228
readFrom:aStringOrStream onError:errorBlock
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   229
    |d offs s uuid t byte|
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   230
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   231
    Error handle:[:ex |
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   232
        ^ errorBlock value.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   233
    ] do:[
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   234
        s := aStringOrStream readStream.
1923
6380ea5d7385 #new is now the same as genUUID (squeak compatibility)
Claus Gittinger <cg@exept.de>
parents: 1898
diff changeset
   235
        uuid := super basicNew:16.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   236
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   237
        s skipSeparators.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   238
        s peek == ${ ifTrue:[s next].
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   239
        s skipSeparators.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   240
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   241
        t := s next:8.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   242
        d := Integer readFrom:t radix:16 onError:[^ errorBlock value].
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   243
        uuid unsignedLongAt:1 put:d bigEndian:true.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   244
        offs := 5.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   245
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   246
        s next.         "skip $-"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   247
1601
b0dfbe332caf WARNING: byte order of internal byte-representation changed;
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   248
        1 to:2 do:[:i |
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   249
            t := s next:4.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   250
            d := Integer readFrom:t radix:16 onError:[^ errorBlock value].
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   251
            uuid unsignedShortAt:offs put:d bigEndian:true.
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   252
            offs := offs + 2.
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   253
            s next.     "skip $-"
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   254
        ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   255
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   256
        1 to:2 do:[:i |
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   257
            t := s next:2.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   258
            d := Integer readFrom:t radix:16 onError:[^ errorBlock value].
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   259
            uuid at:offs put:d.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   260
            offs := offs + 1.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   261
        ].
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   262
        s next.         "skip $-"
1601
b0dfbe332caf WARNING: byte order of internal byte-representation changed;
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   263
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   264
        1 to:6 do:[:i |
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   265
            t := s next:2.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   266
            byte := Integer readFrom:t radix:16 onError:[^ errorBlock value].
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   267
            uuid at:offs put:byte.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   268
            offs := offs + 1.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   269
        ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   270
    ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   271
    ^ uuid
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   272
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   273
    "
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   274
     UUID readFrom:'5ab2e9b4-3d48-11d2-9ea4-80c5140aaa77' 
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   275
     UUID fromString:'5ab2e9b4-3d48-11d2-9ea4-80c5140aaa77' 
1601
b0dfbe332caf WARNING: byte order of internal byte-representation changed;
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   276
     UUID fromString:'00000001-0000-0000-C000-000000000046'
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   277
     UUID fromString:'00000001-0000-0000-C000-000000004600'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   278
     UUID fromString:'00000001-0000-0000-C000-000000460000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   279
     UUID fromString:'00000001-0000-0000-C000-000046000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   280
     UUID fromString:'00000001-0000-0000-C000-004600000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   281
     UUID fromString:'00000001-0000-0000-C000-460000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   282
     UUID fromString:'00000001-0000-0000-C046-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   283
     UUID fromString:'00000001-0000-0046-C000-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   284
     UUID fromString:'00000001-0000-4600-C000-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   285
     UUID fromString:'00000001-0046-0000-C000-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   286
     UUID fromString:'00000001-4600-0000-C000-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   287
     UUID fromString:'00000100-4600-0000-C000-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   288
     UUID fromString:'00010000-4600-0000-C000-000000000000'
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   289
     UUID fromString:'10000000-4600-0000-C000-000000000000'
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   290
    "
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   291
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   292
    "Modified: / 10-10-2007 / 23:03:47 / cg"
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   295
!UUID class methodsFor:'helpers'!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   296
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   297
adjustByteOrder:aByteArray
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   298
    "change the byte order of the uuid"
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   299
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   300
    |d|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   301
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   302
    d := aByteArray unsignedLongAt:1 bigEndian:false.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   303
    aByteArray unsignedLongAt:1 put:d bigEndian:true.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   304
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   305
    d := aByteArray unsignedShortAt:1+4 bigEndian:false.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   306
    aByteArray unsignedShortAt:1+4 put:d bigEndian:true.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   307
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   308
    d := aByteArray unsignedShortAt:1+4+2 bigEndian:false.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   309
    aByteArray unsignedShortAt:1+4+2 put:d bigEndian:true.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   310
!
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   311
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   312
getDtssUtcTime
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   313
    "return the DTSS based time in 100 nsec intervals
1647
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   314
     DTSS UTC base time is October 15, 1582 (the start of the Gregorian Calendar)."
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   315
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   316
     "Unix base time is January 1, 1970.
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   317
      The difference between both is: 122192928000000000"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   318
1647
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   319
"   
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   320
        (Timestamp epoch asDate subtractDate:(Date day:15 month:10 year:1582))
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   321
        *  (24 * 60 * 60)
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   322
"
1613
feef745939ea Use UTC time
Stefan Vogel <sv@exept.de>
parents: 1612
diff changeset
   323
1647
124e977b6a8f comment
Stefan Vogel <sv@exept.de>
parents: 1613
diff changeset
   324
    ^ (Timestamp now getMilliseconds + 12219292800000) * 10000.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   325
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   326
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   327
getValidMACAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   328
    "return the first valid MAC address (i.e. having at least one byte ~~ 0)"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   329
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   330
    CachedMACAddress isNil ifTrue:[
1491
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   331
        |dictOfIf ipAddr|
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   332
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   333
        CachedMACAddress := false.      "cache the fact, that there is no MAC address" 
1577
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   334
        [
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   335
            dictOfIf := OperatingSystem getNetworkMACAddresses.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   336
1577
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   337
            dictOfIf do:[:macAddress |
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   338
                (macAddress contains:[:byte | byte ~~ 0]) ifTrue:[
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   339
                    ^ CachedMACAddress := macAddress
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   340
                ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   341
            ].
1577
c0db2891f228 Ignore primitive failures when doing #getNetworkMACAddresses
Stefan Vogel <sv@exept.de>
parents: 1544
diff changeset
   342
        ] on:PrimitiveFailure do:[:ex| "ignore"].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   343
    ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   344
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   345
    ^ CachedMACAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   346
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   347
    "
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   348
       CachedMACAddress := nil.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   349
       self getValidMACAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   350
    "
1491
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   351
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   352
    "Modified: / 17-11-2004 / 01:45:53 / cg"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   353
! !
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   354
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   355
!UUID methodsFor:'accessing'!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   356
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   357
clockSeqHiAndReserved
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   358
    ^ self at:9
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   359
!
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   360
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   361
clockSeqLow
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   362
    ^ self at:10
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   363
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   364
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   365
node
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   366
    ^ self copyFrom:11 to:16
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   367
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   368
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   369
timeHighAndVersion
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   370
    ^ self unsignedShortAt:7 bigEndian:true
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   371
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   372
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   373
timeLow
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   374
    ^ self unsignedLongAt:1 bigEndian:true
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   375
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   376
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   377
timeMid
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   378
    ^ self unsignedShortAt:5 bigEndian:true
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   379
! !
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   380
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
!UUID methodsFor:'converting'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
1382
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   383
asBytes
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   384
    "convert this UUID to a ByteArray in network byte order (MSB-first)"
1382
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   385
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   386
    |bytes|
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
    bytes := ByteArray new:16.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
    bytes replaceFrom:1 to:16 with:self.
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   390
    ^ bytes
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   392
    "
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   393
     |bytes|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   394
        
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   395
     bytes := #[16r01 16r02 16r03 16r04
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   396
                      16r05 16r06 16r07 16r08
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   397
                      16r09 16r10 16r11 16r12
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   398
                      16r13 16r14 16r15 16r16].
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   399
     (UUID fromBytes:bytes) asBytes ~= bytes ifTrue:[self halt] 
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   400
    "
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   401
!
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   403
asBytesMSB:msb
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   404
    "convert this UUID to a ByteArray.
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   405
     If msb == false, it is converted into LSB-first byte ordering"
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   406
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   407
    |bytes|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   408
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   409
    bytes := self asBytes.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   410
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   411
    msb ifFalse:[
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   412
        self class adjustByteOrder:bytes.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
    ^ bytes
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   415
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   416
    "Modified: / 10-10-2007 / 22:51:09 / cg"
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   417
!
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   418
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   419
asNativeBytes
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   420
    "convert this uuid to a ByteArray in host byte order.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   421
     Use this only to pass the UUID to the OS (Windows)"
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   422
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   423
    |bytes|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   424
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   425
    bytes := self asBytes.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   426
    self class isBigEndian ifFalse:[
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   427
        self class adjustByteOrder:bytes.
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   428
    ].
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   429
    ^ bytes.
2021
21f1faba832a literalArray
fm
parents: 2018
diff changeset
   430
!
21f1faba832a literalArray
fm
parents: 2018
diff changeset
   431
2170
8cd3d9480ab7 new: #asUUID
Stefan Vogel <sv@exept.de>
parents: 2132
diff changeset
   432
asUUID
8cd3d9480ab7 new: #asUUID
Stefan Vogel <sv@exept.de>
parents: 2132
diff changeset
   433
    ^ self
8cd3d9480ab7 new: #asUUID
Stefan Vogel <sv@exept.de>
parents: 2132
diff changeset
   434
!
8cd3d9480ab7 new: #asUUID
Stefan Vogel <sv@exept.de>
parents: 2132
diff changeset
   435
2021
21f1faba832a literalArray
fm
parents: 2018
diff changeset
   436
literalArrayEncoding
21f1faba832a literalArray
fm
parents: 2018
diff changeset
   437
    ^ Array 
21f1faba832a literalArray
fm
parents: 2018
diff changeset
   438
        with:(self class name)
21f1faba832a literalArray
fm
parents: 2018
diff changeset
   439
        with:(self printString).
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
2132
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   442
!UUID methodsFor:'copying'!
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   443
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   444
deepCopy
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   445
    ^ self
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   446
!
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   447
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   448
deepCopyUsing:aDictionary postCopySelector:postCopySelector
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   449
    ^ self
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   450
!
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   451
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   452
shallowCopy
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   453
    ^ self
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   454
!
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   455
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   456
simpleDeepCopy
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   457
    ^ self
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   458
! !
c580316610e1 copying - a UUID is unique...
ca
parents: 2069
diff changeset
   459
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
!UUID methodsFor:'generating uuids'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   462
genRandomUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   463
    "answer a randomly generated uuid as defined in RFC4122 section 4.4"
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   464
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   465
    self replaceFrom:1 to:16 with:(RandomGenerator new nextBytes:16).
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   466
    "multiplex the 4 bit version number (Version 4 -> Random UUID) in high bits of byte 7"
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   467
    self at:7 put:(((self at:7) bitAnd:16r0F) bitOr:16r40).
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   468
    self at:9 put:(((self at:9) bitAnd:16r3F) bitOr:16r80).
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   469
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   470
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   471
      self new genRandomUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   472
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   473
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   474
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   475
      1 to: 100 do:[ : el |
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   476
          Transcript show:el.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   477
          Transcript show:': '.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   478
          Transcript showCR:(UUID new genRandomUUID).
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   479
      ].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   480
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   481
!
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   482
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   483
genTimestampUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   484
    "generate a timestamp (and mac-address) based uuid"
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   485
1610
5f79965e186b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   486
    |macBytes utcTime seqNr|
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   488
    macBytes := self class getValidMACAddress.
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   489
    macBytes size ~~ 6 ifTrue:[
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   490
        self error:'no mac address - cannot generate UUID'.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   491
    ].
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   493
    "use 60 bit counter of 100ns ticks since 00:00:00 15.oct 1582 (sigh)"
1610
5f79965e186b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   494
    utcTime := self class getDtssUtcTime.
5f79965e186b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   495
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   496
    Lock critical:[
1467
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   497
        SequenceNumber isNil ifTrue:[
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   498
            SequenceNumber := RandomGenerator new nextIntegerBetween:0 and:16383.
1467
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   499
        ].
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   500
        utcTime > (LastTime+Increment) ifTrue:[
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   501
            Increment := 0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   502
        ] ifFalse:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   503
            LastTime = utcTime ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   504
                "clock didn't advance since last call. Simply add a tick"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   505
                Increment := Increment + 1.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   506
            ] ifFalse:[
1467
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   507
                "clock went backwards - increment SequenceNumber"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   508
                Increment := 0.
1214
7ae6b9302754 Fix previous change
Stefan Vogel <sv@exept.de>
parents: 1213
diff changeset
   509
                SequenceNumber := SequenceNumber + 1.
7ae6b9302754 Fix previous change
Stefan Vogel <sv@exept.de>
parents: 1213
diff changeset
   510
                SequenceNumber >= 16384 ifTrue:[SequenceNumber := 0].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   511
            ].
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
        ].
1214
7ae6b9302754 Fix previous change
Stefan Vogel <sv@exept.de>
parents: 1213
diff changeset
   513
        
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   514
        LastTime := utcTime.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   515
        utcTime := utcTime + Increment.
1610
5f79965e186b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1608
diff changeset
   516
        seqNr := SequenceNumber.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   519
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   520
    "time low: long"
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   521
    self unsignedLongAt:1 put:(utcTime bitAnd:16rFFFFFFFF) bigEndian:true.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   522
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   523
    "time med: short"
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   524
    utcTime := utcTime bitShift:-32.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   525
    self unsignedShortAt:5 put:(utcTime bitAnd:16rFFFF) bigEndian:true.
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   526
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   527
    "time high and version: short
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   528
     multiplex the 4 bit version number in highest 4 bits (version 1 -> time based version)"
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   529
    self unsignedShortAt:7 put:((utcTime bitShift:-16) bitOr:16r1000) bigEndian:true.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   531
    "2 sequence bytes + reserved bits (this is not a short!!)"
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   532
    self at:9  put:(((seqNr bitShift:-8) bitAnd:16r3F) bitOr:16r80).
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   533
    self at:10 put:(seqNr bitAnd:16rFF).
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   534
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   535
    "48 bits of MAC-Address"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   536
    self replaceFrom:11 to:16 with:macBytes startingAt:1.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    "
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   539
      self new genTimestampUUID
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   540
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   542
    "
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   543
      1 to: 100 do:[ : el |
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   544
          Transcript show:el.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   545
          Transcript show:': '.
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   546
          Transcript showCR:(UUID new genTimestampUUID).
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   547
      ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   548
    "
1608
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   549
!
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   550
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   551
genUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   552
    "generate a uuid - the existing uuid bytes are overwritten.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   553
     If a physical mac address can be retrieved from the OS,
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   554
     a mac-address/timestamp uuid is generated,
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   555
     otherwise a random uuid will be generated."
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   556
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   557
    CachedMACAddress isNil ifTrue:[
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   558
        self class getValidMACAddress.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   559
    ].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   560
    CachedMACAddress == false ifTrue:[
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   561
        "no mac address - generate random UUID"
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   562
        ^ self genRandomUUID.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   563
    ].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   564
    ^ self genTimestampUUID.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   565
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   566
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   567
      self genUUID
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   568
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   569
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   570
    "
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   571
      1 to: 100 do:[ : el |
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   572
          Transcript show:el.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   573
          Transcript show:': '.
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   574
          Transcript showCR:(UUID genUUID).
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   575
      ].
e1cf5d2b6f2f Add random UUID in case there is no mac address
Stefan Vogel <sv@exept.de>
parents: 1602
diff changeset
   576
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
!UUID methodsFor:'printing'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
displayString
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    ^ self printString
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
printOn:aStream
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   586
    |d tmpStream|
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   588
    tmpStream := '' writeStream.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   590
"/    d := self unsignedLongAt:1 bigEndian:true.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   591
"/    d printOn:tmpStream base:16 size:8 fill:$0.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   592
"/    tmpStream nextPut:$-.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   593
"/
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   594
"/    d := self unsignedShortAt:1+4 bigEndian:true.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   595
"/    d printOn:tmpStream base:16 size:4 fill:$0.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   596
"/    tmpStream nextPut:$-.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   597
"/
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   598
"/    d := self unsignedShortAt:1+4+2 bigEndian:true.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   599
"/    d printOn:tmpStream base:16 size:4 fill:$0.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   600
"/    tmpStream nextPut:$-.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   601
"/
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   602
"/    d := self at:1+4+2+2.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   603
"/    d printOn:tmpStream base:16 size:2 fill:$0.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   604
"/    d := self at:1+4+2+2+1.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   605
"/    d printOn:tmpStream base:16 size:2 fill:$0.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   606
"/    tmpStream nextPut:$-.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   607
"/
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   608
"/    11 to:16 do:[:idx|
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   609
"/        d := self at:idx.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   610
"/        d printOn:tmpStream base:16 size:2 fill:$0.
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   611
"/    ].
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   612
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   613
    1 to:4 do:[:idx|
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   614
        d := self at:idx.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   615
        d printOn:tmpStream base:16 size:2 fill:$0.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   616
    ].
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   617
    tmpStream nextPut:$-.
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   618
    5 to:6 do:[:idx|
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   619
        d := self at:idx.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   620
        d printOn:tmpStream base:16 size:2 fill:$0.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   621
    ].
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   622
    tmpStream nextPut:$-.
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   623
    7 to:8 do:[:idx|
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   624
        d := self at:idx.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   625
        d printOn:tmpStream base:16 size:2 fill:$0.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   626
    ].
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   627
    tmpStream nextPut:$-.
1612
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   628
    9 to:10 do:[:idx|
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   629
        d := self at:idx.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   630
        d printOn:tmpStream base:16 size:2 fill:$0.
2877abd0a002 Byte ordering issues
Stefan Vogel <sv@exept.de>
parents: 1611
diff changeset
   631
    ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   632
    tmpStream nextPut:$-.
1602
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   633
    11 to:16 do:[:idx|
6ffbb8db78a4 Fix byte ordering.
Stefan Vogel <sv@exept.de>
parents: 1601
diff changeset
   634
        d := self at:idx.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   635
        d printOn:tmpStream base:16 size:2 fill:$0.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   638
    aStream nextPutAll:(tmpStream contents asLowercase).
1898
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   639
8041791c02c3 comments
Claus Gittinger <cg@exept.de>
parents: 1647
diff changeset
   640
    "Modified: / 10-10-2007 / 23:19:03 / cg"
2069
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   641
!
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   642
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   643
storeOn:aStream
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   644
    aStream 
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   645
        nextPutAll:'('; 
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   646
        nextPutAll:self class name; 
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   647
        nextPutAll:' fromString:''';
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   648
        nextPutAll:self printString;
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   649
        nextPutAll:''')'.
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   650
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   651
    "
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   652
     Object readFrom:(UUID genUUID storeString) 
e84a7576e3ee storeString
sr
parents: 2021
diff changeset
   653
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
!UUID class methodsFor:'documentation'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
version
2170
8cd3d9480ab7 new: #asUUID
Stefan Vogel <sv@exept.de>
parents: 2132
diff changeset
   659
    ^ '$Header: /cvs/stx/stx/libbasic2/UUID.st,v 1.30 2009-06-15 12:43:41 stefan Exp $'
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
! !
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   661
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   662
UUID initialize!