Source Code Cross Referenced for DefaultCaseConverter.java in  » 6.0-JDK-Modules » j2me » com » sun » cldc » i18n » uclc » 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 » 6.0 JDK Modules » j2me » com.sun.cldc.i18n.uclc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.cldc.i18n.uclc;
028:
029:        import java.io.*;
030:        import com.sun.cldc.i18n.*;
031:
032:        /**
033:         * Default class converting the case of characters.
034:         *
035:         * @version 1.0 04/04/2000
036:         */
037:        public class DefaultCaseConverter {
038:
039:            /**
040:             * Determines if the specified character is a lowercase character.
041:             * The default case converter in CLDC only supports the ISO Latin-1 
042:             * range of characters.
043:             * <p>
044:             * Of the ISO Latin-1 characters (character codes 0x0000 through 0x00FF),
045:             * the following are lowercase:
046:             * <p>
047:             * a b c d e f g h i j k l m n o p q r s t u v w x y z
048:             * &#92;u00DF &#92;u00E0 &#92;u00E1 &#92;u00E2 &#92;u00E3 &#92;u00E4 &#92;u00E5 &#92;u00E6 &#92;u00E7
049:             * &#92;u00E8 &#92;u00E9 &#92;u00EA &#92;u00EB &#92;u00EC &#92;u00ED &#92;u00EE &#92;u00EF &#92;u00F0
050:             * &#92;u00F1 &#92;u00F2 &#92;u00F3 &#92;u00F4 &#92;u00F5 &#92;u00F6 &#92;u00F8 &#92;u00F9 &#92;u00FA
051:             * &#92;u00FB &#92;u00FC &#92;u00FD &#92;u00FE &#92;u00FF
052:             *
053:             * @param   ch   the character to be tested.
054:             * @return  <code>true</code> if the character is lowercase;
055:             *          <code>false</code> otherwise.
056:             * @since   JDK1.0
057:             */
058:            public static boolean isLowerCase(char ch) {
059:                return (ch >= 'a' && ch <= 'z') || (ch >= 0xDF && ch <= 0xF6)
060:                        || (ch >= 0xF8 && ch <= 0xFF);
061:            }
062:
063:            /**
064:             * Determines if the specified character is an uppercase character.
065:             * The default case converter in CLDC only supports the ISO Latin-1 
066:             * range of characters.
067:             * <p>
068:             * Of the ISO Latin-1 characters (character codes 0x0000 through 0x00FF),
069:             * the following are uppercase:
070:             * <p>
071:             * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
072:             * &#92;u00C0 &#92;u00C1 &#92;u00C2 &#92;u00C3 &#92;u00C4 &#92;u00C5 &#92;u00C6 &#92;u00C7
073:             * &#92;u00C8 &#92;u00C9 &#92;u00CA &#92;u00CB &#92;u00CC &#92;u00CD &#92;u00CE &#92;u00CF &#92;u00D0
074:             * &#92;u00D1 &#92;u00D2 &#92;u00D3 &#92;u00D4 &#92;u00D5 &#92;u00D6 &#92;u00D8 &#92;u00D9 &#92;u00DA
075:             * &#92;u00DB &#92;u00DC &#92;u00DD &#92;u00DE
076:             *
077:             * @param   ch   the character to be tested.
078:             * @return  <code>true</code> if the character is uppercase;
079:             *          <code>false</code> otherwise.
080:             * @see     java.lang.Character#isLowerCase(char)
081:             * @see     java.lang.Character#toUpperCase(char)
082:             * @since   1.0
083:             */
084:            public static boolean isUpperCase(char ch) {
085:                return (ch >= 'A' && ch <= 'Z') || (ch >= 0xC0 && ch <= 0xD6)
086:                        || (ch >= 0xD8 && ch <= 0xDE);
087:            }
088:
089:            /**
090:             * The given character is mapped to its lowercase equivalent; if the
091:             * character has no lowercase equivalent, the character itself is
092:             * returned.  The default case converter in CLDC only supports
093:             * the ISO Latin-1 range of characters.
094:             *
095:             * @param   ch   the character to be converted.
096:             * @return  the lowercase equivalent of the character, if any;
097:             *          otherwise the character itself.
098:             * @see     java.lang.Character#isLowerCase(char)
099:             * @see     java.lang.Character#isUpperCase(char)
100:             * @see     java.lang.Character#toUpperCase(char)
101:             * @since   JDK1.0
102:             */
103:            public static char toLowerCase(char ch) {
104:                if (isUpperCase(ch)) {
105:                    if (ch <= 'Z') {
106:                        return (char) (ch + ('a' - 'A'));
107:                    } else {
108:                        return (char) (ch + 0x20);
109:                    }
110:                } else {
111:                    return ch;
112:                }
113:            }
114:
115:            /**
116:             * Converts the character argument to uppercase; if the
117:             * character has no lowercase equivalent, the character itself is
118:             * returned.  The default case converter in CLDC only supports
119:             * the ISO Latin-1 range of characters.
120:             *
121:             * @param   ch   the character to be converted.
122:             * @return  the uppercase equivalent of the character, if any;
123:             *          otherwise the character itself.
124:             * @see     java.lang.Character#isLowerCase(char)
125:             * @see     java.lang.Character#isUpperCase(char)
126:             * @see     java.lang.Character#toLowerCase(char)
127:             * @since   JDK1.0
128:             */
129:            public static char toUpperCase(char ch) {
130:                if (isLowerCase(ch)) {
131:                    if (ch <= 'z') {
132:                        return (char) (ch - ('a' - 'A'));
133:                    } else {
134:                        return (char) (ch - 0x20);
135:                    }
136:                } else {
137:                    return ch;
138:                }
139:            }
140:
141:            /**
142:             * Determines if the specified character is a digit.
143:             * This is currently only supported for ISO Latin-1 digits: "0" through "9".
144:             *
145:             * @param   ch   the character to be tested.
146:             * @return  <code>true</code> if the character is a digit;
147:             *          <code>false</code> otherwise.
148:             * @since   JDK1.0
149:             */
150:            public static boolean isDigit(char ch) {
151:                return ch >= '0' && ch <= '9';
152:            }
153:
154:            /**
155:             * Returns the numeric value of the character <code>ch</code>
156:             * in the specified radix.
157:             * This is only supported for ISO Latin-1 characters.
158:             *
159:             * @param   ch      the character to be converted.
160:             * @param   radix   the radix.
161:             * @return  the numeric value represented by the character in the
162:             *          specified radix.
163:             * @see     java.lang.Character#isDigit(char)
164:             * @since   JDK1.0
165:             */
166:            public static int digit(char ch, int radix) {
167:                int value = -1;
168:                if (radix >= Character.MIN_RADIX
169:                        && radix <= Character.MAX_RADIX) {
170:                    if (isDigit(ch)) {
171:                        value = ch - '0';
172:                    } else if (isUpperCase(ch) || isLowerCase(ch)) {
173:                        // Java supradecimal digit
174:                        value = (ch & 0x1F) + 9;
175:                    }
176:                }
177:                return (value < radix) ? value : -1;
178:            }
179:
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.