public class BidiTransform extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BidiTransform.Mirroring
indicates whether or not characters with
the "mirrored" property in RTL runs should be replaced with their
mirror-image counterparts. |
static class |
BidiTransform.Order
indicates the order of text. |
Constructor and Description |
---|
BidiTransform()
default constructor. |
Modifier and Type | Method and Description |
---|---|
String |
transform(CharSequence text,
byte inParaLevel,
BidiTransform.Order inOrder,
byte outParaLevel,
BidiTransform.Order outOrder,
BidiTransform.Mirroring doMirroring,
int shapingOptions)
Performs transformation of text from the bidi layout defined by the
input ordering scheme to the bidi layout defined by the output ordering
scheme, and applies character mirroring and Arabic shaping operations.
|
public BidiTransform()
BidiTransform
default constructor.public String transform(CharSequence text, byte inParaLevel, BidiTransform.Order inOrder, byte outParaLevel, BidiTransform.Order outOrder, BidiTransform.Mirroring doMirroring, int shapingOptions)
In terms of
class, such a transformation
implies:
Bidi
Bidi.setReorderingMode(int)
as needed (when
the reordering mode is other than normal),Bidi.setInverse(boolean)
as needed (when text
should be transformed from a visual to a logical form),Bidi.setPara(java.lang.String, byte, byte[])
,Bidi.writeReordered(int)
,ArabicShaping.shape(char[], int, int, char[], int, int)
.An "ordering scheme" encompasses the base direction and the order of text, and these characteristics must be defined by the caller for both input and output explicitly .
There are 36 possible combinations of {input, output} ordering schemes,
which are partially supported by
already.
Examples of the currently supported combinations:
Bidi
Bidi.setPara(java.lang.String, byte, byte[])
with
paraLevel == Bidi.LTR
,Bidi.setPara(java.lang.String, byte, byte[])
with
paraLevel == Bidi.RTL
,Bidi.setPara(java.lang.String, byte, byte[])
with
paraLevel == Bidi.LEVEL_DEFAULT_LTR
,Bidi.setPara(java.lang.String, byte, byte[])
with
paraLevel == Bidi.LEVEL_DEFAULT_RTL
,Bidi.setInverse(boolean)
(true)
and then
Bidi.setPara(java.lang.String, byte, byte[])
with
paraLevel == Bidi.LTR
,Bidi.setInverse(boolean)
(true)
and then
Bidi.setPara(java.lang.String, byte, byte[])
with
paraLevel == Bidi.RTL
.
All combinations that involve the Visual RTL scheme are unsupported by
, for instance:
Bidi
Example of usage of the transformation engine:
BidiTransform bidiTransform = new BidiTransform(); String in = "abc ۰123"; // "abc \\u06f0123" // Run a transformation. String out = bidiTransform.transform(in, Bidi.LTR, Order.VISUAL, Bidi.RTL, Order.LOGICAL, Mirroring.OFF, ArabicShaping.DIGITS_AN2EN | ArabicShaping.DIGIT_TYPE_AN_EXTENDED); // Result: "0123 abc". // Do something with out. out = out.replace('0', '4'); // Result: "4123 abc". // Run a reverse transformation. String inNew = bidiTransform.transform(out, Bidi.RTL, Order.LOGICAL, Bidi.LTR, Order.VISUAL, Mirroring.OFF, ArabicShaping.DIGITS_EN2AN | ArabicShaping.DIGIT_TYPE_AN_EXTENDED); // Result: "abc \\u06f4\\u06f1\\u06f2\\u06f3"
text
- An input character sequence that the Bidi layout
transformations will be performed on.inParaLevel
- A base embedding level of the input as defined in
Bidi.setPara(String, byte, byte[])
documentation for the paraLevel
parameter.inOrder
- An order of the input, which can be one of the
BidiTransform.Order
values.outParaLevel
- A base embedding level of the output as defined in
Bidi.setPara(String, byte, byte[])
documentation for the paraLevel
parameter.outOrder
- An order of the output, which can be one of the
BidiTransform.Order
values.doMirroring
- Indicates whether or not to perform character
mirroring, and can accept one of the
BidiTransform.Mirroring
values.shapingOptions
- Arabic digit and letter shaping options defined in
the ArabicShaping
documentation.
Note: Direction indicator options are computed by the transformation engine based on the effective ordering schemes, so user-defined direction indicators will be ignored.
IllegalArgumentException
- if text
,
inOrder
, outOrder
, or
doMirroring
parameter is null
.Copyright © 2016 Unicode, Inc. and others.