1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.text;
18
19/**
20 * AndroidCharacter exposes some character properties that used to be not
21 * easily accessed from java.lang.Character, but are now available in ICU.
22 * @deprecated Use various methods from {@link android.icu.lang.UCharacter}, instead.
23 */
24@Deprecated
25public class AndroidCharacter
26{
27    public static final int EAST_ASIAN_WIDTH_NEUTRAL = 0;
28    public static final int EAST_ASIAN_WIDTH_AMBIGUOUS = 1;
29    public static final int EAST_ASIAN_WIDTH_HALF_WIDTH = 2;
30    public static final int EAST_ASIAN_WIDTH_FULL_WIDTH = 3;
31    public static final int EAST_ASIAN_WIDTH_NARROW = 4;
32    public static final int EAST_ASIAN_WIDTH_WIDE = 5;
33
34    /**
35     * Fill in the first <code>count</code> bytes of <code>dest</code> with the
36     * directionalities from the first <code>count</code> chars of <code>src</code>.
37     * This is just like Character.getDirectionality() except it is a
38     * batch operation.
39     */
40    public native static void getDirectionalities(char[] src, byte[] dest,
41                                                  int count);
42
43    /**
44     * Calculate the East Asian Width of a character according to
45     * <a href="http://unicode.org/reports/tr11/">Unicode TR#11</a>. The return
46     * will be one of {@link #EAST_ASIAN_WIDTH_NEUTRAL},
47     * {@link #EAST_ASIAN_WIDTH_AMBIGUOUS}, {@link #EAST_ASIAN_WIDTH_HALF_WIDTH},
48     * {@link #EAST_ASIAN_WIDTH_FULL_WIDTH}, {@link #EAST_ASIAN_WIDTH_NARROW},
49     * or {@link #EAST_ASIAN_WIDTH_WIDE}.
50     *
51     * @param input the character to measure
52     * @return the East Asian Width for input
53     */
54    public native static int getEastAsianWidth(char input);
55
56    /**
57     * Fill the first <code>count</code> bytes of <code>dest</code> with the
58     * East Asian Width from <code>count</code> chars of <code>src</code>
59     * starting at <code>start</code>. East Asian Width is calculated based on
60     * <a href="http://unicode.org/reports/tr11/">Unicode TR#11</a>. Each entry
61     * in <code>dest</code> will be one of {@link #EAST_ASIAN_WIDTH_NEUTRAL},
62     * {@link #EAST_ASIAN_WIDTH_AMBIGUOUS}, {@link #EAST_ASIAN_WIDTH_HALF_WIDTH},
63     * {@link #EAST_ASIAN_WIDTH_FULL_WIDTH}, {@link #EAST_ASIAN_WIDTH_NARROW},
64     * or {@link #EAST_ASIAN_WIDTH_WIDE}.
65     *
66     * @param src character array of input to measure
67     * @param start first character in array to measure
68     * @param count maximum number of characters to measure
69     * @param dest byte array of results for each character in src
70     */
71    public native static void getEastAsianWidths(char[] src, int start,
72                                                 int count, byte[] dest);
73
74    /**
75     * Replace the specified slice of <code>text</code> with the chars'
76     * right-to-left mirrors (if any), returning true if any
77     * replacements were made.
78     *
79     * @param text array of characters to apply mirror operation
80     * @param start first character in array to mirror
81     * @param count maximum number of characters to mirror
82     * @return true if replacements were made
83     */
84    public native static boolean mirror(char[] text, int start, int count);
85
86    /**
87     * Return the right-to-left mirror (or the original char if none)
88     * of the specified char.
89     */
90    public native static char getMirror(char ch);
91}
92