Package com.mta.tehreer.unicode
Class BidiLine
java.lang.Object
com.mta.tehreer.unicode.BidiLine
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Releases the native memory of this object.static BidiLine
finalizable
(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.int
Returns the index after the last character of this line in source text.int
Returns the index to the first character of this line in source text.Returns an iterable of mirroring pairs in this line.Returns an unmodifiable list of visually ordered runs in this line.static boolean
isFinalizable
(BidiLine bidiLine) Checks whether a bidi line object is finalizable or not.toString()
-
Method Details
-
finalizable
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. Callingdispose()
on returned object will throw anUnsupportedOperationException
.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
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
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
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 interfaceDisposable
-
toString
-