Top Description Fields Constructors Methods
com.ibm.icu.text

public final Class ArabicShaping

extends Object
Class Inheritance
Imports
com.ibm.icu.impl.UBiDiProps, com.ibm.icu.lang.UCharacterDirection

Shape Arabic text on a character basis.

ArabicShaping performs basic operations for "shaping" Arabic text. It is most useful for use with legacy data formats and legacy display technology (simple terminals). All operations are performed on Unicode characters.

Text-based shaping means that some character code points in the text are replaced by others depending on the context. It transforms one kind of text into another. In comparison, modern displays for Arabic text select appropriate, context-dependent font glyphs for each text element, which means that they transform text into a glyph vector.

Text transformations are necessary when modern display technology is not available or when text needs to be transformed to or from legacy formats that use "shaped" characters. Since the Arabic script is cursive, connecting adjacent letters to each other, computers select images for each letter based on the surrounding letters. This usually results in four images per Arabic letter: initial, middle, final, and isolated forms. In Unicode, on the other hand, letters are normally stored abstract, and a display system is expected to select the necessary glyphs. (This makes searching and other text processing easier because the same letter has only one code.) It is possible to mimic this with text transformations because there are characters in Unicode that are rendered as letters with a specific shape (or cursive connectivity). They were included for interoperability with legacy systems and codepages, and for unsophisticated display systems.

A second kind of text transformations is supported for Arabic digits: For compatibility with legacy codepages that only include European digits, it is possible to replace one set of digits by another, changing the character code points. These operations can be performed for either Arabic-Indic Digits (U+0660...U+0669) or Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).

Some replacements may result in more or fewer characters (code points). By default, this means that the destination buffer may receive text with a length different from the source length. Some legacy systems rely on the length of the text to be constant. They expect extra spaces to be added or consumed either next to the affected character or at the end of the text.

ICU Status
Stable since ICU 2.0.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int[]
private static int[]
private static final char[]
private static final int
public static final int
DIGIT_TYPE_AN

Digit type option: Use Arabic-Indic digits (U+0660...U+0669).

public static final int
DIGIT_TYPE_AN_EXTENDED

Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).

public static final int
DIGIT_TYPE_MASK

Bit mask for digit type options.

public static final int
DIGITS_AN2EN

Digit shaping option: Replace Arabic-Indic digits by European digits (U+0030...U+0039).

public static final int
DIGITS_EN2AN

Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits.

public static final int
DIGITS_EN2AN_INIT_AL

Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC).

public static final int
DIGITS_EN2AN_INIT_LR

Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC).

public static final int
DIGITS_MASK

Bit mask for digit shaping options.

public static final int
DIGITS_NOOP

Digit shaping option: do not perform digit shaping.

private static final char
private static final char
HAMZAFE_CHAR

some constants

private static final int
private static final int[]
private boolean
private static final char
public static final int
LAMALEF_AUTO

Memory option: the result must have the same length as the source.

public static final int
LAMALEF_BEGIN

Memory option: the result must have the same length as the source.

public static final int
LAMALEF_END

Memory option: the result must have the same length as the source.

public static final int
LAMALEF_MASK

Bit mask for LamAlef memory options.

public static final int
LAMALEF_NEAR

Memory option: the result must have the same length as the source.

public static final int
LAMALEF_RESIZE

Memory option: allow the result to have a different length than the source.

private static final char
private static final int
public static final int
LENGTH_FIXED_SPACES_AT_BEGINNING

Memory option: the result must have the same length as the source.

public static final int
LENGTH_FIXED_SPACES_AT_END

Memory option: the result must have the same length as the source.

public static final int
LENGTH_FIXED_SPACES_NEAR

Memory option: the result must have the same length as the source.

public static final int
LENGTH_GROW_SHRINK

Memory option: allow the result to have a different length than the source.

public static final int
LENGTH_MASK

Bit mask for memory options.

public static final int
LETTERS_MASK

Bit mask for letter shaping options.

public static final int
LETTERS_NOOP

Letter shaping option: do not perform letter shaping.

public static final int
LETTERS_SHAPE

Letter shaping option: replace normative letter characters in the U+0600 (Arabic) block, by shaped ones in the U+FE70 (Presentation Forms B) block.

public static final int
LETTERS_SHAPE_TASHKEEL_ISOLATED

Letter shaping option: replace normative letter characters in the U+0600 (Arabic) block, except for the TASHKEEL characters at U+064B...U+0652, by shaped ones in the U+Fe70 (Presentation Forms B) block.

public static final int
LETTERS_UNSHAPE

Letter shaping option: replace shaped letter characters in the U+FE70 (Presentation Forms B) block by normative ones in the U+0600 (Arabic) block.

private static final int
private static final int
private static final char
private static final char
private final int
private static final int[]
public static final int
SEEN_MASK

Bit mask for Seen memory options.

public static final int
SEEN_TWOCELL_NEAR

Memory option: the result must have the same length as the source.

private static final char
private static final char
private static final char
private static final int
public static final int
SHAPE_TAIL_NEW_UNICODE

If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73).

public static final int
SHAPE_TAIL_TYPE_MASK

Bit mask for new Unicode Tail option

private static final int[][][]
private static final char
public static final int
SPACES_RELATIVE_TO_TEXT_BEGIN_END

This option effects the meaning of BEGIN and END options.

public static final int
SPACES_RELATIVE_TO_TEXT_MASK

Bit mask for swapping BEGIN and END for Visual LTR text

private boolean
private char
private static final int[]
public static final int
TASHKEEL_BEGIN

Memory option: the result must have the same length as the source.

public static final int
TASHKEEL_END

Memory option: the result must have the same length as the source.

public static final int
TASHKEEL_MASK

Bit mask for Tashkeel replacement with Space or Tatweel memory options.

public static final int
TASHKEEL_REPLACE_BY_TATWEEL

Memory option: the result must have the same length as the source.

public static final int
TASHKEEL_RESIZE

Memory option: allow the result to have a different length than the source.

private static final char
private static final int[]
private static final char
public static final int
TEXT_DIRECTION_LOGICAL

Direction indicator: the source is in logical (keyboard) order.

public static final int
TEXT_DIRECTION_MASK

Bit mask for direction indicators.

public static final int
TEXT_DIRECTION_VISUAL_LTR

Direction indicator: the source is in visual (display) order, that is, the leftmost displayed character is stored first.

public static final int
TEXT_DIRECTION_VISUAL_RTL

Direction indicator:the source is in visual RTL order, the rightmost displayed character stored first.

private static final char
private static final char
public static final int
YEHHAMZA_MASK

Bit mask for YehHamza memory options.

public static final int
YEHHAMZA_TWOCELL_NEAR

Memory option: the result must have the same length as the source.

private static final char[]

Constructor Summary

AccessConstructor and Description
public
ArabicShaping(int options)

Construct ArabicShaping using the options flags.

Method Summary

Modifier and TypeMethod and Description
private int
calculateSize(char[] source, int sourceStart, int sourceLength)

private static char
changeLamAlef(char ch)

private static int
countSpacesLeft(char[] dest, int start, int count)

private static int
countSpacesRight(char[] dest, int start, int count)

private static int
countSpaceSub(char[] dest, int length, char subChar)

private int
deshapeNormalize(char[] dest, int start, int length)

private int
deShapeUnicode(char[] dest, int start, int length, int destSize)

public boolean
equals(Object
the reference object with which to compare.
rhs
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
private int
expandCompositChar(char[] dest, int start, int length, int lacount, int shapingMode)

private boolean
expandCompositCharAtBegin(char[] dest, int start, int length, int lacount)

private boolean
expandCompositCharAtEnd(char[] dest, int start, int length, int lacount)

private boolean
expandCompositCharAtNear(char[] dest, int start, int length, int yehHamzaOption, int seenTailOption, int lamAlefOption)

private static int
flipArray(char[] dest, int start, int e, int w)

private int
handleGeneratedSpaces(char[] dest, int start, int length)

private static int
handleTashkeelWithTatweel(char[] dest, int sourceLength)

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private int
internalShape(char[] source, int sourceStart, int sourceLength, char[] dest, int destStart, int destSize)

private static void
invertBuffer(char[] buffer, int start, int length)

private static boolean
isAlefChar(char ch)

private static boolean
private static int
private static boolean
isLamAlefChar(char ch)

private static boolean
private static int
private static int
private static boolean
isTailChar(char ch)

private static boolean
isTashkeelChar(char ch)

private static boolean
private static int
private static boolean
isYehHamzaChar(char ch)

private int
normalize(char[] dest, int start, int length)

public int

Returns:

The number of chars written to the destination buffer. If an error occurs, then no output was written, or it may be incomplete.
shape
(char[]
An array containing the input text
source
,
int
The start of the range of text to convert
sourceStart
,
int
The length of the range of text to convert
sourceLength
,
char[]
The destination array that will receive the result. It may be NULL only if destSize is 0.
dest
,
int
The start of the range of the destination buffer to use.
destStart
,
int
The size (capacity) of the destination buffer. If destSize is 0, then no output is produced, but the necessary buffer size is returned ("preflighting"). This does not validate the text against the options, for example, if letters are being unshaped, and spaces are being consumed following lamalef, this will not detect a lamalef without a corresponding space. An error will be thrown when the actual conversion is attempted.
destSize
)

Convert a range of text in the source array, putting the result into a range of text in the destination array, and return the number of characters written.

public void
shape(char[]
An array containing the input text
source
,
int
The start of the range of text to convert
start
,
int
The length of the range of text to convert
length
)

Convert a range of text in place.

public String

Returns:

the converted string
shape
(String
the string to convert
text
)

Convert a string, returning the new string.

private void
shapeToArabicDigitsWithContext(char[] dest, int start, int length, char digitBase, boolean lastStrongWasAL)

private int
shapeUnicode(char[] dest, int start, int length, int destSize, int tashkeelFlag)

private static void
shiftArray(char[] dest, int start, int e, char subChar)

private static int
specialChar(char ch)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ALEFTYPEback to summary
private static final int ALEFTYPE
convertFEto06back to summary
private static int[] convertFEto06
convertNormalizedLamAlefback to summary
private static final char[] convertNormalizedLamAlef
DESHAPE_MODEback to summary
private static final int DESHAPE_MODE
DIGIT_TYPE_ANback to summary
public static final int DIGIT_TYPE_AN

Digit type option: Use Arabic-Indic digits (U+0660...U+0669).

ICU Status
Stable since ICU 2.0.
DIGIT_TYPE_AN_EXTENDEDback to summary
public static final int DIGIT_TYPE_AN_EXTENDED

Digit type option: Use Eastern (Extended) Arabic-Indic digits (U+06f0...U+06f9).

ICU Status
Stable since ICU 2.0.
DIGIT_TYPE_MASKback to summary
public static final int DIGIT_TYPE_MASK

Bit mask for digit type options.

ICU Status
Stable since ICU 2.0.
DIGITS_AN2ENback to summary
public static final int DIGITS_AN2EN

Digit shaping option: Replace Arabic-Indic digits by European digits (U+0030...U+0039).

ICU Status
Stable since ICU 2.0.
DIGITS_EN2ANback to summary
public static final int DIGITS_EN2AN

Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits.

ICU Status
Stable since ICU 2.0.
DIGITS_EN2AN_INIT_ALback to summary
public static final int DIGITS_EN2AN_INIT_AL

Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC). The initial state at the start of the text is assumed to be an Arabic, letter, so European digits at the start of the text will change. Compare to DIGITS_ALEN2AN_INT_LR.

ICU Status
Stable since ICU 2.0.
DIGITS_EN2AN_INIT_LRback to summary
public static final int DIGITS_EN2AN_INIT_LR

Digit shaping option: Replace European digits (U+0030...U+0039) by Arabic-Indic digits if the most recent strongly directional character is an Arabic letter (its Bidi direction value is RIGHT_TO_LEFT_ARABIC). The initial state at the start of the text is assumed to be not an Arabic, letter, so European digits at the start of the text will not change. Compare to DIGITS_ALEN2AN_INIT_AL.

ICU Status
Stable since ICU 2.0.
DIGITS_MASKback to summary
public static final int DIGITS_MASK

Bit mask for digit shaping options.

ICU Status
Stable since ICU 2.0.
DIGITS_NOOPback to summary
public static final int DIGITS_NOOP

Digit shaping option: do not perform digit shaping.

ICU Status
Stable since ICU 2.0.
HAMZA06_CHARback to summary
private static final char HAMZA06_CHAR
HAMZAFE_CHARback to summary
private static final char HAMZAFE_CHAR

some constants

IRRELEVANTback to summary
private static final int IRRELEVANT
irrelevantPosback to summary
private static final int[] irrelevantPos
isLogicalback to summary
private boolean isLogical
LAM_CHARback to summary
private static final char LAM_CHAR
LAMALEF_AUTOback to summary
public static final int LAMALEF_AUTO

Memory option: the result must have the same length as the source. Shaping Mode: For each LAMALEF character found, expand LAMALEF using space at end. If there is no space at end, use spaces at beginning of the buffer. If there is no space at beginning of the buffer, use spaces at the near (i.e. the space after the LAMALEF character). Deshaping Mode: Perform the same function as the flag equals LAMALEF_END. Affects: LamAlef options

ICU Status
Stable since ICU 4.2.
LAMALEF_BEGINback to summary
public static final int LAMALEF_BEGIN

Memory option: the result must have the same length as the source. If more room is necessary, then try to consume spaces at the beginning of the text. Affects: LamAlef options This option is an alias to LENGTH_FIXED_SPACES_AT_BEGINNING

ICU Status
Stable since ICU 4.2.
LAMALEF_ENDback to summary
public static final int LAMALEF_END

Memory option: the result must have the same length as the source. If more room is necessary, then try to consume spaces at the end of the text. Affects: LamAlef options This option is an alias to LENGTH_FIXED_SPACES_AT_END

ICU Status
Stable since ICU 4.2.
LAMALEF_MASKback to summary
public static final int LAMALEF_MASK

Bit mask for LamAlef memory options.

ICU Status
Stable since ICU 4.2.
LAMALEF_NEARback to summary
public static final int LAMALEF_NEAR

Memory option: the result must have the same length as the source. If more room is necessary, then try to consume spaces next to modified characters. Affects: LamAlef options This option is an alias to LENGTH_FIXED_SPACES_NEAR

ICU Status
Stable since ICU 4.2.
LAMALEF_RESIZEback to summary
public static final int LAMALEF_RESIZE

Memory option: allow the result to have a different length than the source. Affects: LamAlef options This option is an alias to LENGTH_GROW_SHRINK

ICU Status
Stable since ICU 4.2.
LAMALEF_SPACE_SUBback to summary
private static final char LAMALEF_SPACE_SUB
LAMTYPEback to summary
private static final int LAMTYPE
LENGTH_FIXED_SPACES_AT_BEGINNINGback to summary
public static final int LENGTH_FIXED_SPACES_AT_BEGINNING

Memory option: the result must have the same length as the source. If more room is necessary, then try to consume spaces at the beginning of the text.

ICU Status
Stable since ICU 2.0.
LENGTH_FIXED_SPACES_AT_ENDback to summary
public static final int LENGTH_FIXED_SPACES_AT_END

Memory option: the result must have the same length as the source. If more room is necessary, then try to consume spaces at the end of the text.

ICU Status
Stable since ICU 2.0.
LENGTH_FIXED_SPACES_NEARback to summary
public static final int LENGTH_FIXED_SPACES_NEAR

Memory option: the result must have the same length as the source. If more room is necessary, then try to consume spaces next to modified characters.

ICU Status
Stable since ICU 2.0.
LENGTH_GROW_SHRINKback to summary
public static final int LENGTH_GROW_SHRINK

Memory option: allow the result to have a different length than the source.

ICU Status
Stable since ICU 2.0.
LENGTH_MASKback to summary
public static final int LENGTH_MASK

Bit mask for memory options.

ICU Status
Stable since ICU 2.0.
LETTERS_MASKback to summary
public static final int LETTERS_MASK

Bit mask for letter shaping options.

ICU Status
Stable since ICU 2.0.
LETTERS_NOOPback to summary
public static final int LETTERS_NOOP

Letter shaping option: do not perform letter shaping.

ICU Status
Stable since ICU 2.0.
LETTERS_SHAPEback to summary
public static final int LETTERS_SHAPE

Letter shaping option: replace normative letter characters in the U+0600 (Arabic) block, by shaped ones in the U+FE70 (Presentation Forms B) block. Performs Lam-Alef ligature substitution.

ICU Status
Stable since ICU 2.0.
LETTERS_SHAPE_TASHKEEL_ISOLATEDback to summary
public static final int LETTERS_SHAPE_TASHKEEL_ISOLATED

Letter shaping option: replace normative letter characters in the U+0600 (Arabic) block, except for the TASHKEEL characters at U+064B...U+0652, by shaped ones in the U+Fe70 (Presentation Forms B) block. The TASHKEEL characters will always be converted to the isolated forms rather than to their correct shape.

ICU Status
Stable since ICU 2.0.
LETTERS_UNSHAPEback to summary
public static final int LETTERS_UNSHAPE

Letter shaping option: replace shaped letter characters in the U+FE70 (Presentation Forms B) block by normative ones in the U+0600 (Arabic) block. Converts Lam-Alef ligatures to pairs of Lam and Alef characters, consuming spaces if required.

ICU Status
Stable since ICU 2.0.
LINKLback to summary
private static final int LINKL
LINKRback to summary
private static final int LINKR
NEW_TAIL_CHARback to summary
private static final char NEW_TAIL_CHAR
OLD_TAIL_CHARback to summary
private static final char OLD_TAIL_CHAR
optionsback to summary
private final int options
SEEN_MASKback to summary
public static final int SEEN_MASK

Bit mask for Seen memory options.

ICU Status
Stable since ICU 4.2.
SEEN_TWOCELL_NEARback to summary
public static final int SEEN_TWOCELL_NEAR

Memory option: the result must have the same length as the source. Shaping mode: The SEEN family character will expand into two characters using space near the SEEN family character(i.e. the space after the character). if there are no spaces found, ArabicShapingException will be thrown De-shaping mode: Any Seen character followed by Tail character will be replaced by one cell Seen and a space will replace the Tail. Affects: Seen options

ICU Status
Stable since ICU 4.2.
SHADDA06_CHARback to summary
private static final char SHADDA06_CHAR
SHADDA_CHARback to summary
private static final char SHADDA_CHAR
SHADDA_TATWEEL_CHARback to summary
private static final char SHADDA_TATWEEL_CHAR
SHAPE_MODEback to summary
private static final int SHAPE_MODE
SHAPE_TAIL_NEW_UNICODEback to summary
public static final int SHAPE_TAIL_NEW_UNICODE

If this option is used, shaping will use the new Unicode code point for TAIL (i.e. 0xFE73). If this option is not specified (Default), old unofficial Unicode TAIL code point is used (i.e. 0x200B) De-shaping will not use this option as it will always search for both the new Unicode code point for the TAIL (i.e. 0xFE73) or the old unofficial Unicode TAIL code point (i.e. 0x200B) and de-shape the Seen-Family letter accordingly. Shaping Mode: Only shaping. De-shaping Mode: N/A. Affects: All Seen options

ICU Status
Stable since ICU 4.2.
SHAPE_TAIL_TYPE_MASKback to summary
public static final int SHAPE_TAIL_TYPE_MASK

Bit mask for new Unicode Tail option

ICU Status
Stable since ICU 4.2.
shapeTableback to summary
private static final int[][][] shapeTable
SPACE_CHARback to summary
private static final char SPACE_CHAR
SPACES_RELATIVE_TO_TEXT_BEGIN_ENDback to summary
public static final int SPACES_RELATIVE_TO_TEXT_BEGIN_END

This option effects the meaning of BEGIN and END options. if this option is not used the default for BEGIN and END will be as following: The Default (for both Visual LTR, Visual RTL and Logical Text) 1. BEGIN always refers to the start address of physical memory. 2. END always refers to the end address of physical memory. If this option is used it will swap the meaning of BEGIN and END only for Visual LTR text. The affect on BEGIN and END Memory Options will be as following: A. BEGIN For Visual LTR text: This will be the beginning (right side) of the visual text (corresponding to the physical memory address end, same as END in default behavior) B. BEGIN For Logical text: Same as BEGIN in default behavior. C. END For Visual LTR text: This will be the end (left side) of the visual text. (corresponding to the physical memory address beginning, same as BEGIN in default behavior) D. END For Logical text: Same as END in default behavior. Affects: All LamAlef BEGIN, END and AUTO options.

ICU Status
Stable since ICU 4.2.
SPACES_RELATIVE_TO_TEXT_MASKback to summary
public static final int SPACES_RELATIVE_TO_TEXT_MASK

Bit mask for swapping BEGIN and END for Visual LTR text

ICU Status
Stable since ICU 4.2.
spacesRelativeToTextBeginEndback to summary
private boolean spacesRelativeToTextBeginEnd
tailCharback to summary
private char tailChar
tailFamilyIsolatedFinalback to summary
private static final int[] tailFamilyIsolatedFinal
TASHKEEL_BEGINback to summary
public static final int TASHKEEL_BEGIN

Memory option: the result must have the same length as the source. Shaping mode: Tashkeel characters will be replaced by spaces. Spaces will be placed at beginning of the buffer De-shaping mode: N/A Affects: Tashkeel options

ICU Status
Stable since ICU 4.2.
TASHKEEL_ENDback to summary
public static final int TASHKEEL_END

Memory option: the result must have the same length as the source. Shaping mode: Tashkeel characters will be replaced by spaces. Spaces will be placed at end of the buffer De-shaping mode: N/A Affects: Tashkeel options

ICU Status
Stable since ICU 4.2.
TASHKEEL_MASKback to summary
public static final int TASHKEEL_MASK

Bit mask for Tashkeel replacement with Space or Tatweel memory options.

ICU Status
Stable since ICU 4.2.
TASHKEEL_REPLACE_BY_TATWEELback to summary
public static final int TASHKEEL_REPLACE_BY_TATWEEL

Memory option: the result must have the same length as the source. Shaping mode: Tashkeel characters will be replaced by Tatweel if it is connected to adjacent characters (i.e. shaped on Tatweel) or replaced by space if it is not connected. De-shaping mode: N/A Affects: YehHamza options

ICU Status
Stable since ICU 4.2.
TASHKEEL_RESIZEback to summary
public static final int TASHKEEL_RESIZE

Memory option: allow the result to have a different length than the source. Shaping mode: Tashkeel characters will be removed, buffer length will shrink. De-shaping mode: N/A Affects: Tashkeel options

ICU Status
Stable since ICU 4.2.
TASHKEEL_SPACE_SUBback to summary
private static final char TASHKEEL_SPACE_SUB
tashkeelMedialback to summary
private static final int[] tashkeelMedial
TATWEEL_CHARback to summary
private static final char TATWEEL_CHAR
TEXT_DIRECTION_LOGICALback to summary
public static final int TEXT_DIRECTION_LOGICAL

Direction indicator: the source is in logical (keyboard) order.

ICU Status
Stable since ICU 2.0.
TEXT_DIRECTION_MASKback to summary
public static final int TEXT_DIRECTION_MASK

Bit mask for direction indicators.

ICU Status
Stable since ICU 2.0.
TEXT_DIRECTION_VISUAL_LTRback to summary
public static final int TEXT_DIRECTION_VISUAL_LTR

Direction indicator: the source is in visual (display) order, that is, the leftmost displayed character is stored first.

ICU Status
Stable since ICU 2.0.
TEXT_DIRECTION_VISUAL_RTLback to summary
public static final int TEXT_DIRECTION_VISUAL_RTL

Direction indicator:the source is in visual RTL order, the rightmost displayed character stored first. This option is an alias to U_SHAPE_TEXT_DIRECTION_LOGICAL

ICU Status
Stable since ICU 4.2.
YEH_HAMZA_CHARback to summary
private static final char YEH_HAMZA_CHAR
YEH_HAMZAFE_CHARback to summary
private static final char YEH_HAMZAFE_CHAR
YEHHAMZA_MASKback to summary
public static final int YEHHAMZA_MASK

Bit mask for YehHamza memory options.

ICU Status
Stable since ICU 4.2.
YEHHAMZA_TWOCELL_NEARback to summary
public static final int YEHHAMZA_TWOCELL_NEAR

Memory option: the result must have the same length as the source. Shaping mode: The YEHHAMZA character will expand into two characters using space near it (i.e. the space after the character) if there are no spaces found, ArabicShapingException will be thrown De-shaping mode: Any Yeh (final or isolated) character followed by Hamza character will be replaced by one cell YehHamza and space will replace the Hamza. Affects: YehHamza options

ICU Status
Stable since ICU 4.2.
yehHamzaToYehback to summary
private static final char[] yehHamzaToYeh

Constructor Detail

ArabicShapingback to summary
public ArabicShaping(int options)

Construct ArabicShaping using the options flags. The flags are as follows:
'LENGTH' flags control whether the text can change size, and if not, how to maintain the size of the text when LamAlef ligatures are formed or broken.
'TEXT_DIRECTION' flags control whether the text is read and written in visual order or in logical order.
'LETTERS_SHAPE' flags control whether conversion is to or from presentation forms.
'DIGITS' flags control whether digits are shaped, and whether from European to Arabic-Indic or vice-versa.
'DIGIT_TYPE' flags control whether standard or extended Arabic-Indic digits are used when performing digit conversion.

ICU Status
Stable since ICU 2.0.

Method Detail

calculateSizeback to summary
private int calculateSize(char[] source, int sourceStart, int sourceLength)
changeLamAlefback to summary
private static char changeLamAlef(char ch)
countSpacesLeftback to summary
private static int countSpacesLeft(char[] dest, int start, int count)
countSpacesRightback to summary
private static int countSpacesRight(char[] dest, int start, int count)
countSpaceSubback to summary
private static int countSpaceSub(char[] dest, int length, char subChar)
deshapeNormalizeback to summary
private int deshapeNormalize(char[] dest, int start, int length)
deShapeUnicodeback to summary
private int deShapeUnicode(char[] dest, int start, int length, int destSize) throws ArabicShapingException
equalsback to summary
public boolean equals(Object rhs)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
rhs:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
ICU Status
Stable since ICU 2.0.
expandCompositCharback to summary
private int expandCompositChar(char[] dest, int start, int length, int lacount, int shapingMode) throws ArabicShapingException
expandCompositCharAtBeginback to summary
private boolean expandCompositCharAtBegin(char[] dest, int start, int length, int lacount)
expandCompositCharAtEndback to summary
private boolean expandCompositCharAtEnd(char[] dest, int start, int length, int lacount)
expandCompositCharAtNearback to summary
private boolean expandCompositCharAtNear(char[] dest, int start, int length, int yehHamzaOption, int seenTailOption, int lamAlefOption)
flipArrayback to summary
private static int flipArray(char[] dest, int start, int e, int w)
handleGeneratedSpacesback to summary
private int handleGeneratedSpaces(char[] dest, int start, int length)
handleTashkeelWithTatweelback to summary
private static int handleTashkeelWithTatweel(char[] dest, int sourceLength)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
ICU Status
Stable since ICU 2.0.
internalShapeback to summary
private int internalShape(char[] source, int sourceStart, int sourceLength, char[] dest, int destStart, int destSize) throws ArabicShapingException
invertBufferback to summary
private static void invertBuffer(char[] buffer, int start, int length)
isAlefCharback to summary
private static boolean isAlefChar(char ch)
isAlefMaksouraCharback to summary
private static boolean isAlefMaksouraChar(char ch)
isIsolatedTashkeelCharback to summary
private static int isIsolatedTashkeelChar(char ch)
isLamAlefCharback to summary
private static boolean isLamAlefChar(char ch)
isNormalizedLamAlefCharback to summary
private static boolean isNormalizedLamAlefChar(char ch)
isSeenFamilyCharback to summary
private static int isSeenFamilyChar(char ch)
isSeenTailFamilyCharback to summary
private static int isSeenTailFamilyChar(char ch)
isTailCharback to summary
private static boolean isTailChar(char ch)
isTashkeelCharback to summary
private static boolean isTashkeelChar(char ch)
isTashkeelCharFEback to summary
private static boolean isTashkeelCharFE(char ch)
isTashkeelOnTatweelCharback to summary
private static int isTashkeelOnTatweelChar(char ch)
isYehHamzaCharback to summary
private static boolean isYehHamzaChar(char ch)
normalizeback to summary
private int normalize(char[] dest, int start, int length)
shapeback to summary
public int shape(char[] source, int sourceStart, int sourceLength, char[] dest, int destStart, int destSize) throws ArabicShapingException

Convert a range of text in the source array, putting the result into a range of text in the destination array, and return the number of characters written.

Parameters
source:char[]

An array containing the input text

sourceStart:int

The start of the range of text to convert

sourceLength:int

The length of the range of text to convert

dest:char[]

The destination array that will receive the result. It may be NULL only if destSize is 0.

destStart:int

The start of the range of the destination buffer to use.

destSize:int

The size (capacity) of the destination buffer. If destSize is 0, then no output is produced, but the necessary buffer size is returned ("preflighting"). This does not validate the text against the options, for example, if letters are being unshaped, and spaces are being consumed following lamalef, this will not detect a lamalef without a corresponding space. An error will be thrown when the actual conversion is attempted.

Returns:int

The number of chars written to the destination buffer. If an error occurs, then no output was written, or it may be incomplete.

Exceptions
ArabicShapingException:
if the text cannot be converted according to the options.
ICU Status
Stable since ICU 2.0.
shapeback to summary
public void shape(char[] source, int start, int length) throws ArabicShapingException

Convert a range of text in place. This may only be used if the Length option does not grow or shrink the text.

Parameters
source:char[]

An array containing the input text

start:int

The start of the range of text to convert

length:int

The length of the range of text to convert

Exceptions
ArabicShapingException:
if the text cannot be converted according to the options.
ICU Status
Stable since ICU 2.0.
shapeback to summary
public String shape(String text) throws ArabicShapingException

Convert a string, returning the new string.

Parameters
text:String

the string to convert

Returns:String

the converted string

Exceptions
ArabicShapingException:
if the string cannot be converted according to the options.
ICU Status
Stable since ICU 2.0.
shapeToArabicDigitsWithContextback to summary
private void shapeToArabicDigitsWithContext(char[] dest, int start, int length, char digitBase, boolean lastStrongWasAL)
shapeUnicodeback to summary
private int shapeUnicode(char[] dest, int start, int length, int destSize, int tashkeelFlag) throws ArabicShapingException
shiftArrayback to summary
private static void shiftArray(char[] dest, int start, int e, char subChar)
specialCharback to summary
private static int specialChar(char ch)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
ICU Status
Stable since ICU 2.0.