UUID.st
author Claus Gittinger <cg@exept.de>
Fri, 18 Mar 2005 17:57:23 +0100
changeset 1543 929986f0910a
parent 1491 512b21b45a9e
child 1544 6c339f276b91
permissions -rw-r--r--
fixed readFrom:onError:
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
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libbasic2' }"
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
ByteArray variableByteSubclass:#UUID
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	instanceVariableNames:''
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    17
	classVariableNames:'CachedMACAddress Lock SequenceNumber LastTime Increment'
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
"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    40
    128-bit Universal Unique Ids (UUIDs) as define by OpenGroup/DCE
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    41
    http://www.opengroup.org/onlinepubs/9629399/apdxa.htm.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    42
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    43
    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
    44
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    45
    [author:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    46
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    47
    [instance variables:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    48
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    49
    [class variables:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    50
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    51
    [see also:]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    52
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    53
"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    54
! !
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    55
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    56
!UUID class methodsFor:'initialization'!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    57
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    58
initialize
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    59
    "I want to get informed about image restarts"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    60
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    61
    Lock isNil ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    62
        Lock := RecursionLock new name:'UUID'.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    63
        LastTime := 0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    64
        Increment := 0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    65
        ObjectMemory addDependent:self.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    66
    ]
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    67
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    68
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    69
update:something with:aParameter from:changedObject
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    70
    "flush cached MAC address (may have been restarted on another host)"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    71
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    72
    (something == #restarted) ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    73
        CachedMACAddress := nil.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    74
        SequenceNumber := nil.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
    75
    ]
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
!UUID class methodsFor:'instance creation'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
1382
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
    80
fromBytes:aByteArray
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
    81
    ^ self fromBytes:aByteArray msb:(UninterpretedBytes isBigEndian)
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
    82
!
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
    83
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
fromBytes:aByteArray msb:msb
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    |uuid d1 d2 d3|
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    uuid := self new.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    uuid replaceFrom:1 to:16 with:aByteArray.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    msb ifTrue:[
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
        d1 := aByteArray unsignedLongAt:1 bigEndian:msb.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        uuid unsignedLongAt:1 put:d1 bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
        d2 := aByteArray unsignedShortAt:1+4 bigEndian:msb.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        uuid unsignedShortAt:1+4 put:d2 bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
        d3 := aByteArray unsignedShortAt:1+4+2 bigEndian:msb.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
        uuid unsignedShortAt:1+4+2 put:d3 bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ uuid
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
     UUID fromBytes:#[16r01 16r02 16r03 16r04
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
                      16r05 16r06 16r07 16r08
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
                      16r09 16r10 16r11 16r12
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
                      16r13 16r14 16r15 16r16] msb:false. 
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
     UUID fromBytes:#[16r01 16r02 16r03 16r04
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
                      16r05 16r06 16r07 16r08
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
                      16r09 16r10 16r11 16r12
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
                      16r13 16r14 16r15 16r16] msb:true.    
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    "
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   117
genUUID
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   118
    "generate a new UUID"
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    ^ self new genUUID
1447
210f3ac37991 *** empty log message ***
penk
parents: 1433
diff changeset
   121
"
210f3ac37991 *** empty log message ***
penk
parents: 1433
diff changeset
   122
    self genUUID
210f3ac37991 *** empty log message ***
penk
parents: 1433
diff changeset
   123
"
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
new
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ^ super new:16
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
new:size
1320
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   131
    "allow creating with exact size. We need this for XMLStandardDecoder"
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   132
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   133
    size ~~ 16 ifTrue:[
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   134
        ^ self shouldNotImplement.
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   135
    ].
fc8265f89040 XMLStandardDecoder compatibility
Stefan Vogel <sv@exept.de>
parents: 1304
diff changeset
   136
    ^ super new:size.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   137
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   138
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   139
readFrom:aStringOrStream onError:errorBlock
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   140
    |d offs s uuid t byte|
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   141
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   142
    Error handle:[:ex |
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   143
        ^ errorBlock value.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   144
    ] do:[
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   145
        s := aStringOrStream readStream.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   146
        uuid := self new.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   147
        offs := 1.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   148
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   149
        s skipSeparators.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   150
        s peek == ${ ifTrue:[s next].
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   151
        s skipSeparators.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   152
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   153
        t := s next:8.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   154
        d := Integer readFrom:t radix:16 onError:[^ errorBlock value].
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   155
        uuid unsignedLongAt:1 put:d bigEndian:false.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   156
        offs := offs + 4.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   157
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   158
        s next.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   159
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   160
        1 to:3 do:[:i |
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   161
            t := s next:4.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   162
            d := Integer readFrom:t radix:16 onError:[^ errorBlock value].
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   163
            uuid unsignedShortAt:offs put:d bigEndian:false.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   164
            offs := offs + 2.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   165
            s next.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   166
        ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   167
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   168
        1 to:6 do:[:i |
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   169
            t := s next:2.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   170
            byte := Integer readFrom:t radix:16 onError:[^ errorBlock value].
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   171
            uuid at:offs put:byte.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   172
            offs := offs + 1.
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   173
        ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   174
    ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   175
    ^ uuid
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   176
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   177
    "
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   178
     UUID readFrom:'5ab2e9b4-3d48-11d2-9ea4-80c5140aaa77' 
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   179
     UUID fromString:'5ab2e9b4-3d48-11d2-9ea4-80c5140aaa77' 
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   180
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
!UUID class methodsFor:'defaults'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
uuidVersion
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    ^ 1
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   190
!UUID class methodsFor:'helpers'!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   191
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   192
getDtssUtcTime
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   193
    "return the DTSS based time in 100 nsec intervals
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   194
     DTSS UTC base time is October 15, 1582.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   195
     Unix base time is January 1, 1970.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   196
     The difference between both is: 16r01B21DD213814000"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   197
1433
47729d4283ef Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 1382
diff changeset
   198
    ^ Timestamp now getMilliseconds * 10000 + 16r01B21DD213814000.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   199
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   200
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   201
getValidMACAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   202
    "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
   203
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   204
    CachedMACAddress isNil ifTrue:[
1491
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   205
        |dictOfIf ipAddr|
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   206
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   207
        dictOfIf := OperatingSystem getNetworkMACAddresses.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   208
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   209
        dictOfIf do:[:macAddress |
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   210
            (macAddress contains:[:byte | byte ~~ 0]) ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   211
                ^ CachedMACAddress := macAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   212
            ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   213
        ].
1491
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   214
        'UUID [warning]: no mac address - using ipAddress' errorPrintCR.
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   215
        ipAddr := Socket ipAddressOfHost:(OperatingSystem getHostName).
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   216
        ^ ipAddr , #[16r55 16r55].
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   217
        "/ ^ #[16r55 16r55 16r55 16r55 16r55 16r55].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   218
    ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   219
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   220
    ^ CachedMACAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   221
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   222
    "
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   223
       CachedMACAddress := nil.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   224
       self getValidMACAddress
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   225
    "
1491
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   226
512b21b45a9e noMacAddress fallBack (NT4.0)
Claus Gittinger <cg@exept.de>
parents: 1467
diff changeset
   227
    "Modified: / 17-11-2004 / 01:45:53 / cg"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   228
! !
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   229
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   230
!UUID methodsFor:'accessing'!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   231
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   232
clockSeqAndReserved
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   233
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   234
    ^ self unsignedShortAt:9 bigEndian:false
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   235
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   236
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   237
node
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   238
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   239
    ^ self copyFrom:10 to:16
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   240
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   241
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   242
timeHighAndVersion
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   243
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   244
    ^ self unsignedShortAt:7 bigEndian:false
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   245
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   246
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   247
timeLow
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   248
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   249
    ^ self unsignedLongAt:1 bigEndian:false
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   250
!
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   251
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   252
timeMid
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   253
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   254
    ^ self unsignedShortAt:5 bigEndian:false
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   255
! !
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   256
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
!UUID methodsFor:'converting'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
1382
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   259
asBytes
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   260
    ^ self asBytesMSB:(UninterpretedBytes isBigEndian)
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   261
!
626693b1fed7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
   262
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
asBytesMSB:msb
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    |bytes d1 d2 d3|
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
    bytes := ByteArray new:16.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    bytes replaceFrom:1 to:16 with:self.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    msb ifTrue:[
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
        d1 := self unsignedLongAt:1 bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
        d2 := self unsignedShortAt:1+4 bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
        d3 := self unsignedShortAt:1+4+2 bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
        bytes unsignedLongAt:1 put:d1 bigEndian:true.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
        bytes unsignedShortAt:1+4 put:d2 bigEndian:true.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
        bytes unsignedShortAt:1+4+2 put:d3 bigEndian:true.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    ^ bytes
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
!UUID methodsFor:'generating uuids'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
genUUID
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   284
    |macBytes utcTime|
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   286
    macBytes := self class getValidMACAddress.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   288
    "use 60 bit counter of 100ns ticks since 00:00:00 15.oct 1582 (sigh)"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   289
    Lock critical:[
1467
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   290
        SequenceNumber isNil ifTrue:[
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   291
            SequenceNumber := Random nextIntegerBetween:0 and:16383.
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   292
        ].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   293
        utcTime := self class getDtssUtcTime.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   294
        LastTime < utcTime ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   295
            Increment := 0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   296
        ] ifFalse:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   297
            LastTime = utcTime ifTrue:[
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   298
                "clock didn't advance since last call. Simply add a tick"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   299
                Increment := Increment + 1.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   300
            ] ifFalse:[
1467
a394ade68816 Protect against a nil SequenceNumber
Stefan Vogel <sv@exept.de>
parents: 1447
diff changeset
   301
                "clock went backwards - increment SequenceNumber"
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   302
                Increment := 0.
1214
7ae6b9302754 Fix previous change
Stefan Vogel <sv@exept.de>
parents: 1213
diff changeset
   303
                SequenceNumber := SequenceNumber + 1.
7ae6b9302754 Fix previous change
Stefan Vogel <sv@exept.de>
parents: 1213
diff changeset
   304
                SequenceNumber >= 16384 ifTrue:[SequenceNumber := 0].
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   305
            ].
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
        ].
1214
7ae6b9302754 Fix previous change
Stefan Vogel <sv@exept.de>
parents: 1213
diff changeset
   307
        
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   308
        LastTime := utcTime.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   309
        utcTime := utcTime + Increment.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   312
    "first 60 bits of timestamp"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   313
    self replaceFrom:1 to:8 with:utcTime digitBytes.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   314
    "multiplex the 4 bit version number in high bits of byte 8"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   315
    self at:8 put:((self at:8) bitOr:(self class uuidVersion bitShift:4)).
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   317
    "2 sequence bytes + reserved bits"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   318
    self at:9  put:(SequenceNumber digitAt:1).
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   319
    self at:10 put:((SequenceNumber digitAt:2) bitOr:2r10000000).
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   320
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   321
    "48 bits of MAC-Address"
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   322
    self replaceFrom:11 to:16 with:macBytes startingAt:1.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    "
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   325
      self genUUID
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   326
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   328
    "
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   329
      1 to: 100 do:[ : el |
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   330
          Transcript show:el.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   331
          Transcript show:': '.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   332
          Transcript showCR:(UUID genUUID).
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   333
      ].
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   334
    "
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
!UUID methodsFor:'printing'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
displayString
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    ^ self printString
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
printOn:aStream
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   344
    |offs d tmpStream|
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   346
    tmpStream := '' writeStream.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    d := self unsignedLongAt:1 bigEndian:false.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   349
    d printOn:tmpStream base:16 size:8 fill:$0.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   351
    tmpStream nextPut:$-.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   353
    offs := 5.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   354
    3 timesRepeat:[
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
        d := self unsignedShortAt:offs bigEndian:false.
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
        offs := offs + 2.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   357
        d printOn:tmpStream base:16 size:4 fill:$0.
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   358
        tmpStream nextPut:$-.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
    6 timesRepeat:[
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   362
        d := self at:offs.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
        offs := offs + 1.
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   364
        d printOn:tmpStream base:16 size:2 fill:$0.
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
    ].
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
1213
5a23a433a990 Refactoring
Stefan Vogel <sv@exept.de>
parents: 1188
diff changeset
   367
    aStream nextPutAll:(tmpStream contents asLowercase).
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
! !
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
!UUID class methodsFor:'documentation'!
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
version
1543
929986f0910a fixed readFrom:onError:
Claus Gittinger <cg@exept.de>
parents: 1491
diff changeset
   373
    ^ '$Header: /cvs/stx/stx/libbasic2/UUID.st,v 1.12 2005-03-18 16:57:23 cg Exp $'
1188
58856b846271 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
! !
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
UUID initialize!