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


001:        /**
002:         *******************************************************************************
003:         * Copyright (C) 2001-2002, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */package com.ibm.icu.impl;
007:
008:        import com.ibm.icu.util.VersionInfo;
009:
010:        public final class ICUDebug {
011:            private static String params;
012:            static {
013:                try {
014:                    params = System.getProperty("ICUDebug");
015:                } catch (SecurityException e) {
016:                }
017:            }
018:            private static boolean debug = params != null;
019:            private static boolean help = debug
020:                    && (params.equals("") || params.indexOf("help") != -1);
021:
022:            static {
023:                if (debug) {
024:                    System.out.println("\nICUDebug=" + params);
025:                }
026:            }
027:
028:            public static final String javaVersionString = System
029:                    .getProperty("java.version");
030:            public static final boolean isJDK14OrHigher;
031:            public static final VersionInfo javaVersion;
032:
033:            public static VersionInfo getInstanceLenient(String s) {
034:                // clean string
035:                // preserve only digits, separated by single '.' 
036:                // ignore over 4 digit sequences
037:                // does not test < 255, very odd...
038:
039:                char[] chars = s.toCharArray();
040:                int r = 0, w = 0, count = 0;
041:                boolean numeric = false; // ignore leading non-numerics
042:                while (r < chars.length) {
043:                    char c = chars[r++];
044:                    if (c < '0' || c > '9') {
045:                        if (numeric) {
046:                            if (count == 3) {
047:                                // only four digit strings allowed
048:                                break;
049:                            }
050:                            numeric = false;
051:                            chars[w++] = '.';
052:                            ++count;
053:                        }
054:                    } else {
055:                        numeric = true;
056:                        chars[w++] = c;
057:                    }
058:                }
059:                while (w > 0 && chars[w - 1] == '.') {
060:                    --w;
061:                }
062:
063:                String vs = new String(chars, 0, w);
064:
065:                return VersionInfo.getInstance(vs);
066:            }
067:
068:            static {
069:                javaVersion = getInstanceLenient(javaVersionString);
070:
071:                VersionInfo java14Version = VersionInfo.getInstance("1.4.0");
072:
073:                isJDK14OrHigher = javaVersion.compareTo(java14Version) >= 0;
074:            }
075:
076:            public static boolean enabled() {
077:                return debug;
078:            }
079:
080:            public static boolean enabled(String arg) {
081:                if (debug) {
082:                    boolean result = params.indexOf(arg) != -1;
083:                    if (help)
084:                        System.out.println("\nICUDebug.enabled(" + arg + ") = "
085:                                + result);
086:                    return result;
087:                }
088:                return false;
089:            }
090:
091:            public static String value(String arg) {
092:                String result = "false";
093:                if (debug) {
094:                    int index = params.indexOf(arg);
095:                    if (index != -1) {
096:                        index += arg.length();
097:                        if (params.length() > index
098:                                && params.charAt(index) == '=') {
099:                            index += 1;
100:                            int limit = params.indexOf(",", index);
101:                            result = params.substring(index,
102:                                    limit == -1 ? params.length() : limit);
103:                        } else {
104:                            result = "true";
105:                        }
106:                    }
107:
108:                    if (help)
109:                        System.out.println("\nICUDebug.value(" + arg + ") = "
110:                                + result);
111:                }
112:                return result;
113:            }
114:
115:            static public void main(String[] args) {
116:                // test
117:                String[] tests = { "1.3.0", "1.3.0_02", "1.3.1ea", "1.4.1b43",
118:                        "___41___5", "x1.4.51xx89ea.7f" };
119:                for (int i = 0; i < tests.length; ++i) {
120:                    System.out.println(tests[i] + " => "
121:                            + getInstanceLenient(tests[i]));
122:                }
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.