1 21 22 package org.apache.derbyTesting.functionTests.util.streams; 23 24 39 public class CharAlphabet { 40 41 42 public static char[] MODERNLATINLOWER = { 43 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 44 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' 45 }; 46 47 48 public static char[] NO_DK_LOWER = { 49 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 50 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 51 '\u00E6', '\u00F8', '\u00E5' 52 }; 53 54 55 public static char[] TAMIL = { 56 '\u0B85', '\u0B86', '\u0B87', '\u0B88', '\u0B89', '\u0B8A', 57 '\u0B8E', '\u0B8F', '\u0B90', '\u0B92', '\u0B93', '\u0B94', 58 '\u0B95', '\u0B99', '\u0B9A', '\u0B9C', '\u0B9E', '\u0B9F', 59 '\u0BA3', '\u0BA4', '\u0BA8', '\u0BA9', '\u0BAA', '\u0BAE', 60 '\u0BAF', '\u0BB0', '\u0BB1', '\u0BB2', '\u0BB3', '\u0BB4', 61 '\u0BB5', '\u0BB6', '\u0BB7', '\u0BB8', '\u0BB9', '\u0BBE', 62 '\u0BBF', '\u0BC0', '\u0BC1', '\u0BC2', '\u0BC6', '\u0BC7', 63 '\u0BC8', '\u0BCA', '\u0BCB', '\u0BCC' 64 }; 65 66 67 public static char[] CJKSUBSET = { 68 '\u4E00', '\u4E01', '\u4E02', '\u4E03', '\u4E04', '\u4E05', 69 '\u4E06', '\u4E07', '\u4E08', '\u4E09', '\u4E0A', '\u4E0B' 70 }; 71 72 75 public static CharAlphabet modernLatinLowercase() { 76 return new CharAlphabet("Modern latin lowercase", 77 CharAlphabet.MODERNLATINLOWER); 78 } 79 80 83 public static CharAlphabet cjkSubset() { 84 return new CharAlphabet("CJK subset", 85 CharAlphabet.CJKSUBSET); 86 } 87 88 89 private final String name; 90 91 private final char[] chars; 92 93 private final int charCount; 94 95 private int off = 0; 96 97 103 private CharAlphabet(String name, char[] chars) { 104 this.name = name; 105 this.chars = chars; 106 this.charCount = chars.length; 107 } 108 109 112 public String getName() { 113 return this.name; 114 } 115 116 119 public int charCount() { 120 return this.charCount; 121 } 122 123 128 public int nextCharAsInt() { 129 if (off >= charCount) { 130 off = 0; 131 } 132 return (int)chars[off++]; 133 } 134 135 140 public char nextChar() { 141 if (off >= charCount) { 142 off = 0; 143 } 144 return chars[off++]; 145 } 146 147 157 public int nextCharToRead(int charsRead) { 158 off = (off + (charsRead % charCount)) % charCount; 159 return off; 160 } 161 162 166 public void reset() { 167 off = 0; 168 } 169 } | Popular Tags |