2
*******************************************************************************
3
* Copyright (C) 2001-2009, International Business Machines
4
* Corporation and others. All Rights Reserved.
5
*******************************************************************************
7
/* Written by Simon Montagu, Matitiahu Allouche
8
* (ported from C code written by Markus W. Scherer)
11
package com.ibm.icu.text;
14
* A BidiRun represents a sequence of characters at the same embedding level.
15
* The Bidi algorithm decomposes a piece of text into sequences of characters
16
* at the same embedding level, each such sequence is called a <quote>run</quote>.
18
* <p>A BidiRun represents such a run by storing its essential properties,
19
* but does not duplicate the characters which form the run.
21
* <p>The "limit" of the run is the position just after the
22
* last character, i.e., one more than that position.
24
* <p>This class has no public constructor, and its members cannot be
27
* @see com.ibm.icu.text.Bidi
30
public class BidiRun {
32
int start; /* first logical position of the run */
33
int limit; /* last visual position of the run +1 */
34
int insertRemove; /* if >0, flags for inserting LRM/RLM before/after run,
35
if <0, count of bidi controls within run */
41
* Note that members start and limit of a run instance have different
42
* meanings depending whether the run is part of the runs array of a Bidi
43
* object, or if it is a reference returned by getVisualRun() or
45
* For a member of the runs array of a Bidi object,
46
* - start is the first logical position of the run in the source text.
47
* - limit is one after the last visual position of the run.
48
* For a reference returned by getLogicalRun() or getVisualRun(),
49
* - start is the first logical position of the run in the source text.
50
* - limit is one after the last logical position of the run.
60
BidiRun(int start, int limit, byte embeddingLevel)
64
this.level = embeddingLevel;
68
* Copy the content of a BidiRun instance
70
void copyFrom(BidiRun run)
72
this.start = run.start;
73
this.limit = run.limit;
74
this.level = run.level;
75
this.insertRemove = run.insertRemove;
79
* Get the first logical position of the run in the source text
88
* Get position of one character after the end of the run in the source text
100
public int getLength()
102
return limit - start;
109
public byte getEmbeddingLevel()
115
* Check if run level is odd
116
* @return true if the embedding level of this run is odd, i.e. it is a
120
public boolean isOddRun()
122
return (level & 1) == 1;
126
* Check if run level is even
127
* @return true if the embedding level of this run is even, i.e. it is a
131
public boolean isEvenRun()
133
return (level & 1) == 0;
137
* Get direction of run
140
public byte getDirection()
142
return (byte)(level & 1);
146
* String to display run
149
public String toString()
151
return new String("BidiRun " + start + " - " + limit + " @ " + level);