private String shapeAsArabicIndic(String text) { // Use U+0660 .. U+0669 are ARABIC-INDIC DIGIT values 0 through 9 // See http://stackoverflow.com/questions/1676460/in-unicode-why-are-there-two-representations-for-the-arabic-digits char[] chars = text.toCharArray(); getNumericShaperArabicIndic().shape(chars, 0, chars.length); return new String(chars); }
/** * Gets a NumericShaper for the specified unicode range. * The NumericShaper supports only a single range and * hence is not contextual. * * @param singleRange the specified unicode single range. * * @return the NumericShaper for the specified unicode range. */ public static NumericShaper getShaper(int singleRange) { singleRange &= ALL_RANGES; return new NumericShaper(singleRange, EUROPEAN, false); }
/** * Transforms the encoding of the text, starting from the character * at index start and transforming count characters, * using the specified context. * * @param text the text to be shaped. * @param start the start offset of the text. * @param count the number of characters to be shaped. * @param context the context to be used for shaping. */ public void shape(char[] text, int start, int count, int context) { if (isContextual()){ contextualShape(text, start, count, getIndexFromRange(context)); } else { nonContextualShape(text, start, count); } }
/** * Transforms the encoding of the text, starting from the character * at index start and transforming count characters. * * @param text the text to be shaped. * @param start the start offset of the text. * @param count the number of characters to be shaped. */ public void shape(char[] text, int start, int count) { if (isContextual()){ contextualShape(text, start, count, fDefaultContextIndex); } else { nonContextualShape(text, start, count); } }
if(isCharStrong(text[ind])){ int index = getCharIndex(text[ind]); if (currIndex != index){ if (((1 << index) & fRanges) != 0){
/** * Returns range corresponding to the specified script index. * * @param index specified script index * * @return one of the range constants according to the specified script index. */ private int getRangeFromIndex(int index){ if (index < 0 || index >= MAX_INDEX){ throw rangeException(index); } return 1 << index; }
/** * Write object. * * @param out the out * * @throws IOException Signals that an I/O exception has occurred. */ private void writeObject(java.io.ObjectOutputStream out) throws IOException{ updateKeyMaskFields(); out.defaultWriteObject(); }
/** * Creates NumericShaper with specified parameters. * * @param ranges specified ranges to be shaped * @param defaultContext default context range * @param isContextual specifies if the instance is contextual */ private NumericShaper(int ranges, int defaultContext, boolean isContextual){ this.fRanges = ranges; this.fDefaultContextIndex = getIndexFromRange(defaultContext); this.fContextual = isContextual; if (!fContextual){ fSingleRangeIndex = getIndexFromRange(ranges); } }
/** * Format. * * @param str * String * @return String */ public static String format(final String str) { final NumericShaper shaper = NumericShaper.getContextualShaper(NumericShaper.ARABIC); final char[] c = str.toCharArray(); shaper.shape(c, 0, c.length, NumericShaper.ARABIC); return new String(c); }
/** * Transforms the encoding of the text, starting from the character * at index start and transforming count characters. * * @param text the text to be shaped. * @param start the start offset of the text. * @param count the number of characters to be shaped. */ public void shape(char[] text, int start, int count) { if (isContextual()){ contextualShape(text, start, count, fDefaultContextIndex); } else { nonContextualShape(text, start, count); } }
if(isCharStrong(text[ind])){ int index = getCharIndex(text[ind]); if (currIndex != index){ if (((1 << index) & fRanges) != 0){
/** * Returns script index of the specified context range. * * @param range specified range * * @return one of the script indices according to the specified range. */ private int getIndexFromRange(int range){ if (range == 0) { throw rangeException(range); } int index = 0; while (index < MAX_INDEX){ if (range == (1 << index)){ return index; } index++; } throw rangeException(range); }
/** * Write object. * * @param out the out * * @throws IOException Signals that an I/O exception has occurred. */ private void writeObject(java.io.ObjectOutputStream out) throws IOException{ updateKeyMaskFields(); out.defaultWriteObject(); }
/** * Creates NumericShaper with specified parameters. * * @param ranges specified ranges to be shaped * @param defaultContext default context range * @param isContextual specifies if the instance is contextual */ private NumericShaper(int ranges, int defaultContext, boolean isContextual){ this.fRanges = ranges; this.fDefaultContextIndex = getIndexFromRange(defaultContext); this.fContextual = isContextual; if (!fContextual){ fSingleRangeIndex = getIndexFromRange(ranges); } }
/** * Transforms the encoding of the text, starting from the character * at index start and transforming count characters, * using the specified context. * * @param text the text to be shaped. * @param start the start offset of the text. * @param count the number of characters to be shaped. * @param context the context to be used for shaping. */ public void shape(char[] text, int start, int count, int context) { if (isContextual()){ contextualShape(text, start, count, getIndexFromRange(context)); } else { nonContextualShape(text, start, count); } }
/** * Transforms the encoding of the text, starting from the character * at index start and transforming count characters. * * @param text the text to be shaped. * @param start the start offset of the text. * @param count the number of characters to be shaped. */ public void shape(char[] text, int start, int count) { if (isContextual()){ contextualShape(text, start, count, fDefaultContextIndex); } else { nonContextualShape(text, start, count); } }
if(isCharStrong(text[ind])){ int index = getCharIndex(text[ind]); if (currIndex != index){ if (((1 << index) & fRanges) != 0){
((NumericShaper) numericShaper).shape(text, 0, length);
/** * 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. * * @param ranges the unicode ranges. * * @return the NumericShaper for the specified ranges. */ public static NumericShaper getContextualShaper(int ranges) { ranges &= ALL_RANGES; return new NumericShaper(ranges, EUROPEAN, true); }
/** * Returns range corresponding to the specified script index. * * @param index specified script index * * @return one of the range constants according to the specified script index. */ private int getRangeFromIndex(int index){ if (index < 0 || index >= MAX_INDEX){ throw rangeException(index); } return 1 << index; }