Class BidiLine

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

public class BidiLine extends Object implements Disposable
A BidiLine object represents a single line processed with rules L1-L2 of Unicode Bidirectional Algorithm. Instead of reordering the characters as stated by rule L2, it allows to query and iterate over reordered level runs. The caller is responsible to reorder the characters manually, if required.
  • Method Details

    • finalizable

      @NonNull public static BidiLine finalizable(@NonNull BidiLine bidiLine)
      Wraps a bidi line 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:
      bidiLine - The bidi line object to wrap into a finalizable instance.
      Returns:
      The finalizable instance of the passed-in bidi line object.
    • isFinalizable

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

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

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

      @NonNull public List<BidiRun> getVisualRuns()
      Returns an unmodifiable list of visually ordered runs in this line.

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

      Returns:
      An unmodifiable list of visually ordered runs in this line.
    • getMirroringPairs

      @NonNull public Iterable<BidiPair> getMirroringPairs()
      Returns an iterable of mirroring pairs in this line. You can use the iterable to implement Rule L4 of Unicode Bidirectional Algorithm.

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

      Returns:
      An iterable of mirroring pairs in this line.
    • 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