Source Code Cross Referenced for Integer.java in  » Ajax » GWT » com » google » gwt » emul » java » lang » 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 » Ajax » GWT » com.google.gwt.emul.java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package java.lang;
017:
018:        /**
019:         * Wraps a primitive <code>int</code> as an object.
020:         */
021:        public final class Integer extends Number implements 
022:                Comparable<Integer> {
023:
024:            public static final int MIN_VALUE = 0x80000000;
025:            public static final int MAX_VALUE = 0x7fffffff;
026:            public static final int SIZE = 32;
027:
028:            // Box values according to JLS - between -128 and 127
029:            private static Integer[] boxedValues = new Integer[256];
030:
031:            public static int bitCount(int x) {
032:                // Courtesy the University of Kentucky
033:                // http://aggregate.org/MAGIC/#Population%20Count%20(Ones%20Count)
034:                x -= ((x >> 1) & 0x55555555);
035:                x = (((x >> 2) & 0x33333333) + (x & 0x33333333));
036:                x = (((x >> 4) + x) & 0x0f0f0f0f);
037:                x += (x >> 8);
038:                x += (x >> 16);
039:                return x & 0x0000003f;
040:            }
041:
042:            public static Integer decode(String s) throws NumberFormatException {
043:                return new Integer((int) __decodeAndValidateLong(s, MIN_VALUE,
044:                        MAX_VALUE));
045:            }
046:
047:            /**
048:             * @skip
049:             * 
050:             * Here for shared implementation with Arrays.hashCode
051:             */
052:            public static int hashCode(int i) {
053:                return i;
054:            }
055:
056:            public static int highestOneBit(int i) {
057:                if (i < 0) {
058:                    return MIN_VALUE;
059:                } else if (i == 0) {
060:                    return 0;
061:                } else {
062:                    int rtn;
063:                    for (rtn = 0x40000000; (rtn & i) == 0; rtn = rtn >> 1) {
064:                        // loop down until smaller
065:                    }
066:                    return rtn;
067:                }
068:            }
069:
070:            public static int lowestOneBit(int i) {
071:                if (i == 0) {
072:                    return 0;
073:                } else if (i == Integer.MIN_VALUE) {
074:                    return 0x80000000;
075:                } else {
076:                    int r = 1;
077:                    while ((r & i) == 0) {
078:                        r = r * 2;
079:                    }
080:                    return r;
081:                }
082:            }
083:
084:            public static int numberOfLeadingZeros(int i) {
085:                if (i < 0) {
086:                    return 0;
087:                } else if (i == 0) {
088:                    return SIZE;
089:                } else {
090:                    return SIZE - 1
091:                            - (int) Math.floor(Math.log(i) / Math.log(2.0d));
092:                }
093:            }
094:
095:            public static int numberOfTrailingZeros(int i) {
096:                if (i == 0) {
097:                    return 32;
098:                } else {
099:                    int rtn = 0;
100:                    for (int r = 1; (r & i) == 0; r = r * 2) {
101:                        rtn++;
102:                    }
103:                    return rtn;
104:                }
105:            }
106:
107:            public static int parseInt(String s) throws NumberFormatException {
108:                return parseInt(s, 10);
109:            }
110:
111:            public static int parseInt(String s, int radix)
112:                    throws NumberFormatException {
113:                return (int) __parseAndValidateLong(s, radix, MIN_VALUE,
114:                        MAX_VALUE);
115:            }
116:
117:            public static int reverse(int i) {
118:                int ui = i & 0x7fffffff; // avoid sign extension
119:                int acc = 0;
120:                int front = 0x80000000;
121:                int back = 1;
122:                int swing = 31;
123:                while (swing > 0) {
124:                    acc = acc | ((ui & front) >> swing)
125:                            | ((ui & back) << swing);
126:                    swing -= 2;
127:                    front = front >> 1;
128:                    back = back << 1;
129:                }
130:                if (i < 0) {
131:                    acc = acc | 0x1; // restore the real value of 0x80000000
132:                }
133:                return acc;
134:            }
135:
136:            public static int reverseBytes(int i) {
137:                return ((i & 0xff) << 24) | ((i & 0xff00) << 8)
138:                        | ((i & 0xff0000) >> 8) | ((i & 0xff000000) >> 24);
139:            }
140:
141:            public static int rotateLeft(int i, int distance) {
142:                while (distance-- > 0) {
143:                    i = i << 1 | ((i < 0) ? 1 : 0);
144:                }
145:                return i;
146:            }
147:
148:            public static int rotateRight(int i, int distance) {
149:                int ui = i & 0x7fffffff; // avoid sign extension
150:                int carry = (i < 0) ? 0x40000000 : 0; // 0x80000000 rightshifted 1
151:                while (distance-- > 0) {
152:                    int nextcarry = ui & 1;
153:                    ui = carry | (ui >> 1);
154:                    carry = (nextcarry == 0) ? 0 : 0x40000000;
155:                }
156:                if (carry != 0) {
157:                    ui = ui | 0x80000000;
158:                }
159:                return ui;
160:            }
161:
162:            public static int signum(int i) {
163:                if (i == 0) {
164:                    return 0;
165:                } else if (i < 0) {
166:                    return -1;
167:                } else {
168:                    return 1;
169:                }
170:            }
171:
172:            public static String toBinaryString(int x) {
173:                return Long.toBinaryString(x);
174:            }
175:
176:            public static String toHexString(int x) {
177:                return Long.toHexString(x);
178:            }
179:
180:            public static String toString(int b) {
181:                return String.valueOf(b);
182:            }
183:
184:            public static Integer valueOf(int i) {
185:                if (i > -129 && i < 128) {
186:                    int rebase = i + 128;
187:                    if (boxedValues[rebase] == null) {
188:                        boxedValues[rebase] = new Integer(i);
189:                    }
190:                    return boxedValues[rebase];
191:                }
192:                return new Integer(i);
193:            }
194:
195:            public static Integer valueOf(String s)
196:                    throws NumberFormatException {
197:                return new Integer(Integer.parseInt(s));
198:            }
199:
200:            public static Integer valueOf(String s, int radix)
201:                    throws NumberFormatException {
202:                return new Integer(Integer.parseInt(s, radix));
203:            }
204:
205:            private final transient int value;
206:
207:            public Integer(int value) {
208:                this .value = value;
209:            }
210:
211:            public Integer(String s) {
212:                value = parseInt(s);
213:            }
214:
215:            @Override
216:            public byte byteValue() {
217:                return (byte) value;
218:            }
219:
220:            public int compareTo(Integer b) {
221:                if (value < b.value) {
222:                    return -1;
223:                } else if (value > b.value) {
224:                    return 1;
225:                } else {
226:                    return 0;
227:                }
228:            }
229:
230:            @Override
231:            public double doubleValue() {
232:                return value;
233:            }
234:
235:            @Override
236:            public boolean equals(Object o) {
237:                return (o instanceof  Integer) && (((Integer) o).value == value);
238:            }
239:
240:            @Override
241:            public float floatValue() {
242:                return value;
243:            }
244:
245:            @Override
246:            public int hashCode() {
247:                return hashCode(value);
248:            }
249:
250:            @Override
251:            public int intValue() {
252:                return value;
253:            }
254:
255:            @Override
256:            public long longValue() {
257:                return value;
258:            }
259:
260:            @Override
261:            public short shortValue() {
262:                return (short) value;
263:            }
264:
265:            @Override
266:            public String toString() {
267:                return toString(value);
268:            }
269:
270:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.