Path: blob/master/src/java.base/share/classes/jdk/internal/icu/text/BidiRun.java
41161 views
/*1* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24/*25*******************************************************************************26* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *27* *28* The original version of this source code and documentation is copyrighted *29* and owned by IBM, These materials are provided under terms of a License *30* Agreement between IBM and Sun. This technology is protected by multiple *31* US and International patents. This notice and attribution to IBM may not *32* to removed. *33*******************************************************************************34*/35/* Written by Simon Montagu, Matitiahu Allouche36* (ported from C code written by Markus W. Scherer)37*/3839package jdk.internal.icu.text;4041/**42* A BidiRun represents a sequence of characters at the same embedding level.43* The Bidi algorithm decomposes a piece of text into sequences of characters44* at the same embedding level, each such sequence is called a "run".45*46* <p>A BidiRun represents such a run by storing its essential properties,47* but does not duplicate the characters which form the run.48*49* <p>The "limit" of the run is the position just after the50* last character, i.e., one more than that position.51*52* <p>This class has no public constructor, and its members cannot be53* modified by users.54*55* @see com.ibm.icu.text.Bidi56*/57class BidiRun {5859int start; /* first logical position of the run */60int limit; /* last visual position of the run +1 */61int insertRemove; /* if >0, flags for inserting LRM/RLM before/after run,62if <0, count of bidi controls within run */63byte level;6465/*66* Default constructor67*68* Note that members start and limit of a run instance have different69* meanings depending whether the run is part of the runs array of a Bidi70* object, or if it is a reference returned by getVisualRun() or71* getLogicalRun().72* For a member of the runs array of a Bidi object,73* - start is the first logical position of the run in the source text.74* - limit is one after the last visual position of the run.75* For a reference returned by getLogicalRun() or getVisualRun(),76* - start is the first logical position of the run in the source text.77* - limit is one after the last logical position of the run.78*/79BidiRun()80{81this(0, 0, (byte)0);82}8384/*85* Constructor86*/87BidiRun(int start, int limit, byte embeddingLevel)88{89this.start = start;90this.limit = limit;91this.level = embeddingLevel;92}9394/*95* Copy the content of a BidiRun instance96*/97void copyFrom(BidiRun run)98{99this.start = run.start;100this.limit = run.limit;101this.level = run.level;102this.insertRemove = run.insertRemove;103}104105/**106* Get level of run107*/108byte getEmbeddingLevel()109{110return level;111}112113/**114* Check if run level is even115* @return true if the embedding level of this run is even, i.e. it is a116* left-to-right run.117*/118boolean isEvenRun()119{120return (level & 1) == 0;121}122123}124125126