Package com.mta.tehreer.unicode
Class BidiParagraph
java.lang.Object
com.mta.tehreer.unicode.BidiParagraph
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptioncreateLine
(int charStart, int charEnd) Creates a line object of specified range by applying Rules L1-L2 of Unicode Bidirectional Algorithm.void
dispose()
Releases the native memory of this object.static BidiParagraph
finalizable
(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.byte
Returns the base level of this paragraph.int
Returns the index after the last character of this paragraph in source text.Returns a list containing the levels of all characters in this paragraph.int
Returns the index to the first character of this paragraph in source text.Returns an iterable of logically ordered runs in this paragraph.static boolean
isFinalizable
(BidiParagraph bidiParagraph) Checks whether a paragraph object is finalizable or not.toString()
-
Method Details
-
finalizable
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. 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:
bidiParagraph
- The bidi paragraph object to wrap into a finalizable instance.- Returns:
- The finalizable instance of the passed-in bidi paragraph object.
-
isFinalizable
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
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
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
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
- ifcharStart
is less than paragraph start, orcharEnd
is greater than paragraph end, orcharStart
is greater than or equal tocharEnd
.
-
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
-