Source Code Cross Referenced for CharModule.java in  » Web-Framework » anvil » anvil » core » util » 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 » Web Framework » anvil » anvil.core.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: CharModule.java,v 1.10 2002/09/16 08:05:03 jkl Exp $
003:         *
004:         * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
005:         *
006:         * Use is subject to license terms, as defined in
007:         * Anvil Sofware License, Version 1.1. See LICENSE 
008:         * file, or http://njet.org/license-1.1.txt
009:         */
010:        package anvil.core.util;
011:
012:        import anvil.core.Any;
013:
014:        /// @module anvil.char 
015:        /// Set of functions for checking whether given string falls into
016:        /// certain character class. These checks are locale-specific.
017:
018:        /**
019:         * class CharModule
020:         *
021:         * @author: Jani Lehtimäki
022:         */
023:        public class CharModule {
024:
025:            public static final Any UNASSIGNED = Any
026:                    .create(Character.UNASSIGNED);
027:            public static final Any UPPERCASE_LETTER = Any
028:                    .create(Character.UPPERCASE_LETTER);
029:            public static final Any LOWERCASE_LETTER = Any
030:                    .create(Character.LOWERCASE_LETTER);
031:            public static final Any TITLECASE_LETTER = Any
032:                    .create(Character.TITLECASE_LETTER);
033:            public static final Any MODIFIER_LETTER = Any
034:                    .create(Character.MODIFIER_LETTER);
035:            public static final Any OTHER_LETTER = Any
036:                    .create(Character.OTHER_LETTER);
037:            public static final Any NON_SPACING_MARK = Any
038:                    .create(Character.NON_SPACING_MARK);
039:            public static final Any ENCLOSING_MARK = Any
040:                    .create(Character.ENCLOSING_MARK);
041:            public static final Any COMBINING_SPACING_MARK = Any
042:                    .create(Character.COMBINING_SPACING_MARK);
043:            public static final Any DECIMAL_DIGIT_NUMBER = Any
044:                    .create(Character.DECIMAL_DIGIT_NUMBER);
045:            public static final Any LETTER_NUMBER = Any
046:                    .create(Character.LETTER_NUMBER);
047:            public static final Any OTHER_NUMBER = Any
048:                    .create(Character.OTHER_NUMBER);
049:            public static final Any SPACE_SEPARATOR = Any
050:                    .create(Character.SPACE_SEPARATOR);
051:            public static final Any LINE_SEPARATOR = Any
052:                    .create(Character.LINE_SEPARATOR);
053:            public static final Any PARAGRAPH_SEPARATOR = Any
054:                    .create(Character.PARAGRAPH_SEPARATOR);
055:            public static final Any CONTROL = Any.create(Character.CONTROL);
056:            public static final Any FORMAT = Any.create(Character.FORMAT);
057:            public static final Any PRIVATE_USE = Any
058:                    .create(Character.PRIVATE_USE);
059:            public static final Any SURROGATE = Any.create(Character.SURROGATE);
060:            public static final Any DASH_PUNCTUATION = Any
061:                    .create(Character.DASH_PUNCTUATION);
062:            public static final Any START_PUNCTUATION = Any
063:                    .create(Character.START_PUNCTUATION);
064:            public static final Any END_PUNCTUATION = Any
065:                    .create(Character.END_PUNCTUATION);
066:            public static final Any CONNECTOR_PUNCTUATION = Any
067:                    .create(Character.CONNECTOR_PUNCTUATION);
068:            public static final Any OTHER_PUNCTUATION = Any
069:                    .create(Character.OTHER_PUNCTUATION);
070:            public static final Any MATH_SYMBOL = Any
071:                    .create(Character.MATH_SYMBOL);
072:            public static final Any CURRENCY_SYMBOL = Any
073:                    .create(Character.CURRENCY_SYMBOL);
074:            public static final Any MODIFIER_SYMBOL = Any
075:                    .create(Character.MODIFIER_SYMBOL);
076:            public static final Any OTHER_SYMBOL = Any
077:                    .create(Character.OTHER_SYMBOL);
078:
079:            /// @function getType
080:            /// Returns the characters class of given parameter.
081:            /// Character class is one of the constants declared in this library.
082:            /// @synopsis int getType(string char)
083:            /// @synopsis int getType(int charcode)
084:            public static final Any getType(Any value) {
085:                if (value.isInt()) {
086:                    return Any.create(Character.getType((char) value.toInt()));
087:                } else {
088:                    String str = value.toString();
089:                    if (str.length() > 0) {
090:                        return Any.create(Character.getType(str.charAt(0)));
091:                    } else {
092:                        return UNASSIGNED;
093:                    }
094:                }
095:            }
096:
097:            /// @function isDigit
098:            /// Tests if whole string consists of digits.
099:            /// @synopsis boolean isDigit(string str)
100:            public static final Any isDigit(String str) {
101:                int n = str.length();
102:                for (int i = 0; i < n; i++) {
103:                    if (!Character.isDigit(str.charAt(i))) {
104:                        return Any.FALSE;
105:                    }
106:                }
107:                return Any.TRUE;
108:            }
109:
110:            /// @function isLetter
111:            /// Tests if whole string consists of letters.
112:            /// @synopsis boolean isLetter(string str)
113:            public static final Any isLetter(String str) {
114:                int n = str.length();
115:                for (int i = 0; i < n; i++) {
116:                    if (!Character.isLetter(str.charAt(i))) {
117:                        return Any.FALSE;
118:                    }
119:                }
120:                return Any.TRUE;
121:            }
122:
123:            /// @function isLetterOrDigit
124:            /// Tests if whole string consists of letters or digits.
125:            /// @synopsis boolean isLetterOrDigit(string str)
126:            public static final Any isLetterOrDigit(String str) {
127:                int n = str.length();
128:                for (int i = 0; i < n; i++) {
129:                    if (!Character.isLetterOrDigit(str.charAt(i))) {
130:                        return Any.FALSE;
131:                    }
132:                }
133:                return Any.TRUE;
134:            }
135:
136:            /// @function isLowerCase
137:            /// Tests if whole string consists of lowercase characters. 
138:            /// @synopsis boolean isLowerCase(string str)
139:            public static final Any isLowerCase(String str) {
140:                int n = str.length();
141:                for (int i = 0; i < n; i++) {
142:                    if (!Character.isLowerCase(str.charAt(i))) {
143:                        return Any.FALSE;
144:                    }
145:                }
146:                return Any.TRUE;
147:            }
148:
149:            /// @function isUpperCase
150:            /// Tests if whole string consists of uppercase characters. 
151:            /// @synopsis boolean isUpperCase(string str)
152:            public static final Any isUpperCase(String str) {
153:                int n = str.length();
154:                for (int i = 0; i < n; i++) {
155:                    if (!Character.isLowerCase(str.charAt(i))) {
156:                        return Any.FALSE;
157:                    }
158:                }
159:                return Any.TRUE;
160:            }
161:
162:            /// @function isSpace
163:            /// Tests if whole string consists of space characters. 
164:            /// @synopsis boolean isSpace(string str)
165:            public static final Any isSpace(String str) {
166:                int n = str.length();
167:                for (int i = 0; i < n; i++) {
168:                    if (!Character.isSpaceChar(str.charAt(i))) {
169:                        return Any.FALSE;
170:                    }
171:                }
172:                return Any.TRUE;
173:            }
174:
175:            public static final anvil.script.compiler.NativeNamespace __module__ = new anvil.script.compiler.NativeNamespace(
176:                    "char", CharModule.class,
177:                    new Class[] {},
178:                    //DOC{{
179:                    ""
180:                            + " @module anvil.char \n"
181:                            + " Set of functions for checking whether given string falls into\n"
182:                            + " certain character class. These checks are locale-specific.\n"
183:                            + " @function getType\n"
184:                            + " Returns the characters class of given parameter.\n"
185:                            + " Character class is one of the constants declared in this library.\n"
186:                            + " @synopsis int getType(string char)\n"
187:                            + " @synopsis int getType(int charcode)\n"
188:                            + " @function isDigit\n"
189:                            + " Tests if whole string consists of digits.\n"
190:                            + " @synopsis boolean isDigit(string str)\n"
191:                            + " @function isLetter\n"
192:                            + " Tests if whole string consists of letters.\n"
193:                            + " @synopsis boolean isLetter(string str)\n"
194:                            + " @function isLetterOrDigit\n"
195:                            + " Tests if whole string consists of letters or digits.\n"
196:                            + " @synopsis boolean isLetterOrDigit(string str)\n"
197:                            + " @function isLowerCase\n"
198:                            + " Tests if whole string consists of lowercase characters. \n"
199:                            + " @synopsis boolean isLowerCase(string str)\n"
200:                            + " @function isUpperCase\n"
201:                            + " Tests if whole string consists of uppercase characters. \n"
202:                            + " @synopsis boolean isUpperCase(string str)\n"
203:                            + " @function isSpace\n"
204:                            + " Tests if whole string consists of space characters. \n"
205:                            + " @synopsis boolean isSpace(string str)\n"
206:            //}}DOC
207:            );
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.