You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/01/22 08:09:49 UTC
svn commit: r1436770 [5/16] - in /commons/proper/lang/trunk/src:
main/java/org/apache/commons/lang3/
main/java/org/apache/commons/lang3/builder/
main/java/org/apache/commons/lang3/concurrent/
main/java/org/apache/commons/lang3/event/ main/java/org/apac...
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java Tue Jan 22 07:09:45 2013
@@ -300,7 +300,7 @@ public class DateFormatUtils {
* @return the formatted date
*/
public static String format(final Date date, final String pattern, final TimeZone timeZone, final Locale locale) {
- FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
+ final FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
return df.format(date);
}
@@ -316,7 +316,7 @@ public class DateFormatUtils {
* @since 2.4
*/
public static String format(final Calendar calendar, final String pattern, final TimeZone timeZone, final Locale locale) {
- FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
+ final FastDateFormat df = FastDateFormat.getInstance(pattern, timeZone, locale);
return df.format(calendar);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DateUtils.java Tue Jan 22 07:09:45 2013
@@ -155,9 +155,9 @@ public class DateUtils {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar cal1 = Calendar.getInstance();
+ final Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
- Calendar cal2 = Calendar.getInstance();
+ final Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
return isSameDay(cal1, cal2);
}
@@ -363,8 +363,8 @@ public class DateUtils {
}
parser.setLenient(lenient);
- ParsePosition pos = new ParsePosition(0);
- for (String parsePattern : parsePatterns) {
+ final ParsePosition pos = new ParsePosition(0);
+ for (final String parsePattern : parsePatterns) {
String pattern = parsePattern;
@@ -382,7 +382,7 @@ public class DateUtils {
str2 = str.replaceAll("([-+][0-9][0-9]):([0-9][0-9])$", "$1$2");
}
- Date date = parser.parse(str2, pos);
+ final Date date = parser.parse(str2, pos);
if (date != null && pos.getIndex() == str2.length()) {
return date;
}
@@ -517,7 +517,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar c = Calendar.getInstance();
+ final Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(calendarField, amount);
return c.getTime();
@@ -647,7 +647,7 @@ public class DateUtils {
throw new IllegalArgumentException("The date must not be null");
}
// getInstance() returns a new object, so this method is thread safe.
- Calendar c = Calendar.getInstance();
+ final Calendar c = Calendar.getInstance();
c.setLenient(false);
c.setTime(date);
c.set(calendarField, amount);
@@ -664,7 +664,7 @@ public class DateUtils {
* @since 3.0
*/
public static Calendar toCalendar(final Date date) {
- Calendar c = Calendar.getInstance();
+ final Calendar c = Calendar.getInstance();
c.setTime(date);
return c;
}
@@ -700,7 +700,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(date);
modify(gval, field, MODIFY_ROUND);
return gval.getTime();
@@ -737,7 +737,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar rounded = (Calendar) date.clone();
+ final Calendar rounded = (Calendar) date.clone();
modify(rounded, field, MODIFY_ROUND);
return rounded;
}
@@ -803,7 +803,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(date);
modify(gval, field, MODIFY_TRUNCATE);
return gval.getTime();
@@ -828,7 +828,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar truncated = (Calendar) date.clone();
+ final Calendar truncated = (Calendar) date.clone();
modify(truncated, field, MODIFY_TRUNCATE);
return truncated;
}
@@ -883,7 +883,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(date);
modify(gval, field, MODIFY_CEILING);
return gval.getTime();
@@ -909,7 +909,7 @@ public class DateUtils {
if (date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar ceiled = (Calendar) date.clone();
+ final Calendar ceiled = (Calendar) date.clone();
modify(ceiled, field, MODIFY_CEILING);
return ceiled;
}
@@ -968,12 +968,12 @@ public class DateUtils {
// Manually truncate milliseconds, seconds and minutes, rather than using
// Calendar methods.
- Date date = val.getTime();
+ final Date date = val.getTime();
long time = date.getTime();
boolean done = false;
// truncate milliseconds
- int millisecs = val.get(Calendar.MILLISECOND);
+ final int millisecs = val.get(Calendar.MILLISECOND);
if (MODIFY_TRUNCATE == modType || millisecs < 500) {
time = time - millisecs;
}
@@ -982,7 +982,7 @@ public class DateUtils {
}
// truncate seconds
- int seconds = val.get(Calendar.SECOND);
+ final int seconds = val.get(Calendar.SECOND);
if (!done && (MODIFY_TRUNCATE == modType || seconds < 30)) {
time = time - (seconds * 1000L);
}
@@ -991,7 +991,7 @@ public class DateUtils {
}
// truncate minutes
- int minutes = val.get(Calendar.MINUTE);
+ final int minutes = val.get(Calendar.MINUTE);
if (!done && (MODIFY_TRUNCATE == modType || minutes < 30)) {
time = time - (minutes * 60000L);
}
@@ -1004,8 +1004,8 @@ public class DateUtils {
// ----------------- Fix for LANG-59 ----------------------- END ----------------
boolean roundUp = false;
- for (int[] aField : fields) {
- for (int element : aField) {
+ for (final int[] aField : fields) {
+ for (final int element : aField) {
if (element == field) {
//This is our field... we stop looping
if (modType == MODIFY_CEILING || (modType == MODIFY_ROUND && roundUp)) {
@@ -1075,8 +1075,8 @@ public class DateUtils {
break;
}
if (!offsetSet) {
- int min = val.getActualMinimum(aField[0]);
- int max = val.getActualMaximum(aField[0]);
+ final int min = val.getActualMinimum(aField[0]);
+ final int max = val.getActualMaximum(aField[0]);
//Calculate the offset from the minimum allowed value
offset = val.get(aField[0]) - min;
//Set roundUp if this is more than half way between the minimum and maximum
@@ -1120,7 +1120,7 @@ public class DateUtils {
if (focus == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar gval = Calendar.getInstance();
+ final Calendar gval = Calendar.getInstance();
gval.setTime(focus);
return iterator(gval, rangeStyle);
}
@@ -1663,7 +1663,7 @@ public class DateUtils {
if(date == null) {
throw new IllegalArgumentException("The date must not be null");
}
- Calendar calendar = Calendar.getInstance();
+ final Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return getFragment(calendar, fragment, unit);
}
@@ -1683,7 +1683,7 @@ public class DateUtils {
if(calendar == null) {
throw new IllegalArgumentException("The date must not be null");
}
- long millisPerUnit = getMillisPerUnit(unit);
+ final long millisPerUnit = getMillisPerUnit(unit);
long result = 0;
// Fragments bigger than a day require a breakdown to days
@@ -1770,8 +1770,8 @@ public class DateUtils {
* @since 3.0
*/
public static int truncatedCompareTo(final Calendar cal1, final Calendar cal2, final int field) {
- Calendar truncatedCal1 = truncate(cal1, field);
- Calendar truncatedCal2 = truncate(cal2, field);
+ final Calendar truncatedCal1 = truncate(cal1, field);
+ final Calendar truncatedCal2 = truncate(cal2, field);
return truncatedCal1.compareTo(truncatedCal2);
}
@@ -1790,8 +1790,8 @@ public class DateUtils {
* @since 3.0
*/
public static int truncatedCompareTo(final Date date1, final Date date2, final int field) {
- Date truncatedDate1 = truncate(date1, field);
- Date truncatedDate2 = truncate(date2, field);
+ final Date truncatedDate1 = truncate(date1, field);
+ final Date truncatedDate2 = truncate(date2, field);
return truncatedDate1.compareTo(truncatedDate2);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java Tue Jan 22 07:09:45 2013
@@ -121,7 +121,7 @@ public class DurationFormatUtils {
*/
public static String formatDuration(long durationMillis, final String format, final boolean padWithZeros) {
- Token[] tokens = lexx(format);
+ final Token[] tokens = lexx(format);
int days = 0;
int hours = 0;
@@ -275,13 +275,13 @@ public class DurationFormatUtils {
// TODO: Compare performance to see if anything was lost by
// losing this optimisation.
- Token[] tokens = lexx(format);
+ final Token[] tokens = lexx(format);
// timezones get funky around 0, so normalizing everything to GMT
// stops the hours being off
- Calendar start = Calendar.getInstance(timezone);
+ final Calendar start = Calendar.getInstance(timezone);
start.setTime(new Date(startMillis));
- Calendar end = Calendar.getInstance(timezone);
+ final Calendar end = Calendar.getInstance(timezone);
end.setTime(new Date(endMillis));
// initial estimates
@@ -413,13 +413,13 @@ public class DurationFormatUtils {
*/
static String format(final Token[] tokens, final int years, final int months, final int days, final int hours, final int minutes, final int seconds,
int milliseconds, final boolean padWithZeros) {
- StringBuilder buffer = new StringBuilder();
+ final StringBuilder buffer = new StringBuilder();
boolean lastOutputSeconds = false;
- int sz = tokens.length;
+ final int sz = tokens.length;
for (int i = 0; i < sz; i++) {
- Token token = tokens[i];
- Object value = token.getValue();
- int count = token.getCount();
+ final Token token = tokens[i];
+ final Object value = token.getValue();
+ final int count = token.getCount();
if (value instanceof StringBuilder) {
buffer.append(value.toString());
} else {
@@ -450,7 +450,7 @@ public class DurationFormatUtils {
} else if (value == S) {
if (lastOutputSeconds) {
milliseconds += 1000;
- String str = padWithZeros
+ final String str = padWithZeros
? StringUtils.leftPad(Integer.toString(milliseconds), count, '0')
: Integer.toString(milliseconds);
buffer.append(str.substring(1));
@@ -481,17 +481,17 @@ public class DurationFormatUtils {
* @return array of Token[]
*/
static Token[] lexx(final String format) {
- char[] array = format.toCharArray();
- ArrayList<Token> list = new ArrayList<Token>(array.length);
+ final char[] array = format.toCharArray();
+ final ArrayList<Token> list = new ArrayList<Token>(array.length);
boolean inLiteral = false;
// Although the buffer is stored in a Token, the Tokens are only
// used internally, so cannot be accessed by other threads
StringBuilder buffer = null;
Token previous = null;
- int sz = array.length;
+ final int sz = array.length;
for(int i=0; i<sz; i++) {
- char ch = array[i];
+ final char ch = array[i];
if(inLiteral && ch != '\'') {
buffer.append(ch); // buffer can't be null if inLiteral is true
continue;
@@ -528,7 +528,7 @@ public class DurationFormatUtils {
if(previous != null && previous.getValue() == value) {
previous.increment();
} else {
- Token token = new Token(value);
+ final Token token = new Token(value);
list.add(token);
previous = token;
}
@@ -552,7 +552,7 @@ public class DurationFormatUtils {
* @return boolean <code>true</code> if contained
*/
static boolean containsTokenWithValue(final Token[] tokens, final Object value) {
- int sz = tokens.length;
+ final int sz = tokens.length;
for (int i = 0; i < sz; i++) {
if (tokens[i].getValue() == value) {
return true;
@@ -620,7 +620,7 @@ public class DurationFormatUtils {
@Override
public boolean equals(final Object obj2) {
if (obj2 instanceof Token) {
- Token tok2 = (Token) obj2;
+ final Token tok2 = (Token) obj2;
if (this.value.getClass() != tok2.value.getClass()) {
return false;
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java Tue Jan 22 07:09:45 2013
@@ -548,7 +548,7 @@ public class FastDateFormat extends Form
if (obj instanceof FastDateFormat == false) {
return false;
}
- FastDateFormat other = (FastDateFormat) obj;
+ final FastDateFormat other = (FastDateFormat) obj;
// no need to check parser, as it has same invariants as printer
return printer.equals(other.printer);
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDateParser.java Tue Jan 22 07:09:45 2013
@@ -106,13 +106,13 @@ public class FastDateParser implements D
* This is called from constructor and from readObject (de-serialization)
*/
private void init() {
- Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
+ final Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
thisYear= definingCalendar.get(Calendar.YEAR);
- StringBuilder regex= new StringBuilder();
- List<Strategy> collector = new ArrayList<Strategy>();
+ final StringBuilder regex= new StringBuilder();
+ final List<Strategy> collector = new ArrayList<Strategy>();
- Matcher patternMatcher= formatPattern.matcher(pattern);
+ final Matcher patternMatcher= formatPattern.matcher(pattern);
if(!patternMatcher.lookingAt()) {
throw new IllegalArgumentException(
"Illegal pattern character '" + pattern.charAt(patternMatcher.regionStart()) + "'");
@@ -126,7 +126,7 @@ public class FastDateParser implements D
nextStrategy = null;
break;
}
- String nextFormatField= patternMatcher.group();
+ final String nextFormatField= patternMatcher.group();
nextStrategy = getStrategy(nextFormatField, definingCalendar);
if(currentStrategy.addRegex(this, regex)) {
collector.add(currentStrategy);
@@ -189,7 +189,7 @@ public class FastDateParser implements D
if (! (obj instanceof FastDateParser) ) {
return false;
}
- FastDateParser other = (FastDateParser) obj;
+ final FastDateParser other = (FastDateParser) obj;
return pattern.equals(other.pattern)
&& timeZone.equals(other.timeZone)
&& locale.equals(other.locale);
@@ -243,7 +243,7 @@ public class FastDateParser implements D
*/
@Override
public Date parse(final String source) throws ParseException {
- Date date= parse(source, new ParsePosition(0));
+ final Date date= parse(source, new ParsePosition(0));
if(date==null) {
// Add a note re supported date range
if (locale.equals(JAPANESE_IMPERIAL)) {
@@ -269,17 +269,17 @@ public class FastDateParser implements D
*/
@Override
public Date parse(final String source, final ParsePosition pos) {
- int offset= pos.getIndex();
- Matcher matcher= parsePattern.matcher(source.substring(offset));
+ final int offset= pos.getIndex();
+ final Matcher matcher= parsePattern.matcher(source.substring(offset));
if(!matcher.lookingAt()) {
return null;
}
// timing tests indicate getting new instance is 19% faster than cloning
- Calendar cal= Calendar.getInstance(timeZone, locale);
+ final Calendar cal= Calendar.getInstance(timeZone, locale);
cal.clear();
for(int i=0; i<strategies.length;) {
- Strategy strategy= strategies[i++];
+ final Strategy strategy= strategies[i++];
strategy.setCalendar(this, cal, matcher.group(i));
}
pos.setIndex(offset+matcher.end());
@@ -352,7 +352,7 @@ public class FastDateParser implements D
* @return A value within -80 and +20 years from instantiation of this instance
*/
int adjustYear(final int twoDigitYear) {
- int trial= twoDigitYear + thisYear - thisYear%100;
+ final int trial= twoDigitYear + thisYear - thisYear%100;
if(trial < thisYear+20) {
return trial;
}
@@ -498,13 +498,13 @@ public class FastDateParser implements D
* @return a TextStrategy for the field and Locale
*/
private Strategy getLocaleSpecificStrategy(final int field, final Calendar definingCalendar) {
- ConcurrentMap<Locale,Strategy> cache = getCache(field);
+ final ConcurrentMap<Locale,Strategy> cache = getCache(field);
Strategy strategy= cache.get(Integer.valueOf(field));
if(strategy==null) {
strategy= field==Calendar.ZONE_OFFSET
? new TimeZoneStrategy(locale)
: new TextStrategy(field, definingCalendar, locale);
- Strategy inCache= cache.putIfAbsent(locale, strategy);
+ final Strategy inCache= cache.putIfAbsent(locale, strategy);
if(inCache!=null) {
return inCache;
}
@@ -570,7 +570,7 @@ public class FastDateParser implements D
@Override
boolean addRegex(final FastDateParser parser, final StringBuilder regex) {
regex.append('(');
- for(String textKeyValue : keyValues.keySet()) {
+ for(final String textKeyValue : keyValues.keySet()) {
escapeRegex(regex, textKeyValue, false).append('|');
}
regex.setCharAt(regex.length()-1, ')');
@@ -582,11 +582,11 @@ public class FastDateParser implements D
*/
@Override
void setCalendar(final FastDateParser parser, final Calendar cal, final String value) {
- Integer iVal = keyValues.get(value);
+ final Integer iVal = keyValues.get(value);
if(iVal == null) {
- StringBuilder sb= new StringBuilder(value);
+ final StringBuilder sb= new StringBuilder(value);
sb.append(" not in (");
- for(String textKeyValue : keyValues.keySet()) {
+ for(final String textKeyValue : keyValues.keySet()) {
sb.append(textKeyValue).append(' ');
}
sb.setCharAt(sb.length()-1, ')');
@@ -678,11 +678,11 @@ public class FastDateParser implements D
* @param locale The Locale
*/
TimeZoneStrategy(final Locale locale) {
- for(String id : TimeZone.getAvailableIDs()) {
+ for(final String id : TimeZone.getAvailableIDs()) {
if(id.startsWith("GMT")) {
continue;
}
- TimeZone tz= TimeZone.getTimeZone(id);
+ final TimeZone tz= TimeZone.getTimeZone(id);
tzNames.put(tz.getDisplayName(false, TimeZone.SHORT, locale), tz);
tzNames.put(tz.getDisplayName(false, TimeZone.LONG, locale), tz);
if(tz.useDaylightTime()) {
@@ -690,9 +690,9 @@ public class FastDateParser implements D
tzNames.put(tz.getDisplayName(true, TimeZone.LONG, locale), tz);
}
}
- StringBuilder sb= new StringBuilder();
+ final StringBuilder sb= new StringBuilder();
sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|");
- for(String id : tzNames.keySet()) {
+ for(final String id : tzNames.keySet()) {
escapeRegex(sb, id, false).append('|');
}
sb.setCharAt(sb.length()-1, ')');
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java Tue Jan 22 07:09:45 2013
@@ -145,7 +145,7 @@ public class FastDatePrinter implements
* <p>Initializes the instance for first use.</p>
*/
private void init() {
- List<Rule> rulesList = parsePattern();
+ final List<Rule> rulesList = parsePattern();
mRules = rulesList.toArray(new Rule[rulesList.size()]);
int len = 0;
@@ -165,31 +165,31 @@ public class FastDatePrinter implements
* @throws IllegalArgumentException if pattern is invalid
*/
protected List<Rule> parsePattern() {
- DateFormatSymbols symbols = new DateFormatSymbols(mLocale);
- List<Rule> rules = new ArrayList<Rule>();
+ final DateFormatSymbols symbols = new DateFormatSymbols(mLocale);
+ final List<Rule> rules = new ArrayList<Rule>();
- String[] ERAs = symbols.getEras();
- String[] months = symbols.getMonths();
- String[] shortMonths = symbols.getShortMonths();
- String[] weekdays = symbols.getWeekdays();
- String[] shortWeekdays = symbols.getShortWeekdays();
- String[] AmPmStrings = symbols.getAmPmStrings();
+ final String[] ERAs = symbols.getEras();
+ final String[] months = symbols.getMonths();
+ final String[] shortMonths = symbols.getShortMonths();
+ final String[] weekdays = symbols.getWeekdays();
+ final String[] shortWeekdays = symbols.getShortWeekdays();
+ final String[] AmPmStrings = symbols.getAmPmStrings();
- int length = mPattern.length();
- int[] indexRef = new int[1];
+ final int length = mPattern.length();
+ final int[] indexRef = new int[1];
for (int i = 0; i < length; i++) {
indexRef[0] = i;
- String token = parseToken(mPattern, indexRef);
+ final String token = parseToken(mPattern, indexRef);
i = indexRef[0];
- int tokenLen = token.length();
+ final int tokenLen = token.length();
if (tokenLen == 0) {
break;
}
Rule rule;
- char c = token.charAt(0);
+ final char c = token.charAt(0);
switch (c) {
case 'G': // era designator (text)
@@ -270,7 +270,7 @@ public class FastDatePrinter implements
}
break;
case '\'': // literal text
- String sub = token.substring(1);
+ final String sub = token.substring(1);
if (sub.length() == 1) {
rule = new CharacterLiteral(sub.charAt(0));
} else {
@@ -295,10 +295,10 @@ public class FastDatePrinter implements
* @return parsed token
*/
protected String parseToken(final String pattern, final int[] indexRef) {
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
int i = indexRef[0];
- int length = pattern.length();
+ final int length = pattern.length();
char c = pattern.charAt(i);
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') {
@@ -307,7 +307,7 @@ public class FastDatePrinter implements
buf.append(c);
while (i + 1 < length) {
- char peek = pattern.charAt(i + 1);
+ final char peek = pattern.charAt(i + 1);
if (peek == c) {
buf.append(c);
i++;
@@ -394,7 +394,7 @@ public class FastDatePrinter implements
*/
@Override
public String format(final long millis) {
- Calendar c = newCalendar(); // hard code GregorianCalendar
+ final Calendar c = newCalendar(); // hard code GregorianCalendar
c.setTimeInMillis(millis);
return applyRulesToString(c);
}
@@ -413,7 +413,7 @@ public class FastDatePrinter implements
*/
@Override
public String format(final Date date) {
- Calendar c = newCalendar(); // hard code GregorianCalendar
+ final Calendar c = newCalendar(); // hard code GregorianCalendar
c.setTime(date);
return applyRulesToString(c);
}
@@ -439,7 +439,7 @@ public class FastDatePrinter implements
*/
@Override
public StringBuffer format(final Date date, final StringBuffer buf) {
- Calendar c = newCalendar(); // hard code GregorianCalendar
+ final Calendar c = newCalendar(); // hard code GregorianCalendar
c.setTime(date);
return applyRules(c, buf);
}
@@ -461,7 +461,7 @@ public class FastDatePrinter implements
* @return the specified string buffer
*/
protected StringBuffer applyRules(final Calendar calendar, final StringBuffer buf) {
- for (Rule rule : mRules) {
+ for (final Rule rule : mRules) {
rule.appendTo(buf, calendar);
}
return buf;
@@ -519,7 +519,7 @@ public class FastDatePrinter implements
if (obj instanceof FastDatePrinter == false) {
return false;
}
- FastDatePrinter other = (FastDatePrinter) obj;
+ final FastDatePrinter other = (FastDatePrinter) obj;
return mPattern.equals(other.mPattern)
&& mTimeZone.equals(other.mTimeZone)
&& mLocale.equals(other.mLocale);
@@ -687,7 +687,7 @@ public class FastDatePrinter implements
public int estimateLength() {
int max = 0;
for (int i=mValues.length; --i >= 0; ) {
- int len = mValues[i].length();
+ final int len = mValues[i].length();
if (len > max) {
max = len;
}
@@ -1087,12 +1087,12 @@ public class FastDatePrinter implements
* @return the textual name of the time zone
*/
static String getTimeZoneDisplay(final TimeZone tz, final boolean daylight, final int style, final Locale locale) {
- TimeZoneDisplayKey key = new TimeZoneDisplayKey(tz, daylight, style, locale);
+ final TimeZoneDisplayKey key = new TimeZoneDisplayKey(tz, daylight, style, locale);
String value = cTimeZoneDisplayCache.get(key);
if (value == null) {
// This is a very slow call, so cache the results.
value = tz.getDisplayName(daylight, style, locale);
- String prior = cTimeZoneDisplayCache.putIfAbsent(key, value);
+ final String prior = cTimeZoneDisplayCache.putIfAbsent(key, value);
if (prior != null) {
value= prior;
}
@@ -1140,7 +1140,7 @@ public class FastDatePrinter implements
*/
@Override
public void appendTo(final StringBuffer buffer, final Calendar calendar) {
- TimeZone zone = calendar.getTimeZone();
+ final TimeZone zone = calendar.getTimeZone();
if (zone.useDaylightTime()
&& calendar.get(Calendar.DST_OFFSET) != 0) {
buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
@@ -1191,7 +1191,7 @@ public class FastDatePrinter implements
buffer.append('+');
}
- int hours = offset / (60 * 60 * 1000);
+ final int hours = offset / (60 * 60 * 1000);
buffer.append((char)(hours / 10 + '0'));
buffer.append((char)(hours % 10 + '0'));
@@ -1199,7 +1199,7 @@ public class FastDatePrinter implements
buffer.append(':');
}
- int minutes = offset / (60 * 1000) - 60 * hours;
+ final int minutes = offset / (60 * 1000) - 60 * hours;
buffer.append((char)(minutes / 10 + '0'));
buffer.append((char)(minutes % 10 + '0'));
}
@@ -1249,7 +1249,7 @@ public class FastDatePrinter implements
return true;
}
if (obj instanceof TimeZoneDisplayKey) {
- TimeZoneDisplayKey other = (TimeZoneDisplayKey)obj;
+ final TimeZoneDisplayKey other = (TimeZoneDisplayKey)obj;
return
mTimeZone.equals(other.mTimeZone) &&
mStyle == other.mStyle &&
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/time/FormatCache.java Tue Jan 22 07:09:45 2013
@@ -76,11 +76,11 @@ abstract class FormatCache<F extends For
if (locale == null) {
locale = Locale.getDefault();
}
- MultipartKey key = new MultipartKey(pattern, timeZone, locale);
+ final MultipartKey key = new MultipartKey(pattern, timeZone, locale);
F format = cInstanceCache.get(key);
if (format == null) {
format = createInstance(pattern, timeZone, locale);
- F previousValue= cInstanceCache.putIfAbsent(key, format);
+ final F previousValue= cInstanceCache.putIfAbsent(key, format);
if (previousValue != null) {
// another thread snuck in and did the same work
// we should return the instance that is in ConcurrentMap
@@ -120,7 +120,7 @@ abstract class FormatCache<F extends For
if (locale == null) {
locale = Locale.getDefault();
}
- String pattern = getPatternForStyle(dateStyle, timeStyle, locale);
+ final String pattern = getPatternForStyle(dateStyle, timeStyle, locale);
return getInstance(pattern, timeZone, locale);
}
@@ -134,7 +134,7 @@ abstract class FormatCache<F extends For
* @throws IllegalArgumentException if the Locale has no date/time pattern defined
*/
public static String getPatternForStyle(final Integer dateStyle, final Integer timeStyle, final Locale locale) {
- MultipartKey key = new MultipartKey(dateStyle, timeStyle, locale);
+ final MultipartKey key = new MultipartKey(dateStyle, timeStyle, locale);
String pattern = cDateTimeInstanceCache.get(key);
if (pattern == null) {
@@ -150,14 +150,14 @@ abstract class FormatCache<F extends For
formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(), locale);
}
pattern = ((SimpleDateFormat)formatter).toPattern();
- String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern);
+ final String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern);
if (previous != null) {
// even though it doesn't matter if another thread put the pattern
// it's still good practice to return the String instance that is
// actually in the ConcurrentMap
pattern= previous;
}
- } catch (ClassCastException ex) {
+ } catch (final ClassCastException ex) {
throw new IllegalArgumentException("No date time pattern for locale: " + locale);
}
}
@@ -198,7 +198,7 @@ abstract class FormatCache<F extends For
public int hashCode() {
if(hashCode==0) {
int rc= 0;
- for(Object key : keys) {
+ for(final Object key : keys) {
if(key!=null) {
rc= rc*7 + key.hashCode();
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java Tue Jan 22 07:09:45 2013
@@ -116,7 +116,7 @@ public class MutablePair<L, R> extends P
*/
@Override
public R setValue(final R value) {
- R result = getRight();
+ final R result = getRight();
setRight(value);
return result;
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Pair.java Tue Jan 22 07:09:45 2013
@@ -131,7 +131,7 @@ public abstract class Pair<L, R> impleme
return true;
}
if (obj instanceof Map.Entry<?, ?>) {
- Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
+ final Map.Entry<?, ?> other = (Map.Entry<?, ?>) obj;
return ObjectUtils.equals(getKey(), other.getKey())
&& ObjectUtils.equals(getValue(), other.getValue());
}
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Triple.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Triple.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Triple.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/tuple/Triple.java Tue Jan 22 07:09:45 2013
@@ -110,7 +110,7 @@ public abstract class Triple<L, M, R> im
return true;
}
if (obj instanceof Triple<?, ?, ?>) {
- Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
+ final Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
return ObjectUtils.equals(getLeft(), other.getLeft())
&& ObjectUtils.equals(getMiddle(), other.getMiddle())
&& ObjectUtils.equals(getRight(), other.getRight());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java Tue Jan 22 07:09:45 2013
@@ -430,14 +430,14 @@ public class AnnotationUtilsTest {
@Test
public void testIsValidAnnotationMemberType() {
- for (Class<?> type : new Class[] { byte.class, short.class, int.class, char.class,
+ for (final Class<?> type : new Class[] { byte.class, short.class, int.class, char.class,
long.class, float.class, double.class, boolean.class, String.class, Class.class,
NestAnnotation.class, TestAnnotation.class, Stooge.class, ElementType.class }) {
assertTrue(AnnotationUtils.isValidAnnotationMemberType(type));
assertTrue(AnnotationUtils.isValidAnnotationMemberType(Array.newInstance(type, 0)
.getClass()));
}
- for (Class<?> type : new Class[] { Object.class, Map.class, Collection.class }) {
+ for (final Class<?> type : new Class[] { Object.class, Map.class, Collection.class }) {
assertFalse(AnnotationUtils.isValidAnnotationMemberType(type));
assertFalse(AnnotationUtils.isValidAnnotationMemberType(Array.newInstance(type, 0)
.getClass()));
@@ -449,7 +449,7 @@ public class AnnotationUtilsTest {
final Test real = getClass().getDeclaredMethod(
"testGeneratedAnnotationEquivalentToRealAnnotation").getAnnotation(Test.class);
- InvocationHandler generatedTestInvocationHandler = new InvocationHandler() {
+ final InvocationHandler generatedTestInvocationHandler = new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
@@ -466,7 +466,7 @@ public class AnnotationUtilsTest {
}
};
- Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread()
+ final Test generated = (Test) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { Test.class },
generatedTestInvocationHandler);
assertTrue(real.equals(generated));
@@ -474,7 +474,7 @@ public class AnnotationUtilsTest {
assertTrue(AnnotationUtils.equals(generated, real));
assertTrue(AnnotationUtils.equals(real, generated));
- Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread()
+ final Test generated2 = (Test) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { Test.class },
generatedTestInvocationHandler);
assertFalse(generated.equals(generated2));
@@ -497,7 +497,7 @@ public class AnnotationUtilsTest {
public void testToString() throws Exception {
final Test testAnno = getClass().getDeclaredMethod("testToString")
.getAnnotation(Test.class);
- String toString = AnnotationUtils.toString(testAnno);
+ final String toString = AnnotationUtils.toString(testAnno);
assertTrue(toString.startsWith("@org.junit.Test("));
assertTrue(toString.endsWith(")"));
assertTrue(toString.contains("expected=class org.junit.Test$None"));
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java Tue Jan 22 07:09:45 2013
@@ -46,7 +46,7 @@ public class ArrayUtilsAddTest {
// Invalid - can't store Long in Integer array
n = ArrayUtils.addAll(new Integer[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)});
fail("Should have generated IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
+ } catch (final IllegalArgumentException expected) {
}
}
@@ -59,7 +59,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((boolean[])null, true);
assertTrue(Arrays.equals(new boolean[]{true}, newArray));
assertEquals(Boolean.TYPE, newArray.getClass().getComponentType());
- boolean[] array1 = new boolean[]{true, false, true};
+ final boolean[] array1 = new boolean[]{true, false, true};
newArray = ArrayUtils.add(array1, false);
assertTrue(Arrays.equals(new boolean[]{true, false, true, false}, newArray));
assertEquals(Boolean.TYPE, newArray.getClass().getComponentType());
@@ -74,7 +74,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((byte[])null, (byte)1);
assertTrue(Arrays.equals(new byte[]{1}, newArray));
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
- byte[] array1 = new byte[]{1, 2, 3};
+ final byte[] array1 = new byte[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (byte)0);
assertTrue(Arrays.equals(new byte[]{1, 2, 3, 0}, newArray));
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
@@ -92,7 +92,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((char[])null, (char)1);
assertTrue(Arrays.equals(new char[]{1}, newArray));
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
- char[] array1 = new char[]{1, 2, 3};
+ final char[] array1 = new char[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (char)0);
assertTrue(Arrays.equals(new char[]{1, 2, 3, 0}, newArray));
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
@@ -110,7 +110,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((double[])null, 1);
assertTrue(Arrays.equals(new double[]{1}, newArray));
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
- double[] array1 = new double[]{1, 2, 3};
+ final double[] array1 = new double[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new double[]{1, 2, 3, 0}, newArray));
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
@@ -128,7 +128,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((float[])null, 1);
assertTrue(Arrays.equals(new float[]{1}, newArray));
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
- float[] array1 = new float[]{1, 2, 3};
+ final float[] array1 = new float[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new float[]{1, 2, 3, 0}, newArray));
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
@@ -146,7 +146,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((int[])null, 1);
assertTrue(Arrays.equals(new int[]{1}, newArray));
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
- int[] array1 = new int[]{1, 2, 3};
+ final int[] array1 = new int[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new int[]{1, 2, 3, 0}, newArray));
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
@@ -164,7 +164,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((long[])null, 1);
assertTrue(Arrays.equals(new long[]{1}, newArray));
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
- long[] array1 = new long[]{1, 2, 3};
+ final long[] array1 = new long[]{1, 2, 3};
newArray = ArrayUtils.add(array1, 0);
assertTrue(Arrays.equals(new long[]{1, 2, 3, 0}, newArray));
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
@@ -182,7 +182,7 @@ public class ArrayUtilsAddTest {
newArray = ArrayUtils.add((short[])null, (short)1);
assertTrue(Arrays.equals(new short[]{1}, newArray));
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
- short[] array1 = new short[]{1, 2, 3};
+ final short[] array1 = new short[]{1, 2, 3};
newArray = ArrayUtils.add(array1, (short)0);
assertTrue(Arrays.equals(new short[]{1, 2, 3, 0}, newArray));
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
@@ -202,12 +202,12 @@ public class ArrayUtilsAddTest {
assertEquals(String.class, newArray.getClass().getComponentType());
//show that not casting to Object[] is okay and will assume String based on "a"
- String[] newStringArray = ArrayUtils.add(null, "a");
+ final String[] newStringArray = ArrayUtils.add(null, "a");
assertTrue(Arrays.equals(new String[]{"a"}, newStringArray));
assertTrue(Arrays.equals(new Object[]{"a"}, newStringArray));
assertEquals(String.class, newStringArray.getClass().getComponentType());
- String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
newArray = ArrayUtils.add(stringArray1, null);
assertTrue(Arrays.equals(new String[]{"a", "b", "c", null}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -229,20 +229,22 @@ public class ArrayUtilsAddTest {
@Test
public void testLANG571(){
- String[] stringArray=null;
- String aString=null;
+ final String[] stringArray=null;
+ final String aString=null;
try {
@SuppressWarnings("unused")
+ final
String[] sa = ArrayUtils.add(stringArray, aString);
fail("Should have caused IllegalArgumentException");
- } catch (IllegalArgumentException iae){
+ } catch (final IllegalArgumentException iae){
//expected
}
try {
@SuppressWarnings("unused")
+ final
String[] sa = ArrayUtils.add(stringArray, 0, aString);
fail("Should have caused IllegalArgumentException");
- } catch (IllegalArgumentException iae){
+ } catch (final IllegalArgumentException iae){
//expected
}
}
@@ -251,8 +253,8 @@ public class ArrayUtilsAddTest {
public void testAddObjectArrayToObjectArray() {
assertNull(ArrayUtils.addAll((Object[]) null, (Object[]) null));
Object[] newArray;
- String[] stringArray1 = new String[]{"a", "b", "c"};
- String[] stringArray2 = new String[]{"1", "2", "3"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray2 = new String[]{"1", "2", "3"};
newArray = ArrayUtils.addAll(stringArray1, (String[]) null);
assertNotSame(stringArray1, newArray);
assertTrue(Arrays.equals(stringArray1, newArray));
@@ -278,7 +280,7 @@ public class ArrayUtilsAddTest {
assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, newArray));
assertTrue(Arrays.equals(new String[]{}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
- String[] stringArrayNull = new String []{null};
+ final String[] stringArrayNull = new String []{null};
newArray = ArrayUtils.addAll(stringArrayNull, stringArrayNull);
assertTrue(Arrays.equals(new String[]{null, null}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -372,7 +374,7 @@ public class ArrayUtilsAddTest {
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
- String[] stringArray1 = new String[]{"a", "b", "c"};
+ final String[] stringArray1 = new String[]{"a", "b", "c"};
newArray = ArrayUtils.add(stringArray1, 0, null);
assertTrue(Arrays.equals(new String[]{null, "a", "b", "c"}, newArray));
assertEquals(String.class, newArray.getClass().getComponentType());
@@ -387,9 +389,9 @@ public class ArrayUtilsAddTest {
assertEquals(String.class, newArray.getClass().getComponentType());
assertEquals(String.class, newArray.getClass().getComponentType());
- Object[] o = new Object[] {"1", "2", "4"};
- Object[] result = ArrayUtils.add(o, 2, "3");
- Object[] result2 = ArrayUtils.add(o, 3, "5");
+ final Object[] o = new Object[] {"1", "2", "4"};
+ final Object[] result = ArrayUtils.add(o, 2, "3");
+ final Object[] result2 = ArrayUtils.add(o, 3, "5");
assertNotNull(result);
assertEquals(4, result.length);
@@ -409,7 +411,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new boolean[] { true }, booleanArray ) );
try {
booleanArray = ArrayUtils.add( null, -1, true );
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
booleanArray = ArrayUtils.add( new boolean[] { true }, 0, false);
@@ -420,12 +422,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new boolean[] { true, true, false }, booleanArray ) );
try {
booleanArray = ArrayUtils.add( new boolean[] { true, false }, 4, true);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
booleanArray = ArrayUtils.add( new boolean[] { true, false }, -1, true);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -434,7 +436,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new char[] { 'a' }, charArray ) );
try {
charArray = ArrayUtils.add( (char[]) null, -1, 'a' );
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
charArray = ArrayUtils.add( new char[] { 'a' }, 0, 'b');
@@ -447,12 +449,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new char[] { 'a', 't', 'b', 'c' }, charArray ) );
try {
charArray = ArrayUtils.add( new char[] { 'a', 'b' }, 4, 'c');
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
charArray = ArrayUtils.add( new char[] { 'a', 'b' }, -1, 'c');
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -461,7 +463,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new short[] { 2, 1 }, shortArray ) );
try {
shortArray = ArrayUtils.add( (short[]) null, -1, (short) 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
shortArray = ArrayUtils.add( new short[] { 2, 6 }, 2, (short) 10);
@@ -472,12 +474,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new short[] { 2, 6, 1, 3 }, shortArray ) );
try {
shortArray = ArrayUtils.add( new short[] { 2, 6 }, 4, (short) 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
shortArray = ArrayUtils.add( new short[] { 2, 6 }, -1, (short) 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -486,7 +488,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new byte[] { 2, 1 }, byteArray ) );
try {
byteArray = ArrayUtils.add( (byte[]) null, -1, (byte) 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, 2, (byte) 3);
@@ -497,12 +499,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new byte[] { 2, 6, 1, 3 }, byteArray ) );
try {
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, 4, (byte) 3);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
byteArray = ArrayUtils.add( new byte[] { 2, 6 }, -1, (byte) 3);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -511,7 +513,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new int[] { 2, 1 }, intArray ) );
try {
intArray = ArrayUtils.add( (int[]) null, -1, 2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
intArray = ArrayUtils.add( new int[] { 2, 6 }, 2, 10);
@@ -522,12 +524,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new int[] { 2, 6, 1, 3 }, intArray ) );
try {
intArray = ArrayUtils.add( new int[] { 2, 6 }, 4, 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
intArray = ArrayUtils.add( new int[] { 2, 6 }, -1, 10);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -536,7 +538,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new long[] { 2L, 1L }, longArray ) );
try {
longArray = ArrayUtils.add( (long[]) null, -1, 2L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
longArray = ArrayUtils.add( new long[] { 2L, 6L }, 2, 10L);
@@ -547,12 +549,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new long[] { 2L, 6L, 1L, 3L }, longArray ) );
try {
longArray = ArrayUtils.add( new long[] { 2L, 6L }, 4, 10L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
longArray = ArrayUtils.add( new long[] { 2L, 6L }, -1, 10L);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -561,7 +563,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new float[] { 2.2f, 1.1f }, floatArray ) );
try {
floatArray = ArrayUtils.add( (float[]) null, -1, 2.2f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, 2, 10.5f);
@@ -572,12 +574,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new float[] { 2.9f, 6.0f, 1.0f, 0.3f }, floatArray ) );
try {
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, 4, 10.5f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
floatArray = ArrayUtils.add( new float[] { 2.3f, 6.4f }, -1, 10.5f);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
@@ -586,7 +588,7 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new double[] { 2.2, 1.1 }, doubleArray ) );
try {
doubleArray = ArrayUtils.add( (double[]) null, -1, 2.2);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 0", e.getMessage());
}
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, 2, 10.5);
@@ -597,12 +599,12 @@ public class ArrayUtilsAddTest {
assertTrue( Arrays.equals( new double[] { 2.9, 6.0, 1.0, 0.3 }, doubleArray ) );
try {
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, 4, 10.5);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: 4, Length: 2", e.getMessage());
}
try {
doubleArray = ArrayUtils.add( new double[] { 2.3, 6.4 }, -1, 10.5);
- } catch(IndexOutOfBoundsException e) {
+ } catch(final IndexOutOfBoundsException e) {
assertEquals("Index: -1, Length: 2", e.getMessage());
}
}
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java Tue Jan 22 07:09:45 2013
@@ -74,8 +74,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllObjectArrayRemoveNone() {
- Object[] array1 = new Object[] { "foo", "bar", "baz" };
- Object[] array2 = ArrayUtils.removeAll(array1);
+ final Object[] array1 = new Object[] { "foo", "bar", "baz" };
+ final Object[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(Object.class, array2.getClass().getComponentType());
@@ -98,7 +98,7 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllNumberArray() {
- Number[] inarray = { Integer.valueOf(1), Long.valueOf(2L), Byte.valueOf((byte) 3) };
+ final Number[] inarray = { Integer.valueOf(1), Long.valueOf(2L), Byte.valueOf((byte) 3) };
assertEquals(3, inarray.length);
Number[] outarray;
outarray = ArrayUtils.removeAll(inarray, 1);
@@ -172,8 +172,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllBooleanArrayRemoveNone() {
- boolean[] array1 = new boolean[] { true, false };
- boolean[] array2 = ArrayUtils.removeAll(array1);
+ final boolean[] array1 = new boolean[] { true, false };
+ final boolean[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(boolean.class, array2.getClass().getComponentType());
@@ -238,8 +238,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllByteArrayRemoveNone() {
- byte[] array1 = new byte[] { 1, 2 };
- byte[] array2 = ArrayUtils.removeAll(array1);
+ final byte[] array1 = new byte[] { 1, 2 };
+ final byte[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(byte.class, array2.getClass().getComponentType());
@@ -304,8 +304,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllCharArrayRemoveNone() {
- char[] array1 = new char[] { 'a', 'b' };
- char[] array2 = ArrayUtils.removeAll(array1);
+ final char[] array1 = new char[] { 'a', 'b' };
+ final char[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(char.class, array2.getClass().getComponentType());
@@ -370,8 +370,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllDoubleArrayRemoveNone() {
- double[] array1 = new double[] { 1, 2 };
- double[] array2 = ArrayUtils.removeAll(array1);
+ final double[] array1 = new double[] { 1, 2 };
+ final double[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(double.class, array2.getClass().getComponentType());
@@ -436,8 +436,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllFloatArrayRemoveNone() {
- float[] array1 = new float[] { 1, 2 };
- float[] array2 = ArrayUtils.removeAll(array1);
+ final float[] array1 = new float[] { 1, 2 };
+ final float[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertTrue(Arrays.equals(array1, array2));
assertEquals(float.class, array2.getClass().getComponentType());
@@ -506,8 +506,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllIntArrayRemoveNone() {
- int[] array1 = new int[] { 1, 2 };
- int[] array2 = ArrayUtils.removeAll(array1);
+ final int[] array1 = new int[] { 1, 2 };
+ final int[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(int.class, array2.getClass().getComponentType());
@@ -572,8 +572,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllLongArrayRemoveNone() {
- long[] array1 = new long[] { 1, 2 };
- long[] array2 = ArrayUtils.removeAll(array1);
+ final long[] array1 = new long[] { 1, 2 };
+ final long[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(long.class, array2.getClass().getComponentType());
@@ -638,8 +638,8 @@ public class ArrayUtilsRemoveMultipleTes
@Test
public void testRemoveAllShortArrayRemoveNone() {
- short[] array1 = new short[] { 1, 2 };
- short[] array2 = ArrayUtils.removeAll(array1);
+ final short[] array1 = new short[] { 1, 2 };
+ final short[] array2 = ArrayUtils.removeAll(array1);
assertNotSame(array1, array2);
assertArrayEquals(array1, array2);
assertEquals(short.class, array2.getClass().getComponentType());
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java?rev=1436770&r1=1436769&r2=1436770&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java Tue Jan 22 07:09:45 2013
@@ -51,20 +51,20 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new Object[] {"a", "b"}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new Object[] {"a", "b"}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((Object[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
public void testRemoveNumberArray(){
- Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
+ final Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
assertEquals(3, inarray.length);
Number[] outarray;
outarray = ArrayUtils.remove(inarray, 1);
@@ -96,15 +96,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new boolean[] {true, false}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new boolean[] {true, false}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((boolean[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -125,15 +125,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new byte[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new byte[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((byte[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -154,15 +154,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new char[] {'a', 'b'}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new char[] {'a', 'b'}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((char[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -183,15 +183,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new double[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new double[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((double[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -212,15 +212,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new float[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new float[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((float[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -241,15 +241,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new int[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new int[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((int[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -270,15 +270,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new long[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new long[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((long[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test
@@ -299,15 +299,15 @@ public class ArrayUtilsRemoveTest {
try {
ArrayUtils.remove(new short[] {1, 2}, -1);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove(new short[] {1, 2}, 2);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
try {
ArrayUtils.remove((short[]) null, 0);
fail("IndexOutOfBoundsException expected");
- } catch (IndexOutOfBoundsException e) {}
+ } catch (final IndexOutOfBoundsException e) {}
}
@Test