Skip to content

Commit b3f60fa

Browse files
committed
[lib] Wrote documentation of script classifier methods
1 parent 082ca11 commit b3f60fa

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

tehreer-android/src/main/java/com/mta/tehreer/unicode/ScriptClassifier.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ public class ScriptClassifier {
3131
private final String text;
3232
private final byte[] scripts;
3333

34+
/**
35+
* Constructs a script classifier object for the specified text.
36+
*
37+
* @param text The text whose script classification is desired.
38+
*
39+
* @throw NullPointerException if <code>text</code> is null.
40+
*/
3441
public ScriptClassifier(String text) {
3542
if (text == null) {
3643
throw new NullPointerException("Text is null");
@@ -42,18 +49,41 @@ public ScriptClassifier(String text) {
4249
nClassify(text, scripts);
4350
}
4451

52+
/**
53+
* Returns the text that the script classifier object was created for.
54+
*
55+
* @return The text that the script classifier object was created for.
56+
*/
4557
public String getText() {
4658
return text;
4759
}
4860

61+
/**
62+
* Returns a list containing the resolved scripts of all characters in source text. The valid
63+
* script values are available in {@link Script} class as static constants.
64+
*
65+
* @return A list containing the resolved scripts of all characters in source text.
66+
*/
4967
public IntList getCharScripts() {
5068
return new JByteArrayIntList(scripts, 0, scripts.length);
5169
}
5270

71+
/**
72+
* Returns an iterable of resolved script runs in source text.
73+
*
74+
* @return An iterable of resolved script runs in source text.
75+
*/
5376
public Iterable<ScriptRun> getScriptRuns() {
5477
return getScriptRuns(0, scripts.length);
5578
}
5679

80+
/**
81+
* Returns an iterable of resolved script runs within the specified range of source text.
82+
*
83+
* @param charStart The index to the first character in source text.
84+
* @param charEnd The index after the last character in source text.
85+
* @return An iterable of script runs within the specified range of source text.
86+
*/
5787
public Iterable<ScriptRun> getScriptRuns(int charStart, int charEnd) {
5888
if (charStart < 0) {
5989
throw new IllegalArgumentException("Char Start: " + charStart);
@@ -71,7 +101,6 @@ public Iterable<ScriptRun> getScriptRuns(int charStart, int charEnd) {
71101
private static native void nClassify(String text, byte[] scripts);
72102

73103
private static class RunIterator implements Iterator<ScriptRun> {
74-
75104
final byte[] scripts;
76105
final int end;
77106
int index;
@@ -112,7 +141,6 @@ public void remove() {
112141
}
113142

114143
private static class RunIterable implements Iterable<ScriptRun> {
115-
116144
final byte[] scripts;
117145
final int start;
118146
final int end;

0 commit comments

Comments
 (0)