Source Code Cross Referenced for UCharacterCompare.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » 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 » Internationalization Localization » icu4j » com.ibm.icu.dev.test.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *******************************************************************************
003:         * Copyright (C) 1996-2006, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */package com.ibm.icu.dev.test.lang;
007:
008:        import com.ibm.icu.lang.UCharacter;
009:        import com.ibm.icu.lang.UCharacterCategory;
010:        import java.io.FileWriter;
011:        import java.io.PrintWriter;
012:        import java.util.Hashtable;
013:        import java.util.Enumeration;
014:
015:        /**
016:         * A class to compare the difference in methods between java.lang.Character and
017:         * UCharacter
018:         * @author Syn Wee Quek
019:         * @since oct 06 2000
020:         * @see com.ibm.icu.lang.UCharacter
021:         */
022:
023:        public final class UCharacterCompare {
024:            // private variables ================================================
025:
026:            private static Hashtable m_hashtable_ = new Hashtable();
027:
028:            // public methods ======================================================
029:
030:            /**
031:             * Main testing method
032:             */
033:            public static void main(String arg[]) {
034:                System.out.println("Starting character compare");
035:                try {
036:                    FileWriter f;
037:                    if (arg.length == 0)
038:                        f = new FileWriter("compare.txt");
039:                    else
040:                        f = new FileWriter(arg[0]);
041:                    PrintWriter p = new PrintWriter(f);
042:                    p
043:                            .print("char  character name                                                           ");
044:                    p.println("method name               ucharacter character");
045:                    for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
046:                        System.out.println("character \\u"
047:                                + Integer.toHexString(i));
048:                        if (UCharacter.isDefined(i) != Character.isDefined(i))
049:                            trackDifference(p, i, "isDefined()", ""
050:                                    + UCharacter.isDefined(i), ""
051:                                    + Character.isDefined(i));
052:                        else {
053:                            if (UCharacter.digit(i, 10) != Character.digit(i,
054:                                    10))
055:                                trackDifference(p, i, "digit()", ""
056:                                        + UCharacter.digit(i, 10), ""
057:                                        + Character.digit(i, 10));
058:                            if (UCharacter.getNumericValue(i) != Character
059:                                    .getNumericValue(i))
060:                                trackDifference(p, i, "getNumericValue()", ""
061:                                        + UCharacter.getNumericValue(i), ""
062:                                        + Character.getNumericValue(i));
063:                            if (!compareType(UCharacter.getType(i), Character
064:                                    .getType(i)))
065:                                trackDifference(p, i, "getType()", ""
066:                                        + UCharacter.getType(i), ""
067:                                        + Character.getType(i));
068:                            if (UCharacter.isDigit(i) != Character.isDigit(i))
069:                                trackDifference(p, i, "isDigit()", ""
070:                                        + UCharacter.isDigit(i), ""
071:                                        + Character.isDigit(i));
072:                            if (UCharacter.isISOControl(i) != Character
073:                                    .isISOControl(i))
074:                                trackDifference(p, i, "isISOControl()", ""
075:                                        + UCharacter.isISOControl(i), ""
076:                                        + Character.isISOControl(i));
077:                            if (UCharacter.isLetter(i) != Character.isLetter(i))
078:                                trackDifference(p, i, "isLetter()", ""
079:                                        + UCharacter.isLetter(i), ""
080:                                        + Character.isLetter(i));
081:                            if (UCharacter.isLetterOrDigit(i) != Character
082:                                    .isLetterOrDigit(i))
083:                                trackDifference(p, i, "isLetterOrDigit()", ""
084:                                        + UCharacter.isLetterOrDigit(i), ""
085:                                        + Character.isLetterOrDigit(i));
086:                            if (UCharacter.isLowerCase(i) != Character
087:                                    .isLowerCase(i))
088:                                trackDifference(p, i, "isLowerCase()", ""
089:                                        + UCharacter.isLowerCase(i), ""
090:                                        + Character.isLowerCase(i));
091:                            if (UCharacter.isWhitespace(i) != Character
092:                                    .isWhitespace(i))
093:                                trackDifference(p, i, "isWhitespace()", ""
094:                                        + UCharacter.isWhitespace(i), ""
095:                                        + Character.isWhitespace(i));
096:                            if (UCharacter.isSpaceChar(i) != Character
097:                                    .isSpaceChar(i))
098:                                trackDifference(p, i, "isSpaceChar()", ""
099:                                        + UCharacter.isSpaceChar(i), ""
100:                                        + Character.isSpaceChar(i));
101:                            if (UCharacter.isTitleCase(i) != Character
102:                                    .isTitleCase(i))
103:                                trackDifference(p, i, "isTitleChar()", ""
104:                                        + UCharacter.isTitleCase(i), ""
105:                                        + Character.isTitleCase(i));
106:                            if (UCharacter.isUnicodeIdentifierPart(i) != Character
107:                                    .isUnicodeIdentifierPart(i))
108:                                trackDifference(
109:                                        p,
110:                                        i,
111:                                        "isUnicodeIdentifierPart()",
112:                                        ""
113:                                                + UCharacter
114:                                                        .isUnicodeIdentifierPart(i),
115:                                        ""
116:                                                + Character
117:                                                        .isUnicodeIdentifierPart(i));
118:                            if (UCharacter.isUnicodeIdentifierStart(i) != Character
119:                                    .isUnicodeIdentifierStart(i))
120:                                trackDifference(
121:                                        p,
122:                                        i,
123:                                        "isUnicodeIdentifierStart()",
124:                                        ""
125:                                                + UCharacter
126:                                                        .isUnicodeIdentifierStart(i),
127:                                        ""
128:                                                + Character
129:                                                        .isUnicodeIdentifierStart(i));
130:                            if (UCharacter.isIdentifierIgnorable(i) != Character
131:                                    .isIdentifierIgnorable(i))
132:                                trackDifference(
133:                                        p,
134:                                        i,
135:                                        "isIdentifierIgnorable()",
136:                                        ""
137:                                                + UCharacter
138:                                                        .isIdentifierIgnorable(i),
139:                                        "" + Character.isIdentifierIgnorable(i));
140:                            if (UCharacter.isUpperCase(i) != Character
141:                                    .isUpperCase(i))
142:                                trackDifference(p, i, "isUpperCase()", ""
143:                                        + UCharacter.isUpperCase(i), ""
144:                                        + Character.isUpperCase(i));
145:                            if (UCharacter.toLowerCase(i) != Character
146:                                    .toLowerCase(i))
147:                                trackDifference(p, i, "toLowerCase()",
148:                                        Integer.toHexString(UCharacter
149:                                                .toLowerCase(i)), Integer
150:                                                .toHexString(Character
151:                                                        .toLowerCase(i)));
152:                            if (!UCharacter.toString(i).equals(
153:                                    new Character(i).toString()))
154:                                trackDifference(p, i, "toString()", UCharacter
155:                                        .toString(i), new Character(i)
156:                                        .toString());
157:                            if (UCharacter.toTitleCase(i) != Character
158:                                    .toTitleCase(i))
159:                                trackDifference(p, i, "toTitleCase()",
160:                                        Integer.toHexString(UCharacter
161:                                                .toTitleCase(i)), Integer
162:                                                .toHexString(Character
163:                                                        .toTitleCase(i)));
164:                            if (UCharacter.toUpperCase(i) != Character
165:                                    .toUpperCase(i))
166:                                trackDifference(p, i, "toUpperCase()",
167:                                        Integer.toHexString(UCharacter
168:                                                .toUpperCase(i)), Integer
169:                                                .toHexString(Character
170:                                                        .toUpperCase(i)));
171:                        }
172:                    }
173:                    summary(p);
174:                    p.close();
175:                } catch (Exception e) {
176:                    e.printStackTrace();
177:                }
178:            }
179:
180:            // private methods ===================================================
181:
182:            /**
183:             * Comparing types
184:             * @param uchartype UCharacter type
185:             * @param jchartype java.lang.Character type
186:             */
187:            private static boolean compareType(int uchartype, int jchartype) {
188:                if (uchartype == UCharacterCategory.UNASSIGNED
189:                        && jchartype == Character.UNASSIGNED)
190:                    return true;
191:                if (uchartype == UCharacterCategory.UPPERCASE_LETTER
192:                        && jchartype == Character.UPPERCASE_LETTER)
193:                    return true;
194:                if (uchartype == UCharacterCategory.LOWERCASE_LETTER
195:                        && jchartype == Character.LOWERCASE_LETTER)
196:                    return true;
197:                if (uchartype == UCharacterCategory.TITLECASE_LETTER
198:                        && jchartype == Character.TITLECASE_LETTER)
199:                    return true;
200:                if (uchartype == UCharacterCategory.MODIFIER_LETTER
201:                        && jchartype == Character.MODIFIER_LETTER)
202:                    return true;
203:                if (uchartype == UCharacterCategory.OTHER_LETTER
204:                        && jchartype == Character.OTHER_LETTER)
205:                    return true;
206:                if (uchartype == UCharacterCategory.NON_SPACING_MARK
207:                        && jchartype == Character.NON_SPACING_MARK)
208:                    return true;
209:                if (uchartype == UCharacterCategory.ENCLOSING_MARK
210:                        && jchartype == Character.ENCLOSING_MARK)
211:                    return true;
212:                if (uchartype == UCharacterCategory.COMBINING_SPACING_MARK
213:                        && jchartype == Character.COMBINING_SPACING_MARK)
214:                    return true;
215:                if (uchartype == UCharacterCategory.DECIMAL_DIGIT_NUMBER
216:                        && jchartype == Character.DECIMAL_DIGIT_NUMBER)
217:                    return true;
218:                if (uchartype == UCharacterCategory.LETTER_NUMBER
219:                        && jchartype == Character.LETTER_NUMBER)
220:                    return true;
221:                if (uchartype == UCharacterCategory.OTHER_NUMBER
222:                        && jchartype == Character.OTHER_NUMBER)
223:                    return true;
224:                if (uchartype == UCharacterCategory.SPACE_SEPARATOR
225:                        && jchartype == Character.SPACE_SEPARATOR)
226:                    return true;
227:                if (uchartype == UCharacterCategory.LINE_SEPARATOR
228:                        && jchartype == Character.LINE_SEPARATOR)
229:                    return true;
230:                if (uchartype == UCharacterCategory.PARAGRAPH_SEPARATOR
231:                        && jchartype == Character.PARAGRAPH_SEPARATOR)
232:                    return true;
233:                if (uchartype == UCharacterCategory.CONTROL
234:                        && jchartype == Character.CONTROL)
235:                    return true;
236:                if (uchartype == UCharacterCategory.FORMAT
237:                        && jchartype == Character.FORMAT)
238:                    return true;
239:                if (uchartype == UCharacterCategory.PRIVATE_USE
240:                        && jchartype == Character.PRIVATE_USE)
241:                    return true;
242:                if (uchartype == UCharacterCategory.SURROGATE
243:                        && jchartype == Character.SURROGATE)
244:                    return true;
245:                if (uchartype == UCharacterCategory.DASH_PUNCTUATION
246:                        && jchartype == Character.DASH_PUNCTUATION)
247:                    return true;
248:                if (uchartype == UCharacterCategory.START_PUNCTUATION
249:                        && jchartype == Character.START_PUNCTUATION)
250:                    return true;
251:                if (uchartype == UCharacterCategory.END_PUNCTUATION
252:                        && jchartype == Character.END_PUNCTUATION)
253:                    return true;
254:                if (uchartype == UCharacterCategory.CONNECTOR_PUNCTUATION
255:                        && jchartype == Character.CONNECTOR_PUNCTUATION)
256:                    return true;
257:                if (uchartype == UCharacterCategory.OTHER_PUNCTUATION
258:                        && jchartype == Character.OTHER_PUNCTUATION)
259:                    return true;
260:                if (uchartype == UCharacterCategory.MATH_SYMBOL
261:                        && jchartype == Character.MATH_SYMBOL)
262:                    return true;
263:                if (uchartype == UCharacterCategory.CURRENCY_SYMBOL
264:                        && jchartype == Character.CURRENCY_SYMBOL)
265:                    return true;
266:                if (uchartype == UCharacterCategory.MODIFIER_SYMBOL
267:                        && jchartype == Character.MODIFIER_SYMBOL)
268:                    return true;
269:                if (uchartype == UCharacterCategory.OTHER_SYMBOL
270:                        && jchartype == Character.OTHER_SYMBOL)
271:                    return true;
272:                if (uchartype == UCharacterCategory.INITIAL_PUNCTUATION
273:                        && jchartype == Character.START_PUNCTUATION)
274:                    return true;
275:                if (uchartype == UCharacterCategory.FINAL_PUNCTUATION
276:                        && jchartype == Character.END_PUNCTUATION)
277:                    return true;
278:                /*if (uchartype == UCharacterCategory.GENERAL_OTHER_TYPES && 
279:                  jchartype == Character.GENERAL_OTHER_TYPES)
280:                return true;*/
281:                return false;
282:            }
283:
284:            /**
285:             * Difference writing to file
286:             * @param f file outputstream
287:             * @param ch code point
288:             * @param method for testing
289:             * @param ucharval UCharacter value after running method
290:             * @param charval Character value after running method
291:             */
292:            private static void trackDifference(PrintWriter f, int ch,
293:                    String method, String ucharval, String charval)
294:                    throws Exception {
295:                if (m_hashtable_.containsKey(method)) {
296:                    Integer value = (Integer) m_hashtable_.get(method);
297:                    m_hashtable_.put(method, new Integer(value.intValue() + 1));
298:                } else
299:                    m_hashtable_.put(method, new Integer(1));
300:
301:                String temp = Integer.toHexString(ch);
302:                StringBuffer s = new StringBuffer(temp);
303:                for (int i = 0; i < 6 - temp.length(); i++)
304:                    s.append(' ');
305:                temp = UCharacter.getExtendedName(ch);
306:                if (temp == null)
307:                    temp = " ";
308:                s.append(temp);
309:                for (int i = 0; i < 73 - temp.length(); i++)
310:                    s.append(' ');
311:
312:                s.append(method);
313:                for (int i = 0; i < 27 - method.length(); i++)
314:                    s.append(' ');
315:                s.append(ucharval);
316:                for (int i = 0; i < 11 - ucharval.length(); i++)
317:                    s.append(' ');
318:                s.append(charval);
319:                f.println(s.toString());
320:            }
321:
322:            /**
323:             * Does up a summary of the differences
324:             * @param f file outputstream
325:             */
326:            private static void summary(PrintWriter f) {
327:                f.println("==================================================");
328:                f.println("Summary of differences");
329:                for (Enumeration e = m_hashtable_.keys(); e.hasMoreElements();) {
330:                    StringBuffer method = new StringBuffer((String) e
331:                            .nextElement());
332:                    int count = ((Integer) m_hashtable_.get(method.toString()))
333:                            .intValue();
334:                    for (int i = 30 - method.length(); i > 0; i--)
335:                        method.append(' ');
336:                    f.println(method + "  " + count);
337:                }
338:            }
339:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.