Skip to content

Commit d9233f5

Browse files
committed
Javadoc
1 parent 76b9468 commit d9233f5

File tree

6 files changed

+187
-306
lines changed

6 files changed

+187
-306
lines changed

src/main/java/org/apache/commons/codec/StringDecoder.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ public interface StringDecoder extends Decoder {
2525
/**
2626
* Decodes a String and returns a String.
2727
*
28-
* @param source
29-
* the String to decode
30-
* @return the encoded String
31-
* @throws DecoderException
32-
* thrown if there is an error condition during the Encoding process.
28+
* @param source the String to decode.
29+
* @return the encoded String.
30+
* @throws DecoderException thrown if there is an error condition during the Encoding process.
3331
*/
3432
String decode(String source) throws DecoderException;
3533
}
36-

src/main/java/org/apache/commons/codec/StringEncoder.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ public interface StringEncoder extends Encoder {
2525
/**
2626
* Encodes a String and returns a String.
2727
*
28-
* @param source
29-
* the String to encode
30-
* @return the encoded String
31-
* @throws EncoderException
32-
* thrown if there is an error condition during the encoding process.
28+
* @param source the String to encode.
29+
* @return the encoded String.
30+
* @throws EncoderException thrown if there is an error condition during the encoding process.
3331
*/
3432
String encode(String source) throws EncoderException;
3533
}
36-

src/main/java/org/apache/commons/codec/language/Soundex.java

Lines changed: 42 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@
2121
import org.apache.commons.codec.StringEncoder;
2222

2323
/**
24-
* Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a
25-
* general purpose scheme to find word with similar phonemes.
24+
* Encodes a string into a Soundex value. Soundex is an encoding used to relate similar names, but can also be used as a general purpose scheme to find word
25+
* with similar phonemes.
2626
*
27-
* <p>This class is thread-safe.
28-
* Although not strictly immutable, the mutable fields are not actually used.</p>
27+
* <p>
28+
* This class is thread-safe. Although not strictly immutable, the mutable fields are not actually used.
29+
* </p>
2930
*/
3031
public class Soundex implements StringEncoder {
3132

3233
/**
33-
* The marker character used to indicate a silent (ignored) character.
34-
* These are ignored except when they appear as the first character.
34+
* The marker character used to indicate a silent (ignored) character. These are ignored except when they appear as the first character.
3535
* <p>
36-
* Note: The {@link #US_ENGLISH_MAPPING_STRING} does not use this mechanism
37-
* because changing it might break existing code. Mappings that don't contain
38-
* a silent marker code are treated as though H and W are silent.
36+
* Note: The {@link #US_ENGLISH_MAPPING_STRING} does not use this mechanism because changing it might break existing code. Mappings that don't contain a
37+
* silent marker code are treated as though H and W are silent.
3938
* </p>
4039
* <p>
4140
* To override this, use the {@link #Soundex(String, boolean)} constructor.
@@ -46,69 +45,57 @@ public class Soundex implements StringEncoder {
4645
public static final char SILENT_MARKER = '-';
4746

4847
/**
49-
* This is a default mapping of the 26 letters used in US English. A value of {@code 0} for a letter position
50-
* means do not encode, but treat as a separator when it occurs between consonants with the same code.
48+
* This is a default mapping of the 26 letters used in US English. A value of {@code 0} for a letter position means do not encode, but treat as a separator
49+
* when it occurs between consonants with the same code.
5150
* <p>
52-
* (This constant is provided as both an implementation convenience and to allow Javadoc to pick
53-
* up the value for the constant values page.)
51+
* (This constant is provided as both an implementation convenience and to allow Javadoc to pick up the value for the constant values page.)
5452
* </p>
5553
* <p>
56-
* <strong>Note that letters H and W are treated specially.</strong>
57-
* They are ignored (after the first letter) and don't act as separators
58-
* between consonants with the same code.
54+
* <strong>Note that letters H and W are treated specially.</strong> They are ignored (after the first letter) and don't act as separators between
55+
* consonants with the same code.
5956
* </p>
6057
*/
6158
public static final String US_ENGLISH_MAPPING_STRING = "01230120022455012623010202";
6259

6360
/**
64-
* This is a default mapping of the 26 letters used in US English. A value of {@code 0} for a letter position
65-
* means do not encode.
61+
* This is a default mapping of the 26 letters used in US English. A value of {@code 0} for a letter position means do not encode.
6662
*
6763
* @see Soundex#Soundex(char[])
6864
*/
6965
private static final char[] US_ENGLISH_MAPPING = US_ENGLISH_MAPPING_STRING.toCharArray();
7066

7167
/**
72-
* An instance of Soundex using the US_ENGLISH_MAPPING mapping.
73-
* This treats H and W as silent letters.
74-
* Apart from when they appear as the first letter, they are ignored.
75-
* They don't act as separators between duplicate codes.
68+
* An instance of Soundex using the US_ENGLISH_MAPPING mapping. This treats H and W as silent letters. Apart from when they appear as the first letter, they
69+
* are ignored. They don't act as separators between duplicate codes.
7670
*
7771
* @see #US_ENGLISH_MAPPING_STRING
7872
*/
7973
public static final Soundex US_ENGLISH = new Soundex();
8074

8175
/**
82-
* An instance of Soundex using the Simplified Soundex mapping, as described here:
83-
* http://west-penwith.org.uk/misc/soundex.htm
76+
* An instance of Soundex using the Simplified Soundex mapping, as described here: http://west-penwith.org.uk/misc/soundex.htm
8477
* <p>
85-
* This treats H and W the same as vowels (AEIOUY).
86-
* Such letters aren't encoded (after the first), but they do
87-
* act as separators when dropping duplicate codes.
88-
* The mapping is otherwise the same as for {@link #US_ENGLISH}
78+
* This treats H and W the same as vowels (AEIOUY). Such letters aren't encoded (after the first), but they do act as separators when dropping duplicate
79+
* codes. The mapping is otherwise the same as for {@link #US_ENGLISH}.
8980
* </p>
9081
*
9182
* @since 1.11
9283
*/
9384
public static final Soundex US_ENGLISH_SIMPLIFIED = new Soundex(US_ENGLISH_MAPPING_STRING, false);
9485

9586
/**
96-
* An instance of Soundex using the mapping as per the Genealogy site:
97-
* http://www.genealogy.com/articles/research/00000060.html
87+
* An instance of Soundex using the mapping as per the Genealogy site: http://www.genealogy.com/articles/research/00000060.html
9888
* <p>
99-
* This treats vowels (AEIOUY), H and W as silent letters.
100-
* Such letters are ignored (after the first) and do not
101-
* act as separators when dropping duplicate codes.
89+
* This treats vowels (AEIOUY), H and W as silent letters. Such letters are ignored (after the first) and do not act as separators when dropping duplicate
90+
* codes.
10291
* </p>
10392
* <p>
104-
* The codes for consonants are otherwise the same as for
105-
* {@link #US_ENGLISH_MAPPING_STRING} and {@link #US_ENGLISH_SIMPLIFIED}
93+
* The codes for consonants are otherwise the same as for {@link #US_ENGLISH_MAPPING_STRING} and {@link #US_ENGLISH_SIMPLIFIED}.
10694
* </p>
10795
*
10896
* @since 1.11
10997
*/
11098
public static final Soundex US_ENGLISH_GENEALOGY = new Soundex("-123-12--22455-12623-1-2-2");
111-
// ABCDEFGHIJKLMNOPQRSTUVWXYZ
11299

113100
/**
114101
* The maximum length of a Soundex code - Soundex codes are only four characters by definition.
@@ -119,17 +106,16 @@ public class Soundex implements StringEncoder {
119106
private int maxLength = 4;
120107

121108
/**
122-
* Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
123-
* letter is mapped. This implementation contains a default map for US_ENGLISH
109+
* Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each letter is mapped. This implementation
110+
* contains a default map for US_ENGLISH.
124111
*/
125112
private final char[] soundexMapping;
126113

127114
/**
128115
* Should H and W be treated specially?
129116
* <p>
130-
* In versions of the code prior to 1.11,
131-
* the code always treated H and W as silent (ignored) letters.
132-
* If this field is false, H and W are no longer special-cased.
117+
* In versions of the code prior to 1.11, the code always treated H and W as silent (ignored) letters. If this field is false, H and W are no longer
118+
* special-cased.
133119
* </p>
134120
*/
135121
private final boolean specialCaseHW;
@@ -146,33 +132,30 @@ public Soundex() {
146132
}
147133

148134
/**
149-
* Creates a Soundex instance using the given mapping. This constructor can be used to provide an internationalized
150-
* mapping for a non-Western character set.
135+
* Creates a Soundex instance using the given mapping. This constructor can be used to provide an internationalized mapping for a non-Western character set.
151136
* <p>
152-
* Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each
153-
* letter is mapped. This implementation contains a default map for US_ENGLISH
137+
* Every letter of the alphabet is "mapped" to a numerical value. This char array holds the values to which each letter is mapped. This implementation
138+
* contains a default map for US_ENGLISH
154139
* </p>
155140
* <p>
156141
* If the mapping contains an instance of {@link #SILENT_MARKER} then H and W are not given special treatment.
157142
* </p>
158143
*
159-
* @param mapping
160-
* Mapping array to use when finding the corresponding code for a given character.
144+
* @param mapping Mapping array to use when finding the corresponding code for a given character.
161145
*/
162146
public Soundex(final char[] mapping) {
163147
this.soundexMapping = mapping.clone();
164148
this.specialCaseHW = !hasMarker(this.soundexMapping);
165149
}
166150

167151
/**
168-
* Creates a refined Soundex instance using a custom mapping. This constructor can be used to customize the mapping,
169-
* and/or possibly provide an internationalized mapping for a non-Western character set.
152+
* Creates a refined Soundex instance using a custom mapping. This constructor can be used to customize the mapping, and/or possibly provide an
153+
* internationalized mapping for a non-Western character set.
170154
* <p>
171155
* If the mapping contains an instance of {@link #SILENT_MARKER} then H and W are not given special treatment.
172156
* </p>
173157
*
174-
* @param mapping
175-
* Mapping string to use when finding the corresponding code for a given character.
158+
* @param mapping Mapping string to use when finding the corresponding code for a given character.
176159
* @since 1.4
177160
*/
178161
public Soundex(final String mapping) {
@@ -181,12 +164,11 @@ public Soundex(final String mapping) {
181164
}
182165

183166
/**
184-
* Creates a refined Soundex instance using a custom mapping. This constructor can be used to customize the mapping,
185-
* and/or possibly provide an internationalized mapping for a non-Western character set.
167+
* Creates a refined Soundex instance using a custom mapping. This constructor can be used to customize the mapping, and/or possibly provide an
168+
* internationalized mapping for a non-Western character set.
186169
*
187-
* @param mapping
188-
* Mapping string to use when finding the corresponding code for a given character.
189-
* @param specialCaseHW if true, then
170+
* @param mapping Mapping string to use when finding the corresponding code for a given character.
171+
* @param specialCaseHW if true, then H and W are treated as silent letters that are ignored and do not act as separators between duplicate codes.
190172
* @since 1.11
191173
*/
192174
public Soundex(final String mapping, final boolean specialCaseHW) {
@@ -203,7 +185,6 @@ public Soundex(final String mapping, final boolean specialCaseHW) {
203185
* @return The number of characters in the two encoded Strings that are the same from 0 to 4.
204186
* @see SoundexUtils#difference(StringEncoder,String,String)
205187
* @see <a href="https://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_de-dz_8co5.asp"> MS T-SQL DIFFERENCE</a>
206-
*
207188
* @throws EncoderException if an error occurs encoding one of the strings.
208189
* @since 1.3
209190
*/
@@ -243,8 +224,8 @@ public String encode(final String str) {
243224
/**
244225
* Returns the maxLength. Standard Soundex
245226
*
246-
* @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
247227
* @return the maxLength.
228+
* @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
248229
*/
249230
@Deprecated
250231
public int getMaxLength() {
@@ -263,11 +244,9 @@ private boolean hasMarker(final char[] mapping) {
263244
/**
264245
* Maps the given upper-case character to its Soundex code.
265246
*
266-
* @param ch
267-
* An upper-case character.
247+
* @param ch An upper-case character.
268248
* @return A Soundex code.
269-
* @throws IllegalArgumentException
270-
* Thrown if {@code ch} is not mapped.
249+
* @throws IllegalArgumentException Thrown if {@code ch} is not mapped.
271250
*/
272251
private char map(final char ch) {
273252
final int index = ch - 'A';
@@ -281,8 +260,7 @@ private char map(final char ch) {
281260
* Sets the maxLength.
282261
*
283262
* @deprecated This feature is not needed since the encoding size must be constant. Will be removed in 2.0.
284-
* @param maxLength
285-
* The maxLength to set.
263+
* @param maxLength The maxLength to set.
286264
*/
287265
@Deprecated
288266
public void setMaxLength(final int maxLength) {
@@ -325,5 +303,4 @@ public String soundex(String str) {
325303
}
326304
return new String(out);
327305
}
328-
329306
}

0 commit comments

Comments
 (0)