This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
The following commit(s) were added to refs/heads/master by this push:
new 482df6c No need to nest in else.
482df6c is described below
commit 482df6cabfb288acb6ab3e4a732fdb93aecfa7c2
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Mar 5 13:31:09 2021 -0500
No need to nest in else.
---
.../apache/commons/codec/binary/BaseNCodec.java | 6 +--
.../codec/binary/BaseNCodecInputStream.java | 63 +++++++++++-----------
.../codec/binary/BaseNCodecOutputStream.java | 6 ++-
.../java/org/apache/commons/codec/binary/Hex.java | 17 +++---
.../org/apache/commons/codec/digest/Crypt.java | 12 +++--
.../codec/language/DaitchMokotoffSoundex.java | 5 +-
.../commons/codec/language/DoubleMetaphone.java | 54 ++++++++++---------
.../codec/language/MatchRatingApproachEncoder.java | 9 ++--
.../commons/codec/language/RefinedSoundex.java | 3 +-
.../commons/codec/language/bm/Languages.java | 30 +++++------
.../org/apache/commons/codec/language/bm/Rule.java | 18 ++++---
.../java/org/apache/commons/codec/net/BCodec.java | 20 +++----
.../org/apache/commons/codec/net/PercentCodec.java | 12 ++---
.../java/org/apache/commons/codec/net/QCodec.java | 20 +++----
.../commons/codec/net/QuotedPrintableCodec.java | 26 ++++-----
.../org/apache/commons/codec/net/URLCodec.java | 20 +++----
16 files changed, 171 insertions(+), 150 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
index 256d1f1..b054253 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
@@ -456,11 +456,11 @@ public abstract class BaseNCodec implements
BinaryEncoder, BinaryDecoder {
public Object decode(final Object obj) throws DecoderException {
if (obj instanceof byte[]) {
return decode((byte[]) obj);
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return decode((String) obj);
- } else {
- throw new DecoderException("Parameter supplied to Base-N decode is
not a byte[] or a String");
}
+ throw new DecoderException("Parameter supplied to Base-N decode is not
a byte[] or a String");
}
/**
diff --git
a/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
b/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
index ff99e5c..f225aab 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
@@ -145,42 +145,43 @@ public class BaseNCodecInputStream extends
FilterInputStream {
Objects.requireNonNull(array, "array");
if (offset < 0 || len < 0) {
throw new IndexOutOfBoundsException();
- } else if (offset > array.length || offset + len > array.length) {
+ }
+ if (offset > array.length || offset + len > array.length) {
throw new IndexOutOfBoundsException();
- } else if (len == 0) {
+ }
+ if (len == 0) {
return 0;
- } else {
- int readLen = 0;
- /*
- Rationale for while-loop on (readLen == 0):
- -----
- Base32.readResults() usually returns > 0 or EOF (-1). In the
- rare case where it returns 0, we just keep trying.
-
- This is essentially an undocumented contract for InputStream
- implementors that want their code to work properly with
- java.io.InputStreamReader, since the latter hates it when
- InputStream.read(byte[]) returns a zero. Unfortunately our
- readResults() call must return 0 if a large amount of the data
- being decoded was non-base32, so this while-loop enables proper
- interop with InputStreamReader for that scenario.
- -----
- This is a fix for CODEC-101
- */
- while (readLen == 0) {
- if (!baseNCodec.hasData(context)) {
- final byte[] buf = new byte[doEncode ? 4096 : 8192];
- final int c = in.read(buf);
- if (doEncode) {
- baseNCodec.encode(buf, 0, c, context);
- } else {
- baseNCodec.decode(buf, 0, c, context);
- }
+ }
+ int readLen = 0;
+ /*
+ Rationale for while-loop on (readLen == 0):
+ -----
+ Base32.readResults() usually returns > 0 or EOF (-1). In the
+ rare case where it returns 0, we just keep trying.
+
+ This is essentially an undocumented contract for InputStream
+ implementors that want their code to work properly with
+ java.io.InputStreamReader, since the latter hates it when
+ InputStream.read(byte[]) returns a zero. Unfortunately our
+ readResults() call must return 0 if a large amount of the data
+ being decoded was non-base32, so this while-loop enables proper
+ interop with InputStreamReader for that scenario.
+ -----
+ This is a fix for CODEC-101
+ */
+ while (readLen == 0) {
+ if (!baseNCodec.hasData(context)) {
+ final byte[] buf = new byte[doEncode ? 4096 : 8192];
+ final int c = in.read(buf);
+ if (doEncode) {
+ baseNCodec.encode(buf, 0, c, context);
+ } else {
+ baseNCodec.decode(buf, 0, c, context);
}
- readLen = baseNCodec.readResults(array, offset, len, context);
}
- return readLen;
+ readLen = baseNCodec.readResults(array, offset, len, context);
}
+ return readLen;
}
/**
diff --git
a/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
b/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
index 074f96d..16cb6cd 100644
--- a/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
+++ b/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
@@ -166,9 +166,11 @@ public class BaseNCodecOutputStream extends
FilterOutputStream {
Objects.requireNonNull(array, "array");
if (offset < 0 || len < 0) {
throw new IndexOutOfBoundsException();
- } else if (offset > array.length || offset + len > array.length) {
+ }
+ if (offset > array.length || offset + len > array.length) {
throw new IndexOutOfBoundsException();
- } else if (len > 0) {
+ }
+ if (len > 0) {
if (doEncode) {
baseNCodec.encode(array, offset, len, context);
} else {
diff --git a/src/main/java/org/apache/commons/codec/binary/Hex.java
b/src/main/java/org/apache/commons/codec/binary/Hex.java
index 7075ab9..5e086b6 100644
--- a/src/main/java/org/apache/commons/codec/binary/Hex.java
+++ b/src/main/java/org/apache/commons/codec/binary/Hex.java
@@ -451,16 +451,17 @@ public class Hex implements BinaryEncoder, BinaryDecoder {
public Object decode(final Object object) throws DecoderException {
if (object instanceof String) {
return decode(((String) object).toCharArray());
- } else if (object instanceof byte[]) {
+ }
+ if (object instanceof byte[]) {
return decode((byte[]) object);
- } else if (object instanceof ByteBuffer) {
+ }
+ if (object instanceof ByteBuffer) {
return decode((ByteBuffer) object);
- } else {
- try {
- return decodeHex((char[]) object);
- } catch (final ClassCastException e) {
- throw new DecoderException(e.getMessage(), e);
- }
+ }
+ try {
+ return decodeHex((char[]) object);
+ } catch (final ClassCastException e) {
+ throw new DecoderException(e.getMessage(), e);
}
}
diff --git a/src/main/java/org/apache/commons/codec/digest/Crypt.java
b/src/main/java/org/apache/commons/codec/digest/Crypt.java
index e73ec9f..f6ac066 100644
--- a/src/main/java/org/apache/commons/codec/digest/Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Crypt.java
@@ -74,15 +74,17 @@ public class Crypt {
public static String crypt(final byte[] keyBytes, final String salt) {
if (salt == null) {
return Sha2Crypt.sha512Crypt(keyBytes);
- } else if (salt.startsWith(Sha2Crypt.SHA512_PREFIX)) {
+ }
+ if (salt.startsWith(Sha2Crypt.SHA512_PREFIX)) {
return Sha2Crypt.sha512Crypt(keyBytes, salt);
- } else if (salt.startsWith(Sha2Crypt.SHA256_PREFIX)) {
+ }
+ if (salt.startsWith(Sha2Crypt.SHA256_PREFIX)) {
return Sha2Crypt.sha256Crypt(keyBytes, salt);
- } else if (salt.startsWith(Md5Crypt.MD5_PREFIX)) {
+ }
+ if (salt.startsWith(Md5Crypt.MD5_PREFIX)) {
return Md5Crypt.md5Crypt(keyBytes, salt);
- } else {
- return UnixCrypt.crypt(keyBytes, salt);
}
+ return UnixCrypt.crypt(keyBytes, salt);
}
/**
diff --git
a/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
b/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
index cff0f1e..4d4c74a 100644
--- a/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
+++ b/src/main/java/org/apache/commons/codec/language/DaitchMokotoffSoundex.java
@@ -520,11 +520,10 @@ public class DaitchMokotoffSoundex implements
StringEncoder {
nextBranch.processNextReplacement(nextReplacement,
force);
- if (branching) {
- nextBranches.add(nextBranch);
- } else {
+ if (!branching) {
break;
}
+ nextBranches.add(nextBranch);
}
}
diff --git
a/src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java
b/src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java
index 63e0922..ec2a2e0 100644
--- a/src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java
+++ b/src/main/java/org/apache/commons/codec/language/DoubleMetaphone.java
@@ -354,26 +354,27 @@ public class DoubleMetaphone implements StringEncoder {
if (index > 0 && contains(value, index, 4, "CHAE")) { // Michael
result.append('K', 'X');
return index + 2;
- } else if (conditionCH0(value, index)) {
+ }
+ if (conditionCH0(value, index)) {
//-- Greek roots ("chemistry", "chorus", etc.) --//
result.append('K');
return index + 2;
- } else if (conditionCH1(value, index)) {
+ }
+ if (conditionCH1(value, index)) {
//-- Germanic, Greek, or otherwise 'ch' for 'kh' sound --//
result.append('K');
return index + 2;
- } else {
- if (index > 0) {
- if (contains(value, 0, 2, "MC")) {
- result.append('K');
- } else {
- result.append('X', 'K');
- }
+ }
+ if (index > 0) {
+ if (contains(value, 0, 2, "MC")) {
+ result.append('K');
} else {
- result.append('X');
+ result.append('X', 'K');
}
- return index + 2;
+ } else {
+ result.append('X');
}
+ return index + 2;
}
/**
@@ -779,17 +780,19 @@ public class DoubleMetaphone implements StringEncoder {
private boolean conditionC0(final String value, final int index) {
if (contains(value, index, 4, "CHIA")) {
return true;
- } else if (index <= 1) {
+ }
+ if (index <= 1) {
return false;
- } else if (isVowel(charAt(value, index - 2))) {
+ }
+ if (isVowel(charAt(value, index - 2))) {
return false;
- } else if (!contains(value, index - 1, 3, "ACH")) {
+ }
+ if (!contains(value, index - 1, 3, "ACH")) {
return false;
- } else {
- final char c = charAt(value, index + 2);
- return (c != 'I' && c != 'E') ||
- contains(value, index - 2, 6, "BACHER", "MACHER");
}
+ final char c = charAt(value, index + 2);
+ return (c != 'I' && c != 'E') ||
+ contains(value, index - 2, 6, "BACHER", "MACHER");
}
/**
@@ -798,14 +801,15 @@ public class DoubleMetaphone implements StringEncoder {
private boolean conditionCH0(final String value, final int index) {
if (index != 0) {
return false;
- } else if (!contains(value, index + 1, 5, "HARAC", "HARIS") &&
+ }
+ if (!contains(value, index + 1, 5, "HARAC", "HARIS") &&
!contains(value, index + 1, 3, "HOR", "HYM", "HIA", "HEM"))
{
return false;
- } else if (contains(value, 0, 5, "CHORE")) {
+ }
+ if (contains(value, 0, 5, "CHORE")) {
return false;
- } else {
- return true;
}
+ return true;
}
/**
@@ -826,13 +830,13 @@ public class DoubleMetaphone implements StringEncoder {
if (index == value.length() - 3 &&
contains(value, index - 1, 4, "ILLO", "ILLA", "ALLE")) {
return true;
- } else if ((contains(value, value.length() - 2, 2, "AS", "OS") ||
+ }
+ if ((contains(value, value.length() - 2, 2, "AS", "OS") ||
contains(value, value.length() - 1, 1, "A", "O")) &&
contains(value, index - 1, 4, "ALLE")) {
return true;
- } else {
- return false;
}
+ return false;
}
/**
diff --git
a/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
b/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
index 50f6e81..dc56fb4 100644
---
a/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
+++
b/src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java
@@ -212,11 +212,14 @@ public class MatchRatingApproachEncoder implements
StringEncoder {
// Bulletproof for trivial input - NINO
if (name1 == null || EMPTY.equalsIgnoreCase(name1) ||
SPACE.equalsIgnoreCase(name1)) {
return false;
- } else if (name2 == null || EMPTY.equalsIgnoreCase(name2) ||
SPACE.equalsIgnoreCase(name2)) {
+ }
+ if (name2 == null || EMPTY.equalsIgnoreCase(name2) ||
SPACE.equalsIgnoreCase(name2)) {
return false;
- } else if (name1.length() == 1 || name2.length() == 1) {
+ }
+ if (name1.length() == 1 || name2.length() == 1) {
return false;
- } else if (name1.equalsIgnoreCase(name2)) {
+ }
+ if (name1.equalsIgnoreCase(name2)) {
return true;
}
diff --git
a/src/main/java/org/apache/commons/codec/language/RefinedSoundex.java
b/src/main/java/org/apache/commons/codec/language/RefinedSoundex.java
index e98f1a0..72a914a 100644
--- a/src/main/java/org/apache/commons/codec/language/RefinedSoundex.java
+++ b/src/main/java/org/apache/commons/codec/language/RefinedSoundex.java
@@ -204,7 +204,8 @@ public class RefinedSoundex implements StringEncoder {
current = getMappingCode(str.charAt(i));
if (current == last) {
continue;
- } else if (current != 0) {
+ }
+ if (current != 0) {
sBuf.append(current);
}
diff --git a/src/main/java/org/apache/commons/codec/language/bm/Languages.java
b/src/main/java/org/apache/commons/codec/language/bm/Languages.java
index 778b072..4e058ed 100644
--- a/src/main/java/org/apache/commons/codec/language/bm/Languages.java
+++ b/src/main/java/org/apache/commons/codec/language/bm/Languages.java
@@ -120,32 +120,32 @@ public class Languages {
public LanguageSet restrictTo(final LanguageSet other) {
if (other == NO_LANGUAGES) {
return other;
- } else if (other == ANY_LANGUAGE) {
+ }
+ if (other == ANY_LANGUAGE) {
return this;
- } else {
- final SomeLanguages someLanguages = (SomeLanguages) other;
- final Set<String> set = new
HashSet<>(Math.min(languages.size(), someLanguages.languages.size()));
- for (final String lang : languages) {
- if (someLanguages.languages.contains(lang)) {
- set.add(lang);
- }
+ }
+ final SomeLanguages someLanguages = (SomeLanguages) other;
+ final Set<String> set = new HashSet<>(Math.min(languages.size(),
someLanguages.languages.size()));
+ for (final String lang : languages) {
+ if (someLanguages.languages.contains(lang)) {
+ set.add(lang);
}
- return from(set);
}
+ return from(set);
}
@Override
public LanguageSet merge(final LanguageSet other) {
if (other == NO_LANGUAGES) {
return this;
- } else if (other == ANY_LANGUAGE) {
+ }
+ if (other == ANY_LANGUAGE) {
return other;
- } else {
- final SomeLanguages someLanguages = (SomeLanguages) other;
- final Set<String> set = new HashSet<>(languages);
- set.addAll(someLanguages.languages);
- return from(set);
}
+ final SomeLanguages someLanguages = (SomeLanguages) other;
+ final Set<String> set = new HashSet<>(languages);
+ set.addAll(someLanguages.languages);
+ return from(set);
}
@Override
diff --git a/src/main/java/org/apache/commons/codec/language/bm/Rule.java
b/src/main/java/org/apache/commons/codec/language/bm/Rule.java
index 1939945..f46f544 100644
--- a/src/main/java/org/apache/commons/codec/language/bm/Rule.java
+++ b/src/main/java/org/apache/commons/codec/language/bm/Rule.java
@@ -515,10 +515,12 @@ public class Rule {
return input.equals(content);
}
};
- } else if ((startsWith || endsWith) && content.isEmpty()) {
+ }
+ if ((startsWith || endsWith) && content.isEmpty()) {
// matches every string
return ALL_STRINGS_RMATCHER;
- } else if (startsWith) {
+ }
+ if (startsWith) {
// matches from start
return new RPattern() {
@Override
@@ -526,7 +528,8 @@ public class Rule {
return startsWith(input, content);
}
};
- } else if (endsWith) {
+ }
+ if (endsWith) {
// matches from start
return new RPattern() {
@Override
@@ -558,7 +561,8 @@ public class Rule {
return input.length() == 1 &&
contains(bContent, input.charAt(0)) == shouldMatch;
}
};
- } else if (startsWith) {
+ }
+ if (startsWith) {
// first char
return new RPattern() {
@Override
@@ -566,7 +570,8 @@ public class Rule {
return input.length() > 0 &&
contains(bContent, input.charAt(0)) == shouldMatch;
}
};
- } else if (endsWith) {
+ }
+ if (endsWith) {
// last char
return new RPattern() {
@Override
@@ -706,7 +711,8 @@ public class Rule {
// fail early if any of the evaluations is not successful
if (!input.subSequence(i, ipl).equals(this.pattern)) {
return false;
- } else if (!this.rContext.isMatch(input.subSequence(ipl,
input.length()))) {
+ }
+ if (!this.rContext.isMatch(input.subSequence(ipl, input.length()))) {
return false;
}
return this.lContext.isMatch(input.subSequence(0, i));
diff --git a/src/main/java/org/apache/commons/codec/net/BCodec.java
b/src/main/java/org/apache/commons/codec/net/BCodec.java
index 46263c2..6da4600 100644
--- a/src/main/java/org/apache/commons/codec/net/BCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/BCodec.java
@@ -241,13 +241,13 @@ public class BCodec extends RFC1522Codec implements
StringEncoder, StringDecoder
public Object encode(final Object value) throws EncoderException {
if (value == null) {
return null;
- } else if (value instanceof String) {
+ }
+ if (value instanceof String) {
return encode((String) value);
- } else {
- throw new EncoderException("Objects of type " +
- value.getClass().getName() +
- " cannot be encoded using BCodec");
}
+ throw new EncoderException("Objects of type " +
+ value.getClass().getName() +
+ " cannot be encoded using BCodec");
}
/**
@@ -265,13 +265,13 @@ public class BCodec extends RFC1522Codec implements
StringEncoder, StringDecoder
public Object decode(final Object value) throws DecoderException {
if (value == null) {
return null;
- } else if (value instanceof String) {
+ }
+ if (value instanceof String) {
return decode((String) value);
- } else {
- throw new DecoderException("Objects of type " +
- value.getClass().getName() +
- " cannot be decoded using BCodec");
}
+ throw new DecoderException("Objects of type " +
+ value.getClass().getName() +
+ " cannot be decoded using BCodec");
}
/**
diff --git a/src/main/java/org/apache/commons/codec/net/PercentCodec.java
b/src/main/java/org/apache/commons/codec/net/PercentCodec.java
index 2c0ca4c..16e3320 100644
--- a/src/main/java/org/apache/commons/codec/net/PercentCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/PercentCodec.java
@@ -236,11 +236,11 @@ public class PercentCodec implements BinaryEncoder,
BinaryDecoder {
public Object encode(final Object obj) throws EncoderException {
if (obj == null) {
return null;
- } else if (obj instanceof byte[]) {
+ }
+ if (obj instanceof byte[]) {
return encode((byte[]) obj);
- } else {
- throw new EncoderException("Objects of type " +
obj.getClass().getName() + " cannot be Percent encoded");
}
+ throw new EncoderException("Objects of type " +
obj.getClass().getName() + " cannot be Percent encoded");
}
/**
@@ -254,10 +254,10 @@ public class PercentCodec implements BinaryEncoder,
BinaryDecoder {
public Object decode(final Object obj) throws DecoderException {
if (obj == null) {
return null;
- } else if (obj instanceof byte[]) {
+ }
+ if (obj instanceof byte[]) {
return decode((byte[]) obj);
- } else {
- throw new DecoderException("Objects of type " +
obj.getClass().getName() + " cannot be Percent decoded");
}
+ throw new DecoderException("Objects of type " +
obj.getClass().getName() + " cannot be Percent decoded");
}
}
diff --git a/src/main/java/org/apache/commons/codec/net/QCodec.java
b/src/main/java/org/apache/commons/codec/net/QCodec.java
index 0250e08..5a6745f 100644
--- a/src/main/java/org/apache/commons/codec/net/QCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/QCodec.java
@@ -285,13 +285,13 @@ public class QCodec extends RFC1522Codec implements
StringEncoder, StringDecoder
public Object encode(final Object obj) throws EncoderException {
if (obj == null) {
return null;
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return encode((String) obj);
- } else {
- throw new EncoderException("Objects of type " +
- obj.getClass().getName() +
- " cannot be encoded using Q codec");
}
+ throw new EncoderException("Objects of type " +
+ obj.getClass().getName() +
+ " cannot be encoded using Q codec");
}
/**
@@ -309,13 +309,13 @@ public class QCodec extends RFC1522Codec implements
StringEncoder, StringDecoder
public Object decode(final Object obj) throws DecoderException {
if (obj == null) {
return null;
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return decode((String) obj);
- } else {
- throw new DecoderException("Objects of type " +
- obj.getClass().getName() +
- " cannot be decoded using Q codec");
}
+ throw new DecoderException("Objects of type " +
+ obj.getClass().getName() +
+ " cannot be decoded using Q codec");
}
/**
diff --git
a/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
b/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
index 5641dc8..7ab7707 100644
--- a/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
@@ -507,15 +507,16 @@ public class QuotedPrintableCodec implements
BinaryEncoder, BinaryDecoder, Strin
public Object encode(final Object obj) throws EncoderException {
if (obj == null) {
return null;
- } else if (obj instanceof byte[]) {
+ }
+ if (obj instanceof byte[]) {
return encode((byte[]) obj);
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return encode((String) obj);
- } else {
- throw new EncoderException("Objects of type " +
- obj.getClass().getName() +
- " cannot be quoted-printable encoded");
}
+ throw new EncoderException("Objects of type " +
+ obj.getClass().getName() +
+ " cannot be quoted-printable encoded");
}
/**
@@ -533,15 +534,16 @@ public class QuotedPrintableCodec implements
BinaryEncoder, BinaryDecoder, Strin
public Object decode(final Object obj) throws DecoderException {
if (obj == null) {
return null;
- } else if (obj instanceof byte[]) {
+ }
+ if (obj instanceof byte[]) {
return decode((byte[]) obj);
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return decode((String) obj);
- } else {
- throw new DecoderException("Objects of type " +
- obj.getClass().getName() +
- " cannot be quoted-printable decoded");
}
+ throw new DecoderException("Objects of type " +
+ obj.getClass().getName() +
+ " cannot be quoted-printable decoded");
}
/**
diff --git a/src/main/java/org/apache/commons/codec/net/URLCodec.java
b/src/main/java/org/apache/commons/codec/net/URLCodec.java
index 5c19bc6..d5809f3 100644
--- a/src/main/java/org/apache/commons/codec/net/URLCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/URLCodec.java
@@ -315,14 +315,14 @@ public class URLCodec implements BinaryEncoder,
BinaryDecoder, StringEncoder, St
public Object encode(final Object obj) throws EncoderException {
if (obj == null) {
return null;
- } else if (obj instanceof byte[]) {
+ }
+ if (obj instanceof byte[]) {
return encode((byte[])obj);
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return encode((String)obj);
- } else {
- throw new EncoderException("Objects of type " +
obj.getClass().getName() + " cannot be URL encoded");
-
}
+ throw new EncoderException("Objects of type " +
obj.getClass().getName() + " cannot be URL encoded");
}
/**
@@ -340,14 +340,14 @@ public class URLCodec implements BinaryEncoder,
BinaryDecoder, StringEncoder, St
public Object decode(final Object obj) throws DecoderException {
if (obj == null) {
return null;
- } else if (obj instanceof byte[]) {
+ }
+ if (obj instanceof byte[]) {
return decode((byte[]) obj);
- } else if (obj instanceof String) {
+ }
+ if (obj instanceof String) {
return decode((String) obj);
- } else {
- throw new DecoderException("Objects of type " +
obj.getClass().getName() + " cannot be URL decoded");
-
}
+ throw new DecoderException("Objects of type " +
obj.getClass().getName() + " cannot be URL decoded");
}
/**