Skip to content

Commit 3ac0571

Browse files
committed
Make code less twisty.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/codec/trunk@130372 13f79535-47bb-0310-9956-ffa450edef68
1 parent a175e52 commit 3ac0571

3 files changed

Lines changed: 30 additions & 36 deletions

File tree

src/java/org/apache/commons/codec/language/DoubleMetaphone.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* </ul>
3232
*
3333
* @author Apache Software Foundation
34-
* @version $Id: DoubleMetaphone.java,v 1.22 2004/05/24 00:28:10 ggregory Exp $
34+
* @version $Id: DoubleMetaphone.java,v 1.23 2004/05/24 04:55:33 ggregory Exp $
3535
*/
3636
public class DoubleMetaphone implements StringEncoder {
3737

@@ -869,21 +869,20 @@ private boolean conditionL0(String value, int index) {
869869
* Complex condition 0 for 'M'
870870
*/
871871
private boolean conditionM0(String value, int index) {
872-
if (charAt(value, index + 1) == 'M') {
873-
return true;
874-
} else {
875-
return contains(value, index - 1, 3, "UMB") &&
876-
((index + 1) == value.length() - 1 ||
877-
contains(value, index + 2, 2, "ER"));
878-
}
879-
}
872+
if (charAt(value, index + 1) == 'M') {
873+
return true;
874+
}
875+
return contains(value, index - 1, 3, "UMB")
876+
&& ((index + 1) == value.length() - 1 || contains(value,
877+
index + 2, 2, "ER"));
878+
}
880879

881880
//-- BEGIN HELPER FUNCTIONS --//
882881

883882
/**
884-
* Determines whether or not a value is of slavo-germanic orgin. A value is
885-
* of slavo-germanic origin if it contians any of 'W', 'K', 'CZ', or 'WITZ'.
886-
*/
883+
* Determines whether or not a value is of slavo-germanic orgin. A value is
884+
* of slavo-germanic origin if it contians any of 'W', 'K', 'CZ', or 'WITZ'.
885+
*/
887886
private boolean isSlavoGermanic(String value) {
888887
return value.indexOf('W') > -1 || value.indexOf('K') > -1 ||
889888
value.indexOf("CZ") > -1 || value.indexOf("WITZ") > -1;
@@ -916,29 +915,26 @@ private boolean isSilentStart(String value) {
916915
* Cleans the input
917916
*/
918917
private String cleanInput(String input) {
919-
if (input == null) {
920-
return null;
921-
} else {
922-
input = input.trim();
923-
if (input.length() == 0) {
924-
return null;
925-
} else {
926-
return input.toUpperCase();
927-
}
928-
}
929-
}
918+
if (input == null) {
919+
return null;
920+
}
921+
input = input.trim();
922+
if (input.length() == 0) {
923+
return null;
924+
}
925+
return input.toUpperCase();
926+
}
930927

931928
/**
932-
* Gets the character at index <code>index</code> if available, otherwise it
933-
* returns <code>Character.MIN_VALUE</code> so that there is some sort of a
934-
* default
935-
*/
929+
* Gets the character at index <code>index</code> if available, otherwise
930+
* it returns <code>Character.MIN_VALUE</code> so that there is some sort
931+
* of a default
932+
*/
936933
protected char charAt(String value, int index) {
937934
if (index < 0 || index >= value.length()) {
938935
return Character.MIN_VALUE;
939-
} else {
940-
return value.charAt(index);
941-
}
936+
}
937+
return value.charAt(index);
942938
}
943939

944940
/**

src/java/org/apache/commons/codec/language/Metaphone.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* <i>Computer Language</i> of Dec. 1990, p 39
2929
*
3030
* @author Apache Software Foundation
31-
* @version $Id: Metaphone.java,v 1.18 2004/05/24 00:22:45 ggregory Exp $
31+
* @version $Id: Metaphone.java,v 1.19 2004/05/24 04:56:29 ggregory Exp $
3232
*/
3333
public class Metaphone implements StringEncoder {
3434

@@ -141,9 +141,8 @@ public String metaphone(String txt) {
141141
if ( isPreviousChar(local, n, 'M') &&
142142
isLastChar(wdsz, n) ) { // B is silent if word ends in MB
143143
break;
144-
} else {
145-
code.append(symb);
146144
}
145+
code.append(symb);
147146
break;
148147
case 'C' : // lots of C special cases
149148
/* discard if SCI, SCE or SCY */

src/java/org/apache/commons/codec/language/RefinedSoundex.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Margaret Odell and Robert Russell
2626
*
2727
* @author Apache Software Foundation
28-
* @version $Id: RefinedSoundex.java,v 1.19 2004/05/24 00:23:17 ggregory Exp $
28+
* @version $Id: RefinedSoundex.java,v 1.20 2004/05/24 04:57:24 ggregory Exp $
2929
*/
3030
public class RefinedSoundex implements StringEncoder {
3131

@@ -139,9 +139,8 @@ public String encode(String pString) {
139139
char getMappingCode(char c) {
140140
if (!Character.isLetter(c)) {
141141
return 0;
142-
} else {
143-
return this.soundexMapping[Character.toUpperCase(c) - 'A'];
144142
}
143+
return this.soundexMapping[Character.toUpperCase(c) - 'A'];
145144
}
146145

147146
/**

0 commit comments

Comments
 (0)