Skip to content

Commit 2c848fb

Browse files
committed
Remove extra vertical whitespace
1 parent 0d9a85d commit 2c848fb

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

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

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ public boolean equals(final Object other) {
106106
if (!(other instanceof Branch)) {
107107
return false;
108108
}
109-
110109
return toString().equals(((Branch) other).toString());
111110
}
112111

@@ -135,7 +134,6 @@ public int hashCode() {
135134
*/
136135
private void processNextReplacement(final String replacement, final boolean forceAppend) {
137136
final boolean append = lastReplacement == null || !lastReplacement.endsWith(replacement) || forceAppend;
138-
139137
if (append && builder.length() < MAX_LENGTH) {
140138
builder.append(replacement);
141139
// remove all characters after the maximum length
@@ -144,7 +142,6 @@ private void processNextReplacement(final String replacement, final boolean forc
144142
}
145143
cachedString = null;
146144
}
147-
148145
lastReplacement = replacement;
149146
}
150147

@@ -236,28 +233,24 @@ public String toString() {
236233
try (Scanner scanner = new Scanner(Resources.getInputStream(RESOURCE_FILE), CharEncoding.UTF_8)) {
237234
parseRules(scanner, RESOURCE_FILE, RULES, FOLDINGS);
238235
}
239-
240236
// sort RULES by pattern length in descending order
241237
RULES.forEach((k, v) -> v.sort((rule1, rule2) -> rule2.getPatternLength() - rule1.getPatternLength()));
242238
}
243239

244-
private static void parseRules(final Scanner scanner, final String location,
245-
final Map<Character, List<Rule>> ruleMapping, final Map<Character, Character> asciiFoldings) {
240+
private static void parseRules(final Scanner scanner, final String location, final Map<Character, List<Rule>> ruleMapping,
241+
final Map<Character, Character> asciiFoldings) {
246242
int currentLine = 0;
247243
boolean inMultilineComment = false;
248-
249244
while (scanner.hasNextLine()) {
250245
currentLine++;
251246
final String rawLine = scanner.nextLine();
252247
String line = rawLine;
253-
254248
if (inMultilineComment) {
255249
if (line.endsWith(MULTILINE_COMMENT_END)) {
256250
inMultilineComment = false;
257251
}
258252
continue;
259253
}
260-
261254
if (line.startsWith(MULTILINE_COMMENT_START)) {
262255
inMultilineComment = true;
263256
} else {
@@ -266,50 +259,41 @@ private static void parseRules(final Scanner scanner, final String location,
266259
if (cmtI >= 0) {
267260
line = line.substring(0, cmtI);
268261
}
269-
270262
// trim leading-trailing whitespace
271263
line = line.trim();
272-
273264
if (line.isEmpty()) {
274265
continue; // empty lines can be safely skipped
275266
}
276-
277267
if (line.contains("=")) {
278268
// folding
279269
final String[] parts = EQUAL.split(line);
280270
if (parts.length != 2) {
281-
throw new IllegalArgumentException("Malformed folding statement split into " + parts.length +
282-
" parts: " + rawLine + " in " + location);
271+
throw new IllegalArgumentException("Malformed folding statement split into " + parts.length + " parts: " + rawLine + " in " + location);
283272
}
284273
final String leftCharacter = parts[0];
285274
final String rightCharacter = parts[1];
286-
287275
if (leftCharacter.length() != 1 || rightCharacter.length() != 1) {
288-
throw new IllegalArgumentException("Malformed folding statement - " +
289-
"patterns are not single characters: " + rawLine + " in " + location);
276+
throw new IllegalArgumentException(
277+
"Malformed folding statement - " + "patterns are not single characters: " + rawLine + " in " + location);
290278
}
291-
292279
asciiFoldings.put(leftCharacter.charAt(0), rightCharacter.charAt(0));
293280
} else {
294281
// rule
295282
final String[] parts = SPACES.split(line);
296283
if (parts.length != 4) {
297-
throw new IllegalArgumentException("Malformed rule statement split into " + parts.length +
298-
" parts: " + rawLine + " in " + location);
284+
throw new IllegalArgumentException("Malformed rule statement split into " + parts.length + " parts: " + rawLine + " in " + location);
299285
}
300286
try {
301287
final String pattern = stripQuotes(parts[0]);
302288
final String replacement1 = stripQuotes(parts[1]);
303289
final String replacement2 = stripQuotes(parts[2]);
304290
final String replacement3 = stripQuotes(parts[3]);
305-
306291
final Rule r = new Rule(pattern, replacement1, replacement2, replacement3);
307292
final char patternKey = r.pattern.charAt(0);
308293
final List<Rule> rules = ruleMapping.computeIfAbsent(patternKey, k -> new ArrayList<>());
309294
rules.add(r);
310295
} catch (final IllegalArgumentException e) {
311-
throw new IllegalStateException(
312-
"Problem parsing line '" + currentLine + "' in " + location, e);
296+
throw new IllegalStateException("Problem parsing line '" + currentLine + "' in " + location, e);
313297
}
314298
}
315299
}
@@ -320,11 +304,9 @@ private static String stripQuotes(String str) {
320304
if (str.startsWith(DOUBLE_QUOTE)) {
321305
str = str.substring(1);
322306
}
323-
324307
if (str.endsWith(DOUBLE_QUOTE)) {
325308
str = str.substring(0, str.length() - 1);
326309
}
327-
328310
return str;
329311
}
330312

@@ -368,7 +350,6 @@ private String cleanup(final String input) {
368350
if (Character.isWhitespace(ch)) {
369351
continue;
370352
}
371-
372353
ch = Character.toLowerCase(ch);
373354
final Character character = FOLDINGS.get(ch);
374355
if (folding && character != null) {
@@ -484,17 +465,13 @@ private String[] soundex(final String source, final boolean branching) {
484465
}
485466
final String[] replacements = rule.getReplacements(inputContext, lastChar == '\0');
486467
final boolean branchingRequired = replacements.length > 1 && branching;
487-
488468
for (final Branch branch : currentBranches) {
489469
for (final String nextReplacement : replacements) {
490470
// if we have multiple replacements, always create a new branch
491471
final Branch nextBranch = branchingRequired ? branch.createBranch() : branch;
492-
493472
// special rule: occurrences of mn or nm are treated differently
494473
final boolean force = lastChar == 'm' && ch == 'n' || lastChar == 'n' && ch == 'm';
495-
496474
nextBranch.processNextReplacement(nextReplacement, force);
497-
498475
if (!branching) {
499476
break;
500477
}

0 commit comments

Comments
 (0)