Class BidiParagraph

java.lang.Object
com.mta.tehreer.unicode.BidiParagraph
All Implemented Interfaces:
Disposable

public class BidiParagraph extends Object implements Disposable
A BidiParagraph object represents a single paragraph of text processed with rules X1-I2 of Unicode Bidirectional Algorithm. It contains the resolved embedding levels of all the characters of a paragraph and provides the facility to query them or iterate over their runs.
  • Method Details

    • finalizable

      @NonNull public static BidiParagraph finalizable(@NonNull BidiParagraph bidiParagraph)
      Wraps a bidi paragraph object into a finalizable instance which is guaranteed to be disposed automatically by the GC when no longer in use. After calling this method, dispose() should not be called on either original object or returned object. Calling dispose() on returned object will throw an UnsupportedOperationException.

      Note: The behavior is undefined if the passed-in object is already disposed or wrapped into another finalizable instance.

      Parameters:
      bidiParagraph - The bidi paragraph object to wrap into a finalizable instance.
      Returns:
      The finalizable instance of the passed-in bidi paragraph object.
    • isFinalizable

      public static boolean isFinalizable(@NonNull BidiParagraph bidiParagraph)
      Checks whether a paragraph object is finalizable or not.
      Parameters:
      bidiParagraph - The paragraph object to check.
      Returns:
      true if the passed-in bidi paragraph object is finalizable, false otherwise.
    • getCharStart

      public int getCharStart()
      Returns the index to the first character of this paragraph in source text.
      Returns:
      The index to the first character of this paragraph in source text.
    • getCharEnd

      public int getCharEnd()
      Returns the index after the last character of this paragraph in source text.
      Returns:
      The index after the last character of this paragraph in source text.
    • getBaseLevel

      public byte getBaseLevel()
      Returns the base level of this paragraph.
      Returns:
      The base level of this paragraph.
    • getCharLevels

      @NonNull public ByteList getCharLevels()
      Returns a list containing the levels of all characters in this paragraph.

      Note: The returned list might exhibit undefined behavior if the paragraph object is disposed.

      Returns:
      A list containing the levels of all characters in this paragraph.
    • getLogicalRuns

      @NonNull public Iterator<BidiRun> getLogicalRuns()
      Returns an iterable of logically ordered runs in this paragraph.

      Note: The returned iterable might exhibit undefined behavior if the paragraph object is disposed.

      Returns:
      An iterable of logically ordered runs in this paragraph.
    • createLine

      @NonNull public BidiLine createLine(int charStart, int charEnd)
      Creates a line object of specified range by applying Rules L1-L2 of Unicode Bidirectional Algorithm.
      Parameters:
      charStart - The index to the first character of the line in source text.
      charEnd - The index after the last character of the line in source text.
      Returns:
      A line object processed with Rules L1-L2 of Unicode Bidirectional Algorithm.
      Throws:
      IllegalArgumentException - if charStart is less than paragraph start, or charEnd is greater than paragraph end, or charStart is greater than or equal to charEnd.
    • dispose

      public void dispose()
      Description copied from interface: Disposable
      Releases the native memory of this object. Failing to call this method will cause memory leaks.

      Note: The behavior is undefined if this method is called more than once on the same object.

      Specified by:
      dispose in interface Disposable
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object