0N/A/*
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.text;
0N/A
0N/A/**
0N/A * SupplementaryCharacterData is an SMI-private class which was written for
0N/A * RuleBasedBreakIterator and BreakDictionary.
0N/A */
0N/Apublic final class SupplementaryCharacterData implements Cloneable {
0N/A
0N/A /**
0N/A * An array for supplementary characters and values.
0N/A * Lower one byte is used to keep a byte-value.
0N/A * Upper three bytes are used to keep the first supplementary character
0N/A * which has the value. The value is also valid for the following
0N/A * supplementary characters until the next supplementary character in
0N/A * the array <code>dataTable</code>.
0N/A * For example, if the value of <code>dataTable[2]</code> is
0N/A * <code>0x01000123</code> and the value of <code>dataTable[3]</code> is
0N/A * <code>0x01000567</code>, supplementary characters from
0N/A * <code>0x10001</code> to <code>0x10004</code> has the value
0N/A * <code>0x23</code>. And, <code>getValue(0x10003)</code> returns the value.
0N/A */
0N/A private int[] dataTable;
0N/A
0N/A
0N/A /**
0N/A * Creates a new SupplementaryCharacterData object with the given table.
0N/A */
0N/A public SupplementaryCharacterData(int[] table) {
0N/A dataTable = table;
0N/A }
0N/A
0N/A /**
0N/A * Returns a corresponding value for the given supplementary code-point.
0N/A */
0N/A public int getValue(int index) {
0N/A // Index should be a valid supplementary character.
0N/A assert index >= Character.MIN_SUPPLEMENTARY_CODE_POINT &&
0N/A index <= Character.MAX_CODE_POINT :
0N/A "Invalid code point:" + Integer.toHexString(index);
0N/A
0N/A int i = 0;
0N/A int j = dataTable.length - 1;
0N/A int k;
0N/A
0N/A for (;;) {
0N/A k = (i + j) / 2;
0N/A
0N/A int start = dataTable[k] >> 8;
0N/A int end = dataTable[k+1] >> 8;
0N/A
0N/A if (index < start) {
0N/A j = k;
0N/A } else if (index > (end-1)) {
0N/A i = k;
0N/A } else {
0N/A return dataTable[k] & 0xFF;
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns the data array.
0N/A */
0N/A public int[] getArray() {
0N/A return dataTable;
0N/A }
0N/A
0N/A}