Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/share/classes/sun/text/SupplementaryCharacterData.java
41152 views
1
/*
2
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.text;
27
28
/**
29
* SupplementaryCharacterData is an SMI-private class which was written for
30
* RuleBasedBreakIterator and BreakDictionary.
31
*/
32
public final class SupplementaryCharacterData implements Cloneable {
33
34
/**
35
* A token used as a character-category value to identify ignore characters
36
*/
37
private static final byte IGNORE = -1;
38
39
/**
40
* An array for supplementary characters and values.
41
* Lower one byte is used to keep a byte-value.
42
* Upper three bytes are used to keep the first supplementary character
43
* which has the value. The value is also valid for the following
44
* supplementary characters until the next supplementary character in
45
* the array <code>dataTable</code>.
46
* For example, if the value of <code>dataTable[2]</code> is
47
* <code>0x01000123</code> and the value of <code>dataTable[3]</code> is
48
* <code>0x01000567</code>, supplementary characters from
49
* <code>0x10001</code> to <code>0x10004</code> has the value
50
* <code>0x23</code>. And, <code>getValue(0x10003)</code> returns the value.
51
*/
52
private int[] dataTable;
53
54
55
/**
56
* Creates a new SupplementaryCharacterData object with the given table.
57
*/
58
public SupplementaryCharacterData(int[] table) {
59
dataTable = table;
60
}
61
62
/**
63
* Returns a corresponding value for the given supplementary code-point.
64
*/
65
public int getValue(int index) {
66
// Index should be a valid supplementary character.
67
assert index >= Character.MIN_SUPPLEMENTARY_CODE_POINT &&
68
index <= Character.MAX_CODE_POINT :
69
"Invalid code point:" + Integer.toHexString(index);
70
71
int i = 0;
72
int j = dataTable.length - 1;
73
int k;
74
75
for (;;) {
76
k = (i + j) / 2;
77
78
int start = dataTable[k] >> 8;
79
int end = dataTable[k+1] >> 8;
80
81
if (index < start) {
82
j = k;
83
} else if (index > (end-1)) {
84
i = k;
85
} else {
86
int v = dataTable[k] & 0xFF;
87
return (v == 0xFF) ? IGNORE : v;
88
}
89
}
90
}
91
92
/**
93
* Returns the data array.
94
*/
95
public int[] getArray() {
96
return dataTable;
97
}
98
99
}
100
101