Open In App

Bidi createLineBidi() method in Java with Examples

Last Updated : 27 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The createLineBidi() method of java.text.Bidi class is used to create a new bidi object having same base direction and representing every property of current bidi within the range.

Syntax:

public Bidi createLineBidi(int lineStart,
                           int lineLimit)

Parameter: This method takes following argument as parameter

  • lineStart: it is the start point of this new bidi
  • lineLimit: it is the end point for this new bidi

Return Value: This method return a new Bidi object

Below are the examples to illustrate the createLineBidi() method:

Example 1:




// Java program to demonstrate
// createLineBidi() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        // text with base direction
        Bidi bidi
            = new Bidi(
                "Geeks For Geeks",
                Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // creating and new bidi Object using the old one
        // using createLineBidi() method
        Bidi newbidi = bidi.createLineBidi(1, 6);
  
        // display the new bidi status
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength()
                           + "\nnumber of levels : "
                           + newbidi.getRunCount()
                           + "\nBase Level : "
                           + newbidi.getBaseLevel());
    }
}


Output:

New Bidi 
Length : 5
number of levels : 2
Base Level : 1

Example 2:




// Java program to demonstrate
// createLineBidi() method
  
import java.text.*;
import java.util.*;
import java.io.*;
  
public class GFG {
    public static void main(String[] argv)
    {
        // creating and initializing Bidi
        // text with base direction
        Bidi bidi
            = new Bidi("Tajmahal",
                       Bidi.DIRECTION_RIGHT_TO_LEFT);
  
        // creating and new bidi Object using the old one
        // using createLineBidi() method
        Bidi newbidi = bidi.createLineBidi(3, 5);
  
        // display the new bidi status
        System.out.println("New Bidi "
                           + "\nLength : "
                           + newbidi.getLength()
                           + "\nnumber of levels : "
                           + newbidi.getRunCount()
                           + "\nBase Level : "
                           + newbidi.getBaseLevel());
    }
}


Output:

New Bidi 
Length : 2
number of levels : 1
Base Level : 2

Reference: https://docs.oracle.com/javase/9/docs/api/java/text/Bidi.html#createLineBidi-int-int-



Similar Reads

Bidi getLength() method in Java with Examples
The getLength() method of java.text.Bidi class is used to get the length of the text in this Bidi instance. Syntax: public int getLength() Parameter: This method accepts nothing as parameter. Return Value: This method provides the length of the bidi text as integer. Below are the examples to illustrate the getLength() method: Example 1: // Java pro
1 min read
Bidi getBaseLevel() method in Java with Examples
The getBaseLevel() method of java.text.Bidi class is used to get the base level of this instance of Bidi Class. Base level means whether this Bidi instance has base level "left to right" or "right to left". Syntax: public int getBaseLevel() Parameter: This method accepts nothing as parameter. Return Value: This method used to provide 0 for left to
2 min read
Bidi getLevelAt() method in Java with Examples
The getLevelAt() method of java.text.Bidi class is used to provide the resolved level of the particular character present at the particular point on the line of bidi text. Syntax: public int getLevelAt(int offset) Parameter: This method takes offset of the character present of the line of text for which resolved level is needed. Return Value: This
2 min read
Bidi getRunCount() method in Java with Examples
The getRunCount() method of java.security.Bidi class used to provide the number of base levels present in line of bidi text. Here we will find only one base level because we are using only one base level at a time. Syntax: public int getRunCount() Parameter: This method accepts nothing as parameter. Return Value: This method provides the number of
2 min read
Bidi getRunStart() method in Java with Examples
The getRunStart() method of java.text.Bidi class used to provide the index of the first character where the nth run starts for this Bidi instance. Syntax: public int getRunStart(int run) Parameters: This method accepts the index of the logical run for which start of the run is to be retrieved. Return Value: This method provides the index of start c
2 min read
Bidi toString() method in Java with Examples
The toString() method of java.text.Bidi class is used to display this Bidi instance in string representation. Syntax: public String toString() Parameter: This method accepts nothing as parameter. Return Value: This method display internal state of bidi in string format. Below are the examples to illustrate the toString() method: Example 1: // Java
2 min read
Bidi baseIsLeftToRight() method in Java with Examples
The baseIsLeftToRight() method of java.text.Bidi class is used to check if this Bidi instance has left to right base direction or not. Syntax: public boolean baseIsLeftToRight() Parameter: This method accepts nothing as parameter. Return Value: This method return true if this bidi has left to right base direction otherwise false. Below are the exam
2 min read
Bidi getRunLimit() method in Java with Examples
The getRunLimit() method of java.text.Bidi class is used to provide the (index +1) value of the last character where the last run ends of this Bidi instance. Syntax: public int getRunLimit(int run) Parameters: This method accepts the index of the run for which Run limit is to be retrieved. Return Value: This method provides the length of the line f
2 min read
Bidi getRunLevel() method in Java with Examples
The getRunLevel() method of java.text.Bidi class used to provide the level for the nth run of this line of text if there is only one running state then It will provide base level for that state . Syntax: public int getRunLevel(int run) Parameters: This method accepts the index of the logical run for which the level of the run is to be retrieved. Re
2 min read
Bidi isLeftToRight() method in Java with Examples
The isLeftToRight() method of java.text.Bidi class is used to check if it has left to right line and base direction both or not. Syntax: public boolean isLeftToRight() Parameter: This method accepts nothing as parameter. Return Value: This method return true if this bidi has both left to right line and base direction otherwise false. Below are the
2 min read
Practice Tags :