1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ******************************************************************************* 6 * Copyright (C) 2001-2016, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 ******************************************************************************* 9 */ 10 /* Written by Simon Montagu, Matitiahu Allouche 11 * (ported from C code written by Markus W. Scherer) 12 */ 13 14 package ohos.global.icu.text; 15 16 /** 17 * A BidiRun represents a sequence of characters at the same embedding level. 18 * The Bidi algorithm decomposes a piece of text into sequences of characters 19 * at the same embedding level, each such sequence is called a "run". 20 * 21 * <p>A BidiRun represents such a run by storing its essential properties, 22 * but does not duplicate the characters which form the run. 23 * 24 * <p>The "limit" of the run is the position just after the 25 * last character, i.e., one more than that position. 26 * 27 * <p>This class has no public constructor, and its members cannot be 28 * modified by users. 29 * 30 * @see ohos.global.icu.text.Bidi 31 */ 32 public class BidiRun { 33 34 int start; /* first logical position of the run */ 35 int limit; /* last visual position of the run +1 */ 36 int insertRemove; /* if >0, flags for inserting LRM/RLM before/after run, 37 if <0, count of bidi controls within run */ 38 byte level; 39 40 /* 41 * Default constructor 42 * 43 * Note that members start and limit of a run instance have different 44 * meanings depending whether the run is part of the runs array of a Bidi 45 * object, or if it is a reference returned by getVisualRun() or 46 * getLogicalRun(). 47 * For a member of the runs array of a Bidi object, 48 * - start is the first logical position of the run in the source text. 49 * - limit is one after the last visual position of the run. 50 * For a reference returned by getLogicalRun() or getVisualRun(), 51 * - start is the first logical position of the run in the source text. 52 * - limit is one after the last logical position of the run. 53 */ BidiRun()54 BidiRun() 55 { 56 this(0, 0, (byte)0); 57 } 58 59 /* 60 * Constructor 61 */ BidiRun(int start, int limit, byte embeddingLevel)62 BidiRun(int start, int limit, byte embeddingLevel) 63 { 64 this.start = start; 65 this.limit = limit; 66 this.level = embeddingLevel; 67 } 68 69 /* 70 * Copy the content of a BidiRun instance 71 */ copyFrom(BidiRun run)72 void copyFrom(BidiRun run) 73 { 74 this.start = run.start; 75 this.limit = run.limit; 76 this.level = run.level; 77 this.insertRemove = run.insertRemove; 78 } 79 80 /** 81 * Get the first logical position of the run in the source text 82 */ getStart()83 public int getStart() 84 { 85 return start; 86 } 87 88 /** 89 * Get position of one character after the end of the run in the source text 90 */ getLimit()91 public int getLimit() 92 { 93 return limit; 94 } 95 96 /** 97 * Get length of run 98 */ getLength()99 public int getLength() 100 { 101 return limit - start; 102 } 103 104 /** 105 * Get level of run 106 */ getEmbeddingLevel()107 public byte getEmbeddingLevel() 108 { 109 return level; 110 } 111 112 /** 113 * Check if run level is odd 114 * @return true if the embedding level of this run is odd, i.e. it is a 115 * right-to-left run. 116 */ isOddRun()117 public boolean isOddRun() 118 { 119 return (level & 1) == 1; 120 } 121 122 /** 123 * Check if run level is even 124 * @return true if the embedding level of this run is even, i.e. it is a 125 * left-to-right run. 126 */ isEvenRun()127 public boolean isEvenRun() 128 { 129 return (level & 1) == 0; 130 } 131 132 /** 133 * Get direction of run 134 */ getDirection()135 public byte getDirection() 136 { 137 return (byte)(level & 1); 138 } 139 140 /** 141 * String to display run 142 */ 143 @Override toString()144 public String toString() 145 { 146 return "BidiRun " + start + " - " + limit + " @ " + level; 147 } 148 } 149