public class NumberShaper extends Object implements Serializable
Internally, numbers will be represented with 0-9, but externally they should show as a user wishes. Further user input may, optionally, use the external form.
This shaper has special behavior for Arabic numbers that are in the form "12:34" as this is taken as chapter:verse. Normally, a ':' is treated as a numeric separator, this results in "12:34", but for verses it should be "34:12". That is, Arabic, numbers are left-to-right (even though the rest of the script is right-to-left) and the ':' as a numeric separator does not change that. So to get around this we mark the ':' as a right-to-left character.
See also: com.ibm.icu.text.ArabicShaping
NumericShaper
,
The GNU Lesser General Public License for details.
,
Serialized FormModifier and Type | Field and Description |
---|---|
private char |
nineShape
Nine for this shaper.
|
private static long |
serialVersionUID
Serialization ID
|
Constructor and Description |
---|
NumberShaper()
Create a shaper that is appropriate for the user's locale.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canShape()
Determine whether shaping is possible.
|
boolean |
canUnshape()
Determine whether shaping back to 0-9 is possible.
|
private char |
getNine()
Establish nine for the script.
|
String |
shape(String input)
Replace 0-9 in the input with representations appropriate for the script.
|
private char[] |
shaped(char[] src,
boolean[] transformed) |
private char[] |
transform(char[] src,
int zero,
int nine,
int offset,
boolean[] transformed)
Transform either to or from 0-9 and the script representation, returning
the result and true when at least one character is transformed.
|
String |
unshape(String input)
Replace script representations of numbers with 0-9.
|
private char[] |
unshaped(char[] src,
boolean[] transformed)
Perform shaping back to 0-9.
|
private char nineShape
private static final long serialVersionUID
public NumberShaper()
public boolean canShape()
public String shape(String input)
input
- the text to be transformedpublic boolean canUnshape()
public String unshape(String input)
input
- the text to be transformedprivate char[] unshaped(char[] src, boolean[] transformed)
src
- the text to transformtransformed
- an input parameter of one boolean that can hold whether there
was a transformationprivate char[] shaped(char[] src, boolean[] transformed)
src
- the text to transformtransformed
- an input parameter of one boolean that can hold whether there
was a transformationprivate char[] transform(char[] src, int zero, int nine, int offset, boolean[] transformed)
src
- the text to transformzero
- zero in the source representationnine
- nine in the source representationoffset
- the distance between zeros in the source and target
representationtransformed
- an input parameter of one boolean that can hold whether there
was a transformationprivate char getNine()