5959 * Rules are typically loaded from resource files. These are UTF-8 encoded text files. They are systematically
6060 * named following the pattern:
6161 * </p>
62- * <blockquote>org/apache/commons/codec/language/bm/${NameType#getName}_${RuleType#getName}_${language}.txt</blockquote>
62+ * <blockquote>/ org/apache/commons/codec/language/bm/${NameType#getName}_${RuleType#getName}_${language}.txt</blockquote>
6363 * <p>
6464 * The format of these resources is the following:
6565 * </p>
8484 */
8585public class Rule {
8686
87+ /**
88+ * A phoneme.
89+ */
8790 public static final class Phoneme implements PhonemeExpr {
8891
92+ /**
93+ * The Phoneme Comparator.
94+ */
8995 public static final Comparator <Phoneme > COMPARATOR = (o1 , o2 ) -> {
9096 final int o1Length = o1 .phonemeText .length ();
9197 final int o2Length = o2 .phonemeText .length ();
@@ -105,30 +111,61 @@ public static final class Phoneme implements PhonemeExpr {
105111
106112 return 0 ;
107113 };
114+
108115 private final StringBuilder phonemeText ;
109116
110117 private final Languages .LanguageSet languages ;
111118
119+ /**
120+ * Constructs a new instance.
121+ *
122+ * @param phonemeText The phoneme text.
123+ * @param languages A language set.
124+ */
112125 public Phoneme (final CharSequence phonemeText , final Languages .LanguageSet languages ) {
113126 this .phonemeText = new StringBuilder (phonemeText );
114127 this .languages = languages ;
115128 }
116129
130+ /**
131+ * Constructs a new instance.
132+ *
133+ * @param phonemeLeft The left phoneme text.
134+ * @param phonemeRight The right phoneme text.
135+ */
117136 public Phoneme (final Phoneme phonemeLeft , final Phoneme phonemeRight ) {
118137 this (phonemeLeft .phonemeText , phonemeLeft .languages );
119138 this .phonemeText .append (phonemeRight .phonemeText );
120139 }
121140
141+ /**
142+ * Constructs a new instance.
143+ *
144+ * @param phonemeLeft The left phoneme text.
145+ * @param phonemeRight The right phoneme text.
146+ * @param languages A language set.
147+ */
122148 public Phoneme (final Phoneme phonemeLeft , final Phoneme phonemeRight , final Languages .LanguageSet languages ) {
123149 this (phonemeLeft .phonemeText , languages );
124150 this .phonemeText .append (phonemeRight .phonemeText );
125151 }
126152
127- public Phoneme append (final CharSequence str ) {
128- this .phonemeText .append (str );
153+ /**
154+ * Appends the sequence to the phone text.
155+ *
156+ * @param sequence The sequence to append.
157+ * @return this instance.
158+ */
159+ public Phoneme append (final CharSequence sequence ) {
160+ this .phonemeText .append (sequence );
129161 return this ;
130162 }
131163
164+ /**
165+ * Gets the language set.
166+ *
167+ * @return the language set.
168+ */
132169 public Languages .LanguageSet getLanguages () {
133170 return this .languages ;
134171 }
@@ -138,6 +175,11 @@ public Iterable<Phoneme> getPhonemes() {
138175 return Collections .singleton (this );
139176 }
140177
178+ /**
179+ * Gets the phoneme text sequence.
180+ *
181+ * @return the phoneme text sequence.
182+ */
141183 public CharSequence getPhonemeText () {
142184 return this .phonemeText ;
143185 }
@@ -177,7 +219,16 @@ public String toString() {
177219 }
178220 }
179221
222+ /**
223+ * A phoneme expression.
224+ */
180225 public interface PhonemeExpr {
226+
227+ /**
228+ * Gets an iteration of phonemes.
229+ *
230+ * @return an iteration of phonemes.
231+ */
181232 Iterable <Phoneme > getPhonemes ();
182233
183234 /**
@@ -192,10 +243,18 @@ default int size() {
192243 }
193244 }
194245
246+ /**
247+ * A list of phonemes.
248+ */
195249 public static final class PhonemeList implements PhonemeExpr {
196250
197251 private final List <Phoneme > phonemeList ;
198252
253+ /**
254+ * Constructs a new instance.
255+ *
256+ * @param phonemes the phoneme list.
257+ */
199258 public PhonemeList (final List <Phoneme > phonemes ) {
200259 this .phonemeList = phonemes ;
201260 }
@@ -215,11 +274,24 @@ public int size() {
215274 * A minimal wrapper around the functionality of Pattern that we use, to allow for alternate implementations.
216275 */
217276 public interface RPattern {
277+
278+ /**
279+ * Tests whether the given input matches this instance.
280+ *
281+ * @param input the input to test.
282+ * @return whether the given input matches this instance.
283+ */
218284 boolean isMatch (CharSequence input );
219285 }
220286
287+ /**
288+ * Always matches.
289+ */
221290 public static final RPattern ALL_STRINGS_RMATCHER = input -> true ;
222291
292+ /**
293+ * Unused.
294+ */
223295 public static final String ALL = "ALL" ;
224296
225297 private static final String DOUBLE_QUOTE = "\" " ;
0 commit comments