root / trunk / web / dojo / dojox / uuid / Uuid.js @ 10
History | View | Annotate | Download (2.27 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.uuid.Uuid"]){ |
||
9 | dojo._hasResource["dojox.uuid.Uuid"]=true; |
||
10 | dojo.provide("dojox.uuid.Uuid");
|
||
11 | dojo.require("dojox.uuid");
|
||
12 | dojox.uuid.Uuid=function(_1){ |
||
13 | this._uuidString=dojox.uuid.NIL_UUID;
|
||
14 | if(_1){
|
||
15 | dojox.uuid.assert(dojo.isString(_1)); |
||
16 | this._uuidString=_1.toLowerCase();
|
||
17 | dojox.uuid.assert(this.isValid());
|
||
18 | }else{
|
||
19 | var _2=dojox.uuid.Uuid.getGenerator();
|
||
20 | if(_2){
|
||
21 | this._uuidString=_2();
|
||
22 | dojox.uuid.assert(this.isValid());
|
||
23 | } |
||
24 | } |
||
25 | }; |
||
26 | dojox.uuid.Uuid.compare=function(_3,_4){ |
||
27 | var _5=_3.toString();
|
||
28 | var _6=_4.toString();
|
||
29 | if(_5>_6){
|
||
30 | return 1; |
||
31 | } |
||
32 | if(_5<_6){
|
||
33 | return -1; |
||
34 | } |
||
35 | return 0; |
||
36 | }; |
||
37 | dojox.uuid.Uuid.setGenerator=function(_7){ |
||
38 | dojox.uuid.assert(!_7||dojo.isFunction(_7)); |
||
39 | dojox.uuid.Uuid._ourGenerator=_7; |
||
40 | }; |
||
41 | dojox.uuid.Uuid.getGenerator=function(){ |
||
42 | return dojox.uuid.Uuid._ourGenerator;
|
||
43 | }; |
||
44 | dojox.uuid.Uuid.prototype.toString=function(){ |
||
45 | return this._uuidString; |
||
46 | }; |
||
47 | dojox.uuid.Uuid.prototype.compare=function(_8){ |
||
48 | return dojox.uuid.Uuid.compare(this,_8); |
||
49 | }; |
||
50 | dojox.uuid.Uuid.prototype.isEqual=function(_9){ |
||
51 | return (this.compare(_9)==0); |
||
52 | }; |
||
53 | dojox.uuid.Uuid.prototype.isValid=function(){ |
||
54 | return dojox.uuid.isValid(this); |
||
55 | }; |
||
56 | dojox.uuid.Uuid.prototype.getVariant=function(){ |
||
57 | return dojox.uuid.getVariant(this); |
||
58 | }; |
||
59 | dojox.uuid.Uuid.prototype.getVersion=function(){ |
||
60 | if(!this._versionNumber){ |
||
61 | this._versionNumber=dojox.uuid.getVersion(this); |
||
62 | } |
||
63 | return this._versionNumber; |
||
64 | }; |
||
65 | dojox.uuid.Uuid.prototype.getNode=function(){ |
||
66 | if(!this._nodeString){ |
||
67 | this._nodeString=dojox.uuid.getNode(this); |
||
68 | } |
||
69 | return this._nodeString; |
||
70 | }; |
||
71 | dojox.uuid.Uuid.prototype.getTimestamp=function(_a){ |
||
72 | if(!_a){
|
||
73 | _a=null;
|
||
74 | } |
||
75 | switch(_a){
|
||
76 | case "string": |
||
77 | case String:
|
||
78 | return this.getTimestamp(Date).toUTCString(); |
||
79 | break;
|
||
80 | case "hex": |
||
81 | if(!this._timestampAsHexString){ |
||
82 | this._timestampAsHexString=dojox.uuid.getTimestamp(this,"hex"); |
||
83 | } |
||
84 | return this._timestampAsHexString; |
||
85 | break;
|
||
86 | case null: |
||
87 | case "date": |
||
88 | case Date:
|
||
89 | if(!this._timestampAsDate){ |
||
90 | this._timestampAsDate=dojox.uuid.getTimestamp(this,Date); |
||
91 | } |
||
92 | return this._timestampAsDate; |
||
93 | break;
|
||
94 | default:
|
||
95 | dojox.uuid.assert(false,"The getTimestamp() method dojox.uuid.Uuid was passed a bogus returnType: "+_a); |
||
96 | break;
|
||
97 | } |
||
98 | }; |
||
99 | } |