Source Code Cross Referenced for CharAlphabet.java in  » Database-DBMS » db-derby-10.2 » org » apache » derbyTesting » functionTests » util » streams » 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 » Database DBMS » db derby 10.2 » org.apache.derbyTesting.functionTests.util.streams 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derbyTesting.functionTests.util.streams.CharAlphabet
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derbyTesting.functionTests.util.streams;
023:
024:        /**
025:         * A looping alphabet, returning characters.
026:         *
027:         * The alphabet loops over a list of characters. The alphabet-object is used
028:         * by looping readers, which in turn is used for testing methods requiring
029:         * streaming inputs.
030:         *
031:         * The following alphabets have been defined:
032:         * <ul><li><em>Modern latin, lowercase</em> ; letters a - z (26)
033:         *     <li><em>Norwegian/Danish, lowercase</em> ; letters a - z, plus three
034:         *         additional letters (29)
035:         *     <li><em>Tamil</em> ; 46 Tamil letters from UNICODE U0B80
036:         *     <li><em>CJK subset</em> ; 12 letter from UNICODE CJK U4E00 
037:         * </ul>
038:         */
039:        public class CharAlphabet {
040:
041:            /** Modern latin, lowercase; a - z, 26 letters */
042:            public static char[] MODERNLATINLOWER = { 'a', 'b', 'c', 'd', 'e',
043:                    'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
044:                    'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
045:
046:            /** Norwegian/Danish alphabet, lowercase; 29 letters */
047:            public static char[] NO_DK_LOWER = { 'a', 'b', 'c', 'd', 'e', 'f',
048:                    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
049:                    's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\u00E6', '\u00F8',
050:                    '\u00E5' };
051:
052:            /** Subset of Tamil alphabet; 46 letters, UNICODE U0B80 */
053:            public static char[] TAMIL = { '\u0B85', '\u0B86', '\u0B87',
054:                    '\u0B88', '\u0B89', '\u0B8A', '\u0B8E', '\u0B8F', '\u0B90',
055:                    '\u0B92', '\u0B93', '\u0B94', '\u0B95', '\u0B99', '\u0B9A',
056:                    '\u0B9C', '\u0B9E', '\u0B9F', '\u0BA3', '\u0BA4', '\u0BA8',
057:                    '\u0BA9', '\u0BAA', '\u0BAE', '\u0BAF', '\u0BB0', '\u0BB1',
058:                    '\u0BB2', '\u0BB3', '\u0BB4', '\u0BB5', '\u0BB6', '\u0BB7',
059:                    '\u0BB8', '\u0BB9', '\u0BBE', '\u0BBF', '\u0BC0', '\u0BC1',
060:                    '\u0BC2', '\u0BC6', '\u0BC7', '\u0BC8', '\u0BCA', '\u0BCB',
061:                    '\u0BCC' };
062:
063:            /** CJK subset; 12 letters, UNICODE U4E00 */
064:            public static char[] CJKSUBSET = { '\u4E00', '\u4E01', '\u4E02',
065:                    '\u4E03', '\u4E04', '\u4E05', '\u4E06', '\u4E07', '\u4E08',
066:                    '\u4E09', '\u4E0A', '\u4E0B' };
067:
068:            /**
069:             * Get a modern latin lowercase alphabet.
070:             */
071:            public static CharAlphabet modernLatinLowercase() {
072:                return new CharAlphabet("Modern latin lowercase",
073:                        CharAlphabet.MODERNLATINLOWER);
074:            }
075:
076:            /**
077:             * Get a CJK subset alphabet.
078:             */
079:            public static CharAlphabet cjkSubset() {
080:                return new CharAlphabet("CJK subset", CharAlphabet.CJKSUBSET);
081:            }
082:
083:            /** Name of the alphabet. */
084:            private final String name;
085:            /** Characters in the alphabet. */
086:            private final char[] chars;
087:            /** Number of characters in the alphabet. */
088:            private final int charCount;
089:            /** Current offset into the alphabet/character array. */
090:            private int off = 0;
091:
092:            /**
093:             * Create an alphabet with the given name and characters.
094:             *
095:             * @param name name of the alphabet
096:             * @param chars characters in the alphabet.
097:             */
098:            private CharAlphabet(String name, char[] chars) {
099:                this .name = name;
100:                this .chars = chars;
101:                this .charCount = chars.length;
102:            }
103:
104:            /**
105:             * Return the name of the alphabet.
106:             */
107:            public String getName() {
108:                return this .name;
109:            }
110:
111:            /**
112:             * Return the number of characters in the alphabet.
113:             */
114:            public int charCount() {
115:                return this .charCount;
116:            }
117:
118:            /**
119:             * Return the next char as an <code>integer</code>.
120:             *
121:             * @return the next character in the alphabet as an <code>integer</code>
122:             */
123:            public int nextCharAsInt() {
124:                if (off >= charCount) {
125:                    off = 0;
126:                }
127:                return (int) chars[off++];
128:            }
129:
130:            /**
131:             * Return the next char.
132:             *
133:             * @return the next character in the alphabet
134:             */
135:            public char nextChar() {
136:                if (off >= charCount) {
137:                    off = 0;
138:                }
139:                return chars[off++];
140:            }
141:
142:            /**
143:             * Compute the next character to read after reading the specified number
144:             * of characters. 
145:             *
146:             * Besides from returning the index, the internal state of
147:             * the alphabet is updated.
148:             *
149:             * @param charsRead the number of characters read
150:             * @return the index of the next character
151:             */
152:            public int nextCharToRead(int charsRead) {
153:                off = (off + (charsRead % charCount)) % charCount;
154:                return off;
155:            }
156:
157:            /**
158:             * Reset the alphabet, the next character returned will be the first
159:             * character in the alphabet.
160:             */
161:            public void reset() {
162:                off = 0;
163:            }
164:        } // Enc class CharAlphabet
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.