Fields Summary |
---|
private static final long | serialVersionUIDThe Constant serialVersionUID. |
public static final int | EUROPEANThe Constant EUROPEAN indicates the latin and extended range,
and latin decimal base. |
public static final int | ARABICThe Constant ARABIC indicates the ARABIC range and decimal base. |
public static final int | EASTERN_ARABICThe Constant EASTERN_ARABIC indicates the ARABIC range and
ARABIC_EXTENDED decimal base. |
public static final int | DEVANAGARIThe Constant DEVANAGARI indicates the DEVANAGARI range and
decimal base. |
public static final int | BENGALIThe Constant BENGALI indicates the BENGALI range and decimal base. |
public static final int | GURMUKHIThe Constant GURMUKHI indicates the GURMUKHI range and decimal base. |
public static final int | GUJARATIThe Constant GUJARATI indicates the GUJARATI range and decimal base. |
public static final int | ORIYAThe Constant ORIYA indicates the ORIYA range and decimal base. |
public static final int | TAMILThe Constant TAMIL indicates the TAMIL range and decimal base. |
public static final int | TELUGUThe Constant TELUGU indicates the TELUGU range and decimal base. |
public static final int | KANNADAThe Constant KANNADA indicates the KANNADA range and decimal base. |
public static final int | MALAYALAMThe Constant MALAYALAM indicates the MALAYALAM range and decimal base. |
public static final int | THAIThe Constant THAI indicates the THAI range and decimal base. |
public static final int | LAOThe Constant LAO indicates the LAO range and decimal base. |
public static final int | TIBETANThe Constant TIBETAN indicates the TIBETAN range and decimal base. |
public static final int | MYANMARThe Constant MYANMAR indicates the MYANMAR range and decimal base. |
public static final int | ETHIOPICThe Constant ETHIOPIC indicates the ETHIOPIC range and decimal base. |
public static final int | KHMERThe Constant KHMER indicates the KHMER range and decimal base. |
public static final int | MONGOLIANThe Constant MONGOLIAN indicates the MONGOLIAN range and
decimal base. |
public static final int | ALL_RANGESThe Constant ALL_RANGES indicates all ranges. |
private static final int | INDEX_EUROPEANThe Constant INDEX_EUROPEAN. |
private static final int | INDEX_ARABICThe Constant INDEX_ARABIC. |
private static final int | INDEX_EASTERN_ARABICThe Constant INDEX_EASTERN_ARABIC. |
private static final int | INDEX_DEVANAGARIThe Constant INDEX_DEVANAGARI. |
private static final int | INDEX_BENGALIThe Constant INDEX_BENGALI. |
private static final int | INDEX_GURMUKHIThe Constant INDEX_GURMUKHI. |
private static final int | INDEX_GUJARATIThe Constant INDEX_GUJARATI. |
private static final int | INDEX_ORIYAThe Constant INDEX_ORIYA. |
private static final int | INDEX_TAMILThe Constant INDEX_TAMIL. |
private static final int | INDEX_TELUGUThe Constant INDEX_TELUGU. |
private static final int | INDEX_KANNADAThe Constant INDEX_KANNADA. |
private static final int | INDEX_MALAYALAMThe Constant INDEX_MALAYALAM. |
private static final int | INDEX_THAIThe Constant INDEX_THAI. |
private static final int | INDEX_LAOThe Constant INDEX_LAO. |
private static final int | INDEX_TIBETANThe Constant INDEX_TIBETAN. |
private static final int | INDEX_MYANMARThe Constant INDEX_MYANMAR. |
private static final int | INDEX_ETHIOPICThe Constant INDEX_ETHIOPIC. |
private static final int | INDEX_KHMERThe Constant INDEX_KHMER. |
private static final int | INDEX_MONGOLIANThe Constant INDEX_MONGOLIAN. |
private static final int | MAX_INDEXThe Constant MAX_INDEX. |
private final int[] | scriptsRangesThe scripts ranges. |
private final int[] | digitsLowRangesThe digits low ranges. |
private final String[] | contextsThe contexts. |
private static final int[] | STRONG_TEXT_FLAGSThe Constant STRONG_TEXT_FLAGS. |
private int | keyThe key. |
private int | maskThe mask. |
private int | fRangesThe ranges. |
private int | fDefaultContextIndexThe default context index. |
private boolean | fContextualThe contextual. |
private int | fSingleRangeIndexThe single range index. |
Methods Summary |
---|
private void | contextualShape(char[] text, int start, int count, int contextIndex)Converts count of digits of the given array of characters from the start
index using specified context. This method is applied for the contextual
shaping, if the shaper instance is not contextual use nonContextualShape
method.
char maxDigit = (char)0x0039;
char minDigit = (char)0x0030;
int currIndex;
if (((1 << contextIndex) & fRanges) == 0 ){
currIndex = INDEX_EUROPEAN;
} else {
currIndex = contextIndex;
}
for (int ind = start; ind < start + count; ind++){
if (minDigit <= text[ind] && text[ind] <= maxDigit){
if (currIndex != INDEX_ETHIOPIC || text[ind] != '0"){
text[ind] = (char)(digitsLowRanges[currIndex] + text[ind]);
}
} else {
if(isCharStrong(text[ind])){
int index = getCharIndex(text[ind]);
if (currIndex != index){
if (((1 << index) & fRanges) != 0){
currIndex = index;
} else {
currIndex = INDEX_EUROPEAN;
}
}
}
}
}
|
public boolean | equals(java.lang.Object obj)Compares this NumericShaper object with the specified Object.
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
try {
NumericShaper ns = (NumericShaper)obj;
return (fRanges == ns.fRanges &&
fDefaultContextIndex == ns.fDefaultContextIndex &&
fContextual == ns.fContextual);
} catch (ClassCastException e){
}
return false;
|
private int | getCharIndex(char ch)Returns the index of the script of the specified char.
int index = INDEX_EUROPEAN;
for (int i=0; i < MAX_INDEX; i++){
int j = i * 2;
if (scriptsRanges[j] <= ch && ch <= scriptsRanges[j+1]){
return i;
}
}
return index;
|
public static java.awt.font.NumericShaper | getContextualShaper(int ranges, int defaultContext)Gets the NumericShaper for the specified unicode ranges
and default unicode range. The defaultContext parameter
is used as the starting context (which indicates the
language/script being used). The OR logical operation
should be used for multiple ranges:
NumericShaper.DEVANAGARI | NumericShaper.BENGALI.
The NumericShaper returned by this method is contextual
in that it supports multiple character ranges, depending
on the context.
ranges &= ALL_RANGES;
defaultContext &= ALL_RANGES;
return new NumericShaper(ranges, defaultContext, true);
|
public static java.awt.font.NumericShaper | getContextualShaper(int ranges)Gets the NumericShaper for the specified unicode ranges.
The OR logical operation should be used for multiple ranges:
NumericShaper.DEVANAGARI | NumericShaper.BENGALI.
The NumericShaper returned by this method is contextual
in that it supports multiple character ranges, depending
on the context.
ranges &= ALL_RANGES;
return new NumericShaper(ranges, EUROPEAN, true);
|
private int | getIndexFromRange(int range)Returns script index of the specified context range.
if (range == 0){
// BEGIN android-changed
throwRange(range);
// END android-changed
}
int index = 0;
while (index < MAX_INDEX){
if (range == (1 << index)){
return index;
}
index++;
}
// BEGIN android-changed
throwRange(range);
return -1; // Never executed; quiets the compiler.
// END android-changed
|
private int | getRangeFromIndex(int index)Returns range corresponding to the specified script index.
if (index < 0 || index >= MAX_INDEX){
// BEGIN android-changed
throwRange(index);
// END android-changed
}
return 1 << index;
|
public int | getRanges()Gets the masks for all of the ranges supported by this NumericShaper,
packed into an int value using the logical OR logical operation
for multiple ranges:
NumericShaper.DEVANAGARI | NumericShaper.BENGALI.
return fRanges;
|
public static java.awt.font.NumericShaper | getShaper(int singleRange)Gets a NumericShaper for the specified unicode range.
The NumericShaper supports only a single range and
hence is not contextual.
singleRange &= ALL_RANGES;
return new NumericShaper(singleRange, EUROPEAN, false);
|
public int | hashCode()Returns a hash code of this NumericShaper.
HashCode hash = new HashCode();
hash.append(fRanges);
hash.append(fDefaultContextIndex);
hash.append(fContextual);
return hash.hashCode();
|
private boolean | isCharStrong(int chr)Returns true if the bidirectional category of the character
is strong.
return (STRONG_TEXT_FLAGS[chr >> 5] & (1 << (chr % 32))) != 0;
|
public boolean | isContextual()Checks if this NumericShaper is contextual (supporting
multiple script ranges) or not.
return fContextual;
|
private void | nonContextualShape(char[] text, int start, int count)Converts count of digits of the given array of characters from the start
index. Method is applied for non-contextual shaper.
char maxDigit = (char)0x0039;
char minDigit = (char)((fRanges == ETHIOPIC) ? 0x0031 : 0x0030);
for (int ind = start; ind < start + count; ind++){
if (minDigit <= text[ind] && text[ind] <= maxDigit){
text[ind] = (char)(digitsLowRanges[fSingleRangeIndex] + text[ind]);
}
}
|
private void | readObject(java.io.ObjectInputStream in)Read object.
in.defaultReadObject();
updateRangesFields();
|
public void | shape(char[] text, int start, int count, int context)Transforms the encoding of the text, starting from the character
at index start and transforming count characters,
using the specified context.
if (isContextual()){
contextualShape(text, start, count, getIndexFromRange(context));
} else {
nonContextualShape(text, start, count);
}
|
public void | shape(char[] text, int start, int count)Transforms the encoding of the text, starting from the character
at index start and transforming count characters.
if (isContextual()){
contextualShape(text, start, count, fDefaultContextIndex);
} else {
nonContextualShape(text, start, count);
}
|
private static void | throwRange(int value)Throws a standard "out of range" exception.
throw new IllegalArgumentException(
"Illegal range argument value: " + value);
|
public java.lang.String | toString()Returns a string representation of this NumericShaper.
/* !! There is no description in the documentation what this method must
* return. Thus format of toString method is based on 1.5 release
* behavior and can be obtained using next test sample:
*
* // Simple shapers toString format
* System.out.println(NumericShaper.getShaper(NumericShaper.EASTERN_ARABIC));
*
* // Context shapers with default context toString format
* System.out.println(NumericShaper.getContextualShaper(
* NumericShaper.ARABIC | NumericShaper.TAMIL));
*
* // Context shapers with context
* System.out.println(NumericShaper.getContextualShaper(
* NumericShaper.ARABIC | NumericShaper.TAMIL,
* NumericShaper.EASTERN_ARABIC));
*/
StringBuffer sb = new StringBuffer(super.toString());
sb.append("[contextual:"); //$NON-NLS-1$
sb.append(fContextual);
if (fContextual){
sb.append(", context:"); //$NON-NLS-1$
sb.append(contexts[fDefaultContextIndex]);
}
sb.append(", range(s): "); //$NON-NLS-1$
if (fContextual) {
int index = 0;
boolean isFirst = true;
while (index < MAX_INDEX){
if ((fRanges & (1 << index)) != 0){
if (isFirst){
isFirst = false;
} else {
sb.append(", "); //$NON-NLS-1$
}
sb.append(contexts[index]);
}
index++;
}
} else {
sb.append(contexts[fSingleRangeIndex]);
}
sb.append("]"); //$NON-NLS-1$
return sb.toString();
|
private void | updateKeyMaskFields()Updates private fields for object after deserialization
according to the serialized form of this class mentioned in the
documentation.
mask = fRanges;
if (fContextual){
mask |= (1 << 31);
key = fDefaultContextIndex;
} else{
key = fSingleRangeIndex;
}
|
private void | updateRangesFields()Updates all private serialized fields for object to be correctly serialized
according to the serialized form of this class mentioned in the
documentation.
fRanges = (mask & ~(1 << 31));
fContextual = ((mask &(1 << 31)) != 0);
if (fContextual){
fRanges = (mask & ~(1 << 31));
fDefaultContextIndex = key;
} else {
fRanges = mask;
fSingleRangeIndex = key;
}
|
private void | writeObject(java.io.ObjectOutputStream out)Write object.
updateKeyMaskFields();
out.defaultWriteObject();
|