Combine nested 'if' statement in 'else' block to 'else if'.
This commit is contained in:
parent
7e5be1cf84
commit
91928eed34
|
@ -1458,10 +1458,8 @@ public class ClassUtils {
|
||||||
className.endsWith(";")
|
className.endsWith(";")
|
||||||
? className.length() - 1
|
? className.length() - 1
|
||||||
: className.length());
|
: className.length());
|
||||||
} else {
|
} else if (!className.isEmpty()) {
|
||||||
if (!className.isEmpty()) {
|
className = reverseAbbreviationMap.get(className.substring(0, 1));
|
||||||
className = reverseAbbreviationMap.get(className.substring(0, 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
|
final StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
|
||||||
for (int i = 0; i < dim; i++) {
|
for (int i = 0; i < dim; i++) {
|
||||||
|
|
|
@ -372,18 +372,14 @@ public class RandomStringUtils {
|
||||||
if (start == 0 && end == 0) {
|
if (start == 0 && end == 0) {
|
||||||
if (chars != null) {
|
if (chars != null) {
|
||||||
end = chars.length;
|
end = chars.length;
|
||||||
|
} else if (!letters && !numbers) {
|
||||||
|
end = Character.MAX_CODE_POINT;
|
||||||
} else {
|
} else {
|
||||||
if (!letters && !numbers) {
|
end = 'z' + 1;
|
||||||
end = Character.MAX_CODE_POINT;
|
start = ' ';
|
||||||
} else {
|
|
||||||
end = 'z' + 1;
|
|
||||||
start = ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (end <= start) {
|
|
||||||
throw new IllegalArgumentException("Parameter end (" + end + ") must be greater than start (" + start + ")");
|
|
||||||
}
|
}
|
||||||
|
} else if (end <= start) {
|
||||||
|
throw new IllegalArgumentException("Parameter end (" + end + ") must be greater than start (" + start + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
final int zero_digit_ascii = 48;
|
final int zero_digit_ascii = 48;
|
||||||
|
|
|
@ -2946,10 +2946,8 @@ public class StringUtils {
|
||||||
if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0) {
|
if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!chFound) {
|
||||||
if (!chFound) {
|
return i;
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
|
@ -6747,11 +6745,9 @@ public class StringUtils {
|
||||||
// see if we need to keep searching for this
|
// see if we need to keep searching for this
|
||||||
if (tempIndex == -1) {
|
if (tempIndex == -1) {
|
||||||
noMoreMatchesForReplIndex[i] = true;
|
noMoreMatchesForReplIndex[i] = true;
|
||||||
} else {
|
} else if (textIndex == -1 || tempIndex < textIndex) {
|
||||||
if (textIndex == -1 || tempIndex < textIndex) {
|
textIndex = tempIndex;
|
||||||
textIndex = tempIndex;
|
replaceIndex = i;
|
||||||
replaceIndex = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: logic mostly below END
|
// NOTE: logic mostly below END
|
||||||
|
@ -6804,11 +6800,9 @@ public class StringUtils {
|
||||||
// see if we need to keep searching for this
|
// see if we need to keep searching for this
|
||||||
if (tempIndex == -1) {
|
if (tempIndex == -1) {
|
||||||
noMoreMatchesForReplIndex[i] = true;
|
noMoreMatchesForReplIndex[i] = true;
|
||||||
} else {
|
} else if (textIndex == -1 || tempIndex < textIndex) {
|
||||||
if (textIndex == -1 || tempIndex < textIndex) {
|
textIndex = tempIndex;
|
||||||
textIndex = tempIndex;
|
replaceIndex = i;
|
||||||
replaceIndex = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: logic duplicated above END
|
// NOTE: logic duplicated above END
|
||||||
|
|
|
@ -420,17 +420,15 @@ public class CompareToBuilder implements Builder<Integer> {
|
||||||
if (lhs.getClass().isArray()) {
|
if (lhs.getClass().isArray()) {
|
||||||
// factor out array case in order to keep method small enough to be inlined
|
// factor out array case in order to keep method small enough to be inlined
|
||||||
appendArray(lhs, rhs, comparator);
|
appendArray(lhs, rhs, comparator);
|
||||||
|
} else // the simple case, not an array, just test the element
|
||||||
|
if (comparator == null) {
|
||||||
|
@SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc
|
||||||
|
final Comparable<Object> comparable = (Comparable<Object>) lhs;
|
||||||
|
comparison = comparable.compareTo(rhs);
|
||||||
} else {
|
} else {
|
||||||
// the simple case, not an array, just test the element
|
@SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc
|
||||||
if (comparator == null) {
|
final Comparator<Object> comparator2 = (Comparator<Object>) comparator;
|
||||||
@SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc
|
comparison = comparator2.compare(lhs, rhs);
|
||||||
final Comparable<Object> comparable = (Comparable<Object>) lhs;
|
|
||||||
comparison = comparable.compareTo(rhs);
|
|
||||||
} else {
|
|
||||||
@SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc
|
|
||||||
final Comparator<Object> comparator2 = (Comparator<Object>) comparator;
|
|
||||||
comparison = comparator2.compare(lhs, rhs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,17 +532,15 @@ public class EqualsBuilder implements Builder<Boolean> {
|
||||||
try {
|
try {
|
||||||
if (testClass.isArray()) {
|
if (testClass.isArray()) {
|
||||||
append(lhs, rhs);
|
append(lhs, rhs);
|
||||||
|
} else //If either class is being excluded, call normal object equals method on lhsClass.
|
||||||
|
if (bypassReflectionClasses != null
|
||||||
|
&& (bypassReflectionClasses.contains(lhsClass) || bypassReflectionClasses.contains(rhsClass))) {
|
||||||
|
isEquals = lhs.equals(rhs);
|
||||||
} else {
|
} else {
|
||||||
//If either class is being excluded, call normal object equals method on lhsClass.
|
reflectionAppend(lhs, rhs, testClass);
|
||||||
if (bypassReflectionClasses != null
|
while (testClass.getSuperclass() != null && testClass != reflectUpToClass) {
|
||||||
&& (bypassReflectionClasses.contains(lhsClass) || bypassReflectionClasses.contains(rhsClass))) {
|
testClass = testClass.getSuperclass();
|
||||||
isEquals = lhs.equals(rhs);
|
|
||||||
} else {
|
|
||||||
reflectionAppend(lhs, rhs, testClass);
|
reflectionAppend(lhs, rhs, testClass);
|
||||||
while (testClass.getSuperclass() != null && testClass != reflectUpToClass) {
|
|
||||||
testClass = testClass.getSuperclass();
|
|
||||||
reflectionAppend(lhs, rhs, testClass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
|
@ -644,13 +642,11 @@ public class EqualsBuilder implements Builder<Boolean> {
|
||||||
// factor out array case in order to keep method small enough
|
// factor out array case in order to keep method small enough
|
||||||
// to be inlined
|
// to be inlined
|
||||||
appendArray(lhs, rhs);
|
appendArray(lhs, rhs);
|
||||||
|
} else // The simple case, not an array, just test the element
|
||||||
|
if (testRecursive && !ClassUtils.isPrimitiveOrWrapper(lhsClass)) {
|
||||||
|
reflectionAppend(lhs, rhs);
|
||||||
} else {
|
} else {
|
||||||
// The simple case, not an array, just test the element
|
isEquals = lhs.equals(rhs);
|
||||||
if (testRecursive && !ClassUtils.isPrimitiveOrWrapper(lhsClass)) {
|
|
||||||
reflectionAppend(lhs, rhs);
|
|
||||||
} else {
|
|
||||||
isEquals = lhs.equals(rhs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -842,14 +842,12 @@ public class HashCodeBuilder implements Builder<Integer> {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
iTotal = iTotal * iConstant;
|
iTotal = iTotal * iConstant;
|
||||||
|
|
||||||
|
} else if (object.getClass().isArray()) {
|
||||||
|
// factor out array case in order to keep method small enough
|
||||||
|
// to be inlined
|
||||||
|
appendArray(object);
|
||||||
} else {
|
} else {
|
||||||
if (object.getClass().isArray()) {
|
iTotal = iTotal * iConstant + object.hashCode();
|
||||||
// factor out array case in order to keep method small enough
|
|
||||||
// to be inlined
|
|
||||||
appendArray(object);
|
|
||||||
} else {
|
|
||||||
iTotal = iTotal * iConstant + object.hashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,12 +575,10 @@ public abstract class ToStringStyle implements Serializable {
|
||||||
appendSummary(buffer, fieldName, (Object[]) value);
|
appendSummary(buffer, fieldName, (Object[]) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (detail) {
|
||||||
|
appendDetail(buffer, fieldName, value);
|
||||||
} else {
|
} else {
|
||||||
if (detail) {
|
appendSummary(buffer, fieldName, value);
|
||||||
appendDetail(buffer, fieldName, value);
|
|
||||||
} else {
|
|
||||||
appendSummary(buffer, fieldName, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
unregister(value);
|
unregister(value);
|
||||||
|
|
|
@ -773,114 +773,112 @@ public class StrSubstitutor {
|
||||||
bufEnd);
|
bufEnd);
|
||||||
if (startMatchLen == 0) {
|
if (startMatchLen == 0) {
|
||||||
pos++;
|
pos++;
|
||||||
|
} else // found variable start marker
|
||||||
|
if (pos > offset && chars[pos - 1] == escape) {
|
||||||
|
// escaped
|
||||||
|
if (preserveEscapes) {
|
||||||
|
pos++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
buf.deleteCharAt(pos - 1);
|
||||||
|
chars = buf.buffer; // in case buffer was altered
|
||||||
|
lengthChange--;
|
||||||
|
altered = true;
|
||||||
|
bufEnd--;
|
||||||
} else {
|
} else {
|
||||||
// found variable start marker
|
// find suffix
|
||||||
if (pos > offset && chars[pos - 1] == escape) {
|
final int startPos = pos;
|
||||||
// escaped
|
pos += startMatchLen;
|
||||||
if (preserveEscapes) {
|
int endMatchLen = 0;
|
||||||
pos++;
|
int nestedVarCount = 0;
|
||||||
|
while (pos < bufEnd) {
|
||||||
|
if (substitutionInVariablesEnabled
|
||||||
|
&& (endMatchLen = pfxMatcher.isMatch(chars,
|
||||||
|
pos, offset, bufEnd)) != 0) {
|
||||||
|
// found a nested variable start
|
||||||
|
nestedVarCount++;
|
||||||
|
pos += endMatchLen;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
buf.deleteCharAt(pos - 1);
|
|
||||||
chars = buf.buffer; // in case buffer was altered
|
endMatchLen = suffMatcher.isMatch(chars, pos, offset,
|
||||||
lengthChange--;
|
bufEnd);
|
||||||
altered = true;
|
if (endMatchLen == 0) {
|
||||||
bufEnd--;
|
pos++;
|
||||||
} else {
|
} else {
|
||||||
// find suffix
|
// found variable end marker
|
||||||
final int startPos = pos;
|
if (nestedVarCount == 0) {
|
||||||
pos += startMatchLen;
|
String varNameExpr = new String(chars, startPos
|
||||||
int endMatchLen = 0;
|
+ startMatchLen, pos - startPos
|
||||||
int nestedVarCount = 0;
|
- startMatchLen);
|
||||||
while (pos < bufEnd) {
|
if (substitutionInVariablesEnabled) {
|
||||||
if (substitutionInVariablesEnabled
|
final StrBuilder bufName = new StrBuilder(varNameExpr);
|
||||||
&& (endMatchLen = pfxMatcher.isMatch(chars,
|
substitute(bufName, 0, bufName.length());
|
||||||
pos, offset, bufEnd)) != 0) {
|
varNameExpr = bufName.toString();
|
||||||
// found a nested variable start
|
}
|
||||||
nestedVarCount++;
|
|
||||||
pos += endMatchLen;
|
pos += endMatchLen;
|
||||||
continue;
|
final int endPos = pos;
|
||||||
}
|
|
||||||
|
|
||||||
endMatchLen = suffMatcher.isMatch(chars, pos, offset,
|
String varName = varNameExpr;
|
||||||
bufEnd);
|
String varDefaultValue = null;
|
||||||
if (endMatchLen == 0) {
|
|
||||||
pos++;
|
|
||||||
} else {
|
|
||||||
// found variable end marker
|
|
||||||
if (nestedVarCount == 0) {
|
|
||||||
String varNameExpr = new String(chars, startPos
|
|
||||||
+ startMatchLen, pos - startPos
|
|
||||||
- startMatchLen);
|
|
||||||
if (substitutionInVariablesEnabled) {
|
|
||||||
final StrBuilder bufName = new StrBuilder(varNameExpr);
|
|
||||||
substitute(bufName, 0, bufName.length());
|
|
||||||
varNameExpr = bufName.toString();
|
|
||||||
}
|
|
||||||
pos += endMatchLen;
|
|
||||||
final int endPos = pos;
|
|
||||||
|
|
||||||
String varName = varNameExpr;
|
if (valueDelimMatcher != null) {
|
||||||
String varDefaultValue = null;
|
final char [] varNameExprChars = varNameExpr.toCharArray();
|
||||||
|
int valueDelimiterMatchLen = 0;
|
||||||
if (valueDelimMatcher != null) {
|
for (int i = 0; i < varNameExprChars.length; i++) {
|
||||||
final char [] varNameExprChars = varNameExpr.toCharArray();
|
// if there's any nested variable when nested variable substitution disabled, then stop resolving name and default value.
|
||||||
int valueDelimiterMatchLen = 0;
|
if (!substitutionInVariablesEnabled
|
||||||
for (int i = 0; i < varNameExprChars.length; i++) {
|
&& pfxMatcher.isMatch(varNameExprChars, i, i, varNameExprChars.length) != 0) {
|
||||||
// if there's any nested variable when nested variable substitution disabled, then stop resolving name and default value.
|
break;
|
||||||
if (!substitutionInVariablesEnabled
|
}
|
||||||
&& pfxMatcher.isMatch(varNameExprChars, i, i, varNameExprChars.length) != 0) {
|
if ((valueDelimiterMatchLen = valueDelimMatcher.isMatch(varNameExprChars, i)) != 0) {
|
||||||
break;
|
varName = varNameExpr.substring(0, i);
|
||||||
}
|
varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
|
||||||
if ((valueDelimiterMatchLen = valueDelimMatcher.isMatch(varNameExprChars, i)) != 0) {
|
break;
|
||||||
varName = varNameExpr.substring(0, i);
|
|
||||||
varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on the first call initialize priorVariables
|
|
||||||
if (priorVariables == null) {
|
|
||||||
priorVariables = new ArrayList<>();
|
|
||||||
priorVariables.add(new String(chars,
|
|
||||||
offset, length));
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle cyclic substitution
|
|
||||||
checkCyclicSubstitution(varName, priorVariables);
|
|
||||||
priorVariables.add(varName);
|
|
||||||
|
|
||||||
// resolve the variable
|
|
||||||
String varValue = resolveVariable(varName, buf,
|
|
||||||
startPos, endPos);
|
|
||||||
if (varValue == null) {
|
|
||||||
varValue = varDefaultValue;
|
|
||||||
}
|
|
||||||
if (varValue != null) {
|
|
||||||
// recursive replace
|
|
||||||
final int varLen = varValue.length();
|
|
||||||
buf.replace(startPos, endPos, varValue);
|
|
||||||
altered = true;
|
|
||||||
int change = substitute(buf, startPos,
|
|
||||||
varLen, priorVariables);
|
|
||||||
change = change
|
|
||||||
+ varLen - (endPos - startPos);
|
|
||||||
pos += change;
|
|
||||||
bufEnd += change;
|
|
||||||
lengthChange += change;
|
|
||||||
chars = buf.buffer; // in case buffer was
|
|
||||||
// altered
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove variable from the cyclic stack
|
|
||||||
priorVariables
|
|
||||||
.remove(priorVariables.size() - 1);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
nestedVarCount--;
|
|
||||||
pos += endMatchLen;
|
// on the first call initialize priorVariables
|
||||||
|
if (priorVariables == null) {
|
||||||
|
priorVariables = new ArrayList<>();
|
||||||
|
priorVariables.add(new String(chars,
|
||||||
|
offset, length));
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle cyclic substitution
|
||||||
|
checkCyclicSubstitution(varName, priorVariables);
|
||||||
|
priorVariables.add(varName);
|
||||||
|
|
||||||
|
// resolve the variable
|
||||||
|
String varValue = resolveVariable(varName, buf,
|
||||||
|
startPos, endPos);
|
||||||
|
if (varValue == null) {
|
||||||
|
varValue = varDefaultValue;
|
||||||
|
}
|
||||||
|
if (varValue != null) {
|
||||||
|
// recursive replace
|
||||||
|
final int varLen = varValue.length();
|
||||||
|
buf.replace(startPos, endPos, varValue);
|
||||||
|
altered = true;
|
||||||
|
int change = substitute(buf, startPos,
|
||||||
|
varLen, priorVariables);
|
||||||
|
change = change
|
||||||
|
+ varLen - (endPos - startPos);
|
||||||
|
pos += change;
|
||||||
|
bufEnd += change;
|
||||||
|
lengthChange += change;
|
||||||
|
chars = buf.buffer; // in case buffer was
|
||||||
|
// altered
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove variable from the cyclic stack
|
||||||
|
priorVariables
|
||||||
|
.remove(priorVariables.size() - 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
nestedVarCount--;
|
||||||
|
pos += endMatchLen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,28 +315,26 @@ public class WordUtils {
|
||||||
wrappedLine.append(newLineStr);
|
wrappedLine.append(newLineStr);
|
||||||
offset = spaceToWrapAt + 1;
|
offset = spaceToWrapAt + 1;
|
||||||
|
|
||||||
|
} else // really long word or URL
|
||||||
|
if (wrapLongWords) {
|
||||||
|
// wrap really long word one line at a time
|
||||||
|
wrappedLine.append(str, offset, wrapLength + offset);
|
||||||
|
wrappedLine.append(newLineStr);
|
||||||
|
offset += wrapLength;
|
||||||
} else {
|
} else {
|
||||||
// really long word or URL
|
// do not wrap really long word, just extend beyond limit
|
||||||
if (wrapLongWords) {
|
matcher = patternToWrapOn.matcher(str.substring(offset + wrapLength));
|
||||||
// wrap really long word one line at a time
|
if (matcher.find()) {
|
||||||
wrappedLine.append(str, offset, wrapLength + offset);
|
spaceToWrapAt = matcher.start() + offset + wrapLength;
|
||||||
wrappedLine.append(newLineStr);
|
}
|
||||||
offset += wrapLength;
|
|
||||||
} else {
|
|
||||||
// do not wrap really long word, just extend beyond limit
|
|
||||||
matcher = patternToWrapOn.matcher(str.substring(offset + wrapLength));
|
|
||||||
if (matcher.find()) {
|
|
||||||
spaceToWrapAt = matcher.start() + offset + wrapLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (spaceToWrapAt >= 0) {
|
if (spaceToWrapAt >= 0) {
|
||||||
wrappedLine.append(str, offset, spaceToWrapAt);
|
wrappedLine.append(str, offset, spaceToWrapAt);
|
||||||
wrappedLine.append(newLineStr);
|
wrappedLine.append(newLineStr);
|
||||||
offset = spaceToWrapAt + 1;
|
offset = spaceToWrapAt + 1;
|
||||||
} else {
|
} else {
|
||||||
wrappedLine.append(str, offset, str.length());
|
wrappedLine.append(str, offset, str.length());
|
||||||
offset = inputLineLength;
|
offset = inputLineLength;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,10 +108,8 @@ public class NumericEntityEscaper extends CodePointTranslator {
|
||||||
if (codepoint < below || codepoint > above) {
|
if (codepoint < below || codepoint > above) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (codepoint >= below && codepoint <= above) {
|
||||||
if (codepoint >= below && codepoint <= above) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.write("&#");
|
out.write("&#");
|
||||||
|
|
|
@ -108,10 +108,8 @@ public class UnicodeEscaper extends CodePointTranslator {
|
||||||
if (codepoint < below || codepoint > above) {
|
if (codepoint < below || codepoint > above) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (codepoint >= below && codepoint <= above) {
|
||||||
if (codepoint >= below && codepoint <= above) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle potential + sign per various Unicode escape implementations
|
// TODO: Handle potential + sign per various Unicode escape implementations
|
||||||
|
|
|
@ -431,35 +431,33 @@ public class DurationFormatUtils {
|
||||||
final int count = token.getCount();
|
final int count = token.getCount();
|
||||||
if (value instanceof StringBuilder) {
|
if (value instanceof StringBuilder) {
|
||||||
buffer.append(value.toString());
|
buffer.append(value.toString());
|
||||||
} else {
|
} else if (value.equals(y)) {
|
||||||
if (value.equals(y)) {
|
buffer.append(paddedValue(years, padWithZeros, count));
|
||||||
buffer.append(paddedValue(years, padWithZeros, count));
|
lastOutputSeconds = false;
|
||||||
lastOutputSeconds = false;
|
} else if (value.equals(M)) {
|
||||||
} else if (value.equals(M)) {
|
buffer.append(paddedValue(months, padWithZeros, count));
|
||||||
buffer.append(paddedValue(months, padWithZeros, count));
|
lastOutputSeconds = false;
|
||||||
lastOutputSeconds = false;
|
} else if (value.equals(d)) {
|
||||||
} else if (value.equals(d)) {
|
buffer.append(paddedValue(days, padWithZeros, count));
|
||||||
buffer.append(paddedValue(days, padWithZeros, count));
|
lastOutputSeconds = false;
|
||||||
lastOutputSeconds = false;
|
} else if (value.equals(H)) {
|
||||||
} else if (value.equals(H)) {
|
buffer.append(paddedValue(hours, padWithZeros, count));
|
||||||
buffer.append(paddedValue(hours, padWithZeros, count));
|
lastOutputSeconds = false;
|
||||||
lastOutputSeconds = false;
|
} else if (value.equals(m)) {
|
||||||
} else if (value.equals(m)) {
|
buffer.append(paddedValue(minutes, padWithZeros, count));
|
||||||
buffer.append(paddedValue(minutes, padWithZeros, count));
|
lastOutputSeconds = false;
|
||||||
lastOutputSeconds = false;
|
} else if (value.equals(s)) {
|
||||||
} else if (value.equals(s)) {
|
buffer.append(paddedValue(seconds, padWithZeros, count));
|
||||||
buffer.append(paddedValue(seconds, padWithZeros, count));
|
lastOutputSeconds = true;
|
||||||
lastOutputSeconds = true;
|
} else if (value.equals(S)) {
|
||||||
} else if (value.equals(S)) {
|
if (lastOutputSeconds) {
|
||||||
if (lastOutputSeconds) {
|
// ensure at least 3 digits are displayed even if padding is not selected
|
||||||
// ensure at least 3 digits are displayed even if padding is not selected
|
final int width = padWithZeros ? Math.max(3, count) : 3;
|
||||||
final int width = padWithZeros ? Math.max(3, count) : 3;
|
buffer.append(paddedValue(milliseconds, true, width));
|
||||||
buffer.append(paddedValue(milliseconds, true, width));
|
} else {
|
||||||
} else {
|
buffer.append(paddedValue(milliseconds, padWithZeros, count));
|
||||||
buffer.append(paddedValue(milliseconds, padWithZeros, count));
|
|
||||||
}
|
|
||||||
lastOutputSeconds = false;
|
|
||||||
}
|
}
|
||||||
|
lastOutputSeconds = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
|
Loading…
Reference in New Issue