/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* (C) Copyright IBM Corp. 1999-2000 - All Rights Reserved
*
* The original version of this source code and documentation is
* copyrighted and owned by IBM. These materials are provided
* under terms of a License Agreement between IBM and Sun.
* This technology is protected by multiple US and International
* patents. This notice and attribution to IBM may not be removed.
*/
public final class BidiUtils {
/**
* Return the level of each character into the levels array starting at start.
* This is a convenience method for clients who prefer to use an explicit levels
* array instead of iterating over the runs.
*
* @param levels the array to receive the character levels
* @param start the starting offset into the the array
* @throws IndexOutOfBoundsException if <code>start</code> is less than 0 or
* <code>start + getLength()</code> is greater than <code>levels.length</code>.
*/
}
int p = start;
for (int i = 0; i < runCount; ++i) {
while (p < rlimit) {
}
}
}
/**
* Return an array containing the resolved bidi level of each character, in logical order.
* @return an array containing the level of each character, in logical order.
*/
return levels;
}
/**
* Given level data, compute a a visual to logical mapping.
* The leftmost (or topmost) character is at visual index zero. The
* logical index of the character is derived from the visual index
* by the expression <code>li = map[vi];</code>.
* @param levels the levels array
* @return the mapping array from visual to logical
*/
byte highestLevel = 0;
// initialize mapping and levels
for (int i = 0; i < len; i++) {
mapping[i] = i;
if (level > highestLevel) {
}
}
}
while (highestLevel >= lowestOddLevel) {
int i = 0;
for (;;) {
i++;
}
int begin = i++;
break; // no more runs at this level
}
i++;
}
int end = i - 1;
++begin;
--end;
}
}
--highestLevel;
}
return mapping;
}
/**
* Return the inverse position map. The source array must map one-to-one (each value
* is distinct and the values run from zero to the length of the array minus one).
* For example, if <code>values[i] = j</code>, then <code>inverse[j] = i</code>.
* @param values the source ordering array
* @return the inverse array
*/
return null;
}
}
return result;
}
/**
* Return an array containing contiguous values from 0 to length
* having the same ordering as the source array. If this would be
* a canonical ltr ordering, return null. The data in values[] is NOT
* required to be a permutation, but elements in values are required
* to be distinct.
* @param values an array containing the discontiguous values
* @return the contiguous values
*/
}
return null;
}
/**
* Compute a contiguous order for the range start, limit.
*/
int limit) {
}
// now we'll sort result[], with the following comparison:
// result[i] lessthan result[j] iff values[result[i]] < values[result[j]]
// selection sort for now; use more elaborate sorts if desired
int minIndex = i;
minIndex = j;
}
}
}
// shift result by start:
if (start != 0) {
}
}
// next, check for canonical order:
int k;
if (result[k] != k) {
break;
}
}
return null;
}
// now return inverse of result:
return createInverseMap(result);
}
/**
* Return an array containing the data in the values array from start up to limit,
* normalized to fall within the range from 0 up to limit - start.
* If this would be a canonical ltr ordering, return null.
* NOTE: This method assumes that values[] is a logical to visual map
* generated from levels[].
* @param values the source mapping
* @param levels the levels corresponding to the values
* @param start the starting offset in the values and levels arrays
* @param limit the limiting offset in the values and levels arrays
* @return the normlized map
*/
// levels optimization
byte primaryLevel;
primaryLevel = (byte) 0x0;
copyRange = true;
canonical = true;
}
else {
// scan for levels below primary
int i;
if (levels[i] < primaryLevel) {
break;
}
if (canonical) {
}
}
}
else {
copyRange = false;
// these don't matter; but the compiler cares:
primaryLevel = (byte) 0x0;
canonical = false;
}
}
if (copyRange) {
if (canonical) {
return null;
}
int baseValue;
} else {
}
if (baseValue == 0) {
}
else {
}
}
return result;
}
else {
}
}
else {
return values;
}
}
return null;
}
/**
* Reorder the objects in the array into visual order based on their levels.
* This is a utility function to use when you have a collection of objects
* representing runs of text in logical order, each run containing text
* at a single level. The elements in the objects array will be reordered
* into visual order assuming each run of text has the level provided
* by the corresponding element in the levels array.
* @param levels an array representing the bidi level of each object
* @param objects the array of objects to be reordered into visual order
*/
byte highestLevel = 0;
// initialize mapping and levels
for (int i = 0; i < len; i++) {
if (level > highestLevel) {
}
}
}
while (highestLevel >= lowestOddLevel) {
int i = 0;
for (;;) {
i++;
}
int begin = i++;
break; // no more runs at this level
}
i++;
}
int end = i - 1;
++begin;
--end;
}
}
--highestLevel;
}
}
}