Java Code Examples for com.ibm.icu.text.Bidi#DIRECTION_DEFAULT_LEFT_TO_RIGHT

The following examples show how to use com.ibm.icu.text.Bidi#DIRECTION_DEFAULT_LEFT_TO_RIGHT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BidiBase.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 2
Source File: BidiBase.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 3
Source File: BidiBase.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 4
Source File: BidiBase.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 5
Source File: BidiBase.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 6
Source File: BidiBase.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 7
Source File: BidiBase.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 8
Source File: BidiBase.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 9
Source File: BidiBase.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 10
Source File: BidiBase.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 11
Source File: BidiBase.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}
 
Example 12
Source File: BidiBase.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create Bidi from the given text, embedding, and direction information.
 * The embeddings array may be null. If present, the values represent
 * embedding level information. Negative values from -1 to -61 indicate
 * overrides at the absolute value of the level. Positive values from 1 to
 * 61 indicate embeddings. Where values are zero, the base embedding level
 * as determined by the base direction is assumed.<p>
 *
 * Note: this constructor calls setPara() internally.
 *
 * @param text an array containing the paragraph of text to process.
 * @param textStart the index into the text array of the start of the
 *        paragraph.
 * @param embeddings an array containing embedding values for each character
 *        in the paragraph. This can be null, in which case it is assumed
 *        that there is no external embedding information.
 * @param embStart the index into the embedding array of the start of the
 *        paragraph.
 * @param paragraphLength the length of the paragraph in the text and
 *        embeddings arrays.
 * @param flags a collection of flags that control the algorithm. The
 *        algorithm understands the flags DIRECTION_LEFT_TO_RIGHT,
 *        DIRECTION_RIGHT_TO_LEFT, DIRECTION_DEFAULT_LEFT_TO_RIGHT, and
 *        DIRECTION_DEFAULT_RIGHT_TO_LEFT. Other values are reserved.
 *
 * @throws IllegalArgumentException if the values in embeddings are
 *         not within the allowed range
 *
 * @see #DIRECTION_LEFT_TO_RIGHT
 * @see #DIRECTION_RIGHT_TO_LEFT
 * @see #DIRECTION_DEFAULT_LEFT_TO_RIGHT
 * @see #DIRECTION_DEFAULT_RIGHT_TO_LEFT
 * @stable ICU 3.8
 */
public BidiBase(char[] text,
         int textStart,
         byte[] embeddings,
         int embStart,
         int paragraphLength,
         int flags)
 {
    this(0, 0);
    byte paraLvl;
    switch (flags) {
    case Bidi.DIRECTION_LEFT_TO_RIGHT:
    default:
        paraLvl = Bidi.DIRECTION_LEFT_TO_RIGHT;
        break;
    case Bidi.DIRECTION_RIGHT_TO_LEFT:
        paraLvl = Bidi.DIRECTION_RIGHT_TO_LEFT;
        break;
    case Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
        break;
    case Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT:
        paraLvl = INTERNAL_LEVEL_DEFAULT_RTL;
        break;
    }
    byte[] paraEmbeddings;
    if (embeddings == null) {
        paraEmbeddings = null;
    } else {
        paraEmbeddings = new byte[paragraphLength];
        byte lev;
        for (int i = 0; i < paragraphLength; i++) {
            lev = embeddings[i + embStart];
            if (lev < 0) {
                lev = (byte)((- lev) | INTERNAL_LEVEL_OVERRIDE);
            } else if (lev == 0) {
                lev = paraLvl;
                if (paraLvl > MAX_EXPLICIT_LEVEL) {
                    lev &= 1;
                }
            }
            paraEmbeddings[i] = lev;
        }
    }
    if (textStart == 0 && embStart == 0 && paragraphLength == text.length) {
        setPara(text, paraLvl, paraEmbeddings);
    } else {
        char[] paraText = new char[paragraphLength];
        System.arraycopy(text, textStart, paraText, 0, paragraphLength);
        setPara(paraText, paraLvl, paraEmbeddings);
    }
}