• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package org.apache.harmony.text;
19 
20 /**
21  * Dalvik Bidi wrapper. Derived from an old version of Harmony; today they call
22  * straight through to ICU4J.
23  */
24 
25 public final class BidiWrapper {
26 
27     public static final int UBIDI_DEFAULT_LTR = 0xfe;
28 
29     public static final int UBIDI_DEFAULT_RTL = 0xff;
30 
31     public static final int UBIDI_MAX_EXPLICIT_LEVEL = 61;
32 
33     public static final int UBIDI_LEVEL_OVERRIDE = 0x80;
34 
35     public static final int UBIDI_KEEP_BASE_COMBINING = 1;
36 
37     public static final int UBIDI_DO_MIRRORING = 2;
38 
39     public static final int UBIDI_INSERT_LRM_FOR_NUMERIC = 4;
40 
41     public static final int UBIDI_REMOVE_BIDI_CONTROLS = 8;
42 
43     public static final int UBIDI_OUTPUT_REVERSE = 16;
44 
45     public static final int UBiDiDirection_UBIDI_LTR = 0;
46 
47     public static final int UBiDiDirection_UBIDI_RTL = 1;
48 
49     public static final int UBiDiDirection_UBIDI_MIXED = 2;
50 
51     // Allocate a UBiDi structure.
ubidi_open()52     public static native long ubidi_open();
53 
54     // ubidi_close() must be called to free the memory associated with a
55     // UBiDi object.
ubidi_close(long pBiDi)56     public static native void ubidi_close(long pBiDi);
57 
58     // Perform the Unicode BiDi algorithm.
ubidi_setPara(long pBiDi, char[] text, int length, byte paraLevel, byte[] embeddingLevels)59     public static native void ubidi_setPara(long pBiDi, char[] text,
60             int length, byte paraLevel, byte[] embeddingLevels);
61 
62     // ubidi_setLine() sets a UBiDi to contain the reordering information,
63     // especially the resolved levels, for all the characters in a line of
64     // text.
ubidi_setLine(final long pParaBiDi, int start, int limit)65     public static native long ubidi_setLine(final long pParaBiDi, int start,
66             int limit);
67 
68     // Get the directionality of the text.
ubidi_getDirection(final long pBiDi)69     public static native int ubidi_getDirection(final long pBiDi);
70 
71     // Get the length of the text.
ubidi_getLength(final long pBiDi)72     public static native int ubidi_getLength(final long pBiDi);
73 
74     // Get the paragraph level of the text.
ubidi_getParaLevel(final long pBiDi)75     public static native byte ubidi_getParaLevel(final long pBiDi);
76 
77     // Get an array of levels for each character.
ubidi_getLevels(long pBiDi)78     public static native byte[] ubidi_getLevels(long pBiDi);
79 
80     // Get the number of runs.
ubidi_countRuns(long pBiDi)81     public static native int ubidi_countRuns(long pBiDi);
82 
83     // Get the BidiRuns
ubidi_getRuns(long pBidi)84     public static native BidiRun[] ubidi_getRuns(long pBidi);
85 
86     // This is a convenience function that does not use a UBiDi object
ubidi_reorderVisual(byte[] levels, int length)87     public static native int[] ubidi_reorderVisual(byte[] levels, int length);
88 }
89