Source Code Cross Referenced for UUID_V1.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » shared » uuid » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.shared.uuid 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003:         * [See end of file]
004:         */
005:
006:        package com.hp.hpl.jena.shared.uuid;
007:
008:        /*
009:         Version 1:
010:         60 bits of time
011:         48 bits of nodeId
012:         12 bits of clock sequence
013:         2  bits variant
014:         4  bits version
015:
016:         0                   1                   2                   3
017:         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
018:         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
019:         |                          time_low                             |   8 hex digits
020:         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
021:         |       time_mid                |         time_hi_and_version   |   4-4
022:         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
023:         |clk_seq_hi_res |  clk_seq_low  |         node (0-1)            |   4-
024:         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
025:         |                         node (2-5)                            |   12
026:         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
027:         */
028:
029:        // http://www.opengroup.org/onlinepubs/009629399/apdxa.htm
030:        /* java.util.UUID
031:         0xFFFFFFFF00000000 time_low
032:         0x00000000FFFF0000 time_mid
033:         0x000000000000F000 version
034:         0x0000000000000FFF time_hi
035:
036:         The least significant long consists of the following unsigned fields:
037:
038:         0xC000000000000000 variant
039:         0x3FFF000000000000 clock_seq
040:         0x0000FFFFFFFFFFFF node
041:         */
042:
043:        /** Timebased UUIDs.
044:         * 
045:         * @author		Andy Seaborne
046:         * @version 	$Id: UUID_V1.java,v 1.7 2008/01/02 12:06:07 andy_seaborne Exp $
047:         */
048:
049:        public class UUID_V1 extends JenaUUID {
050:            // Constants
051:            public static final int version = 1; // Version 1: time-based.
052:            public static final int variant = JenaUUID.Var_Std; // DCE varient
053:
054:            // The only state-per-object
055:            long bitsMostSignificant;
056:            long bitsLeastSignificant;
057:
058:            UUID_V1(long mostSigBits, long leastSigBits) {
059:                if (!check(mostSigBits, leastSigBits)) {
060:                    check(mostSigBits, leastSigBits);
061:                    throw new IllegalArgumentException("Funny bits");
062:                }
063:                bitsMostSignificant = mostSigBits;
064:                bitsLeastSignificant = leastSigBits;
065:            }
066:
067:            public long getMostSignificantBits() {
068:                return bitsMostSignificant;
069:            }
070:
071:            public long getLeastSignificantBits() {
072:                return bitsLeastSignificant;
073:            }
074:
075:            private boolean check(long mostSigBits, long leastSigBits) {
076:                int _variant = _getVariant(mostSigBits, leastSigBits);
077:                int _version = _getVersion(mostSigBits, leastSigBits);
078:
079:                if (_variant != variant)
080:                    return false;
081:                if (_version != version)
082:                    return false;
083:                return true;
084:            }
085:
086:            public String toString() {
087:                return UUID_V1_Gen.unparse(this );
088:            }
089:
090:            // Time low - which includes the incremental count. 
091:            public int hashCode() {
092:                return (int) Bits.unpack(bitsMostSignificant, 32, 64);
093:            }
094:
095:            public boolean equals(Object other) {
096:                if (!(other instanceof  UUID_V1))
097:                    return false;
098:                UUID_V1 x = (UUID_V1) other;
099:                return this .bitsMostSignificant == x.bitsMostSignificant
100:                        && this .bitsLeastSignificant == x.bitsLeastSignificant;
101:            }
102:
103:            // Accessors
104:
105:            long getTimeHigh() {
106:                return Bits.unpack(bitsMostSignificant, 0, 12);
107:            } // ( uuid.bitsUpper & UUID_V1_Gen.maskTimeHigh ) ;
108:
109:            long getTimeMid() {
110:                return Bits.unpack(bitsMostSignificant, 16, 32);
111:            } // ( uuid.bitsUpper & UUID_V1_Gen.maskTimeMid ) >>> 16 ;
112:
113:            long getTimeLow() {
114:                return Bits.unpack(bitsMostSignificant, 32, 64);
115:            } // ( uuid.bitsUpper & UUID_V1_Gen.maskTimeLow ) >>> 32;
116:
117:            public long getTimestamp() {
118:                return getTimeLow() | getTimeMid() << 32 | getTimeHigh() << 48;
119:            }
120:
121:            public long getClockSequence() {
122:                return Bits.unpack(bitsLeastSignificant, 48, 62);
123:            }
124:
125:            public long getNode() {
126:                return Bits.unpack(bitsLeastSignificant, 0, 48);
127:            }
128:
129:            public int getVersion() {
130:                return super ._getVersion(bitsMostSignificant,
131:                        bitsLeastSignificant);
132:            }
133:
134:            public int getVariant() {
135:                return super ._getVariant(bitsMostSignificant,
136:                        bitsLeastSignificant);
137:            }
138:        }
139:
140:        /*
141:         *  (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
142:         *  All rights reserved.
143:         *
144:         * Redistribution and use in source and binary forms, with or without
145:         * modification, are permitted provided that the following conditions
146:         * are met:
147:         * 1. Redistributions of source code must retain the above copyright
148:         *    notice, this list of conditions and the following disclaimer.
149:         * 2. Redistributions in binary form must reproduce the above copyright
150:         *    notice, this list of conditions and the following disclaimer in the
151:         *    documentation and/or other materials provided with the distribution.
152:         * 3. The name of the author may not be used to endorse or promote products
153:         *    derived from this software without specific prior written permission.
154:         *
155:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
156:         * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
157:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
158:         * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
159:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
160:         * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
161:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
162:         * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
163:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
164:         * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
165:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.