Source Code Cross Referenced for Character.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:        import java.io.Serializable;
019:
020:        /**
021:         * Wraps a native <code>char</code> as an object.
022:         */
023:        public final class Character implements  Comparable<Character>,
024:                Serializable {
025:
026:            public static final int MIN_RADIX = 2;
027:            public static final int MAX_RADIX = 36;
028:
029:            public static final char MIN_VALUE = '\u0000';
030:            public static final char MAX_VALUE = '\uFFFF';
031:
032:            // Box values according to JLS - from \u0000 to \u007f
033:            private static Character[] boxedValues = new Character[128];
034:
035:            public static int digit(char c, int radix) {
036:                if (radix < MIN_RADIX || radix > MAX_RADIX) {
037:                    return -1;
038:                }
039:
040:                if (c >= '0' && c < '0' + Math.min(radix, 10)) {
041:                    return c - '0';
042:                }
043:
044:                // The offset by 10 is to re-base the alpha values
045:                if (c >= 'a' && c < (radix + 'a' - 10)) {
046:                    return c - 'a' + 10;
047:                }
048:
049:                if (c >= 'A' && c < (radix + 'A' - 10)) {
050:                    return c - 'A' + 10;
051:                }
052:
053:                return -1;
054:            }
055:
056:            public static char forDigit(int digit, int radix) {
057:                if (radix < MIN_RADIX || radix > MAX_RADIX) {
058:                    return 0;
059:                }
060:
061:                if (digit < 0 || digit >= radix) {
062:                    return 0;
063:                }
064:
065:                final int baseTenMax = 10;
066:                if (digit < baseTenMax) {
067:                    return (char) ('0' + digit);
068:                } else {
069:                    return (char) ('a' + digit - baseTenMax);
070:                }
071:            }
072:
073:            /**
074:             * @skip
075:             *
076:             * Here for shared implementation with Arrays.hashCode
077:             */
078:            public static int hashCode(char c) {
079:                return c;
080:            }
081:
082:            public static native boolean isDigit(char c) /*-{
083:               return (null != String.fromCharCode(c).match(/\d/));
084:             }-*/;
085:
086:            public static native boolean isLetter(char c) /*-{
087:               return (null != String.fromCharCode(c).match(/[A-Z]/i));
088:             }-*/;
089:
090:            public static native boolean isLetterOrDigit(char c) /*-{
091:               return (null != String.fromCharCode(c).match(/[A-Z\d]/i));
092:             }-*/;
093:
094:            public static boolean isLowerCase(char c) {
095:                return toLowerCase(c) == c && isLetter(c);
096:            }
097:
098:            public static boolean isSpace(char c) {
099:                switch (c) {
100:                case ' ':
101:                    return true;
102:                case '\n':
103:                    return true;
104:                case '\t':
105:                    return true;
106:                case '\f':
107:                    return true;
108:                case '\r':
109:                    return true;
110:                default:
111:                    return false;
112:                }
113:            }
114:
115:            public static boolean isUpperCase(char c) {
116:                return toUpperCase(c) == c && isLetter(c);
117:            }
118:
119:            public static native char toLowerCase(char c) /*-{
120:               return String.fromCharCode(c).toLowerCase().charCodeAt(0);
121:             }-*/;
122:
123:            public static String toString(char x) {
124:                return String.valueOf(x);
125:            }
126:
127:            public static native char toUpperCase(char c) /*-{
128:               return String.fromCharCode(c).toUpperCase().charCodeAt(0);
129:             }-*/;
130:
131:            public static Character valueOf(char c) {
132:                if (c < 128) {
133:                    if (boxedValues[c] == null) {
134:                        boxedValues[c] = new Character(c);
135:                    }
136:                    return boxedValues[c];
137:                }
138:                return new Character(c);
139:            }
140:
141:            private final transient char value;
142:
143:            public Character(char value) {
144:                this .value = value;
145:            }
146:
147:            public char charValue() {
148:                return value;
149:            }
150:
151:            public int compareTo(Character c) {
152:                if (value < c.value) {
153:                    return -1;
154:                } else if (value > c.value) {
155:                    return 1;
156:                } else {
157:                    return 0;
158:                }
159:            }
160:
161:            @Override
162:            public boolean equals(Object o) {
163:                return (o instanceof  Character)
164:                        && (((Character) o).value == value);
165:            }
166:
167:            @Override
168:            public int hashCode() {
169:                return hashCode(value);
170:            }
171:
172:            @Override
173:            public String toString() {
174:                return String.valueOf(value);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.