Author: peterreilly Date: Wed Oct 3 06:48:26 2007 New Revision: 581599 URL: http://svn.apache.org/viewvc?rev=581599&view=rev Log: checkstyle: remove inner assignment
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java?rev=581599&r1=581598&r2=581599&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java Wed Oct 3 06:48:26 2007 @@ -278,8 +278,6 @@ Vector entries = new Vector(); String line = reader.readLine(); - int index; - CvsTagEntry entry = null; while (null != line) { if (line.length() > headerLength) { @@ -289,45 +287,11 @@ line = line.substring(FILE_STRING.length()); } - index = line.indexOf(FILE_IS_NEW); - if (index != -1) { - // it is a new file - // set the revision but not the prevrevision - String filename = line.substring(0, index); - String rev = null; - int indexrev = line.indexOf(REVISION, index); - if (indexrev != -1) { - rev = line.substring(indexrev + REVISION.length()); - } - entry = new CvsTagEntry(filename, rev); - entries.addElement(entry); - log(entry.toString(), Project.MSG_VERBOSE); - } else if ((index = line.indexOf(FILE_HAS_CHANGED)) != -1) { - // it is a modified file - // set the revision and the prevrevision - String filename = line.substring(0, index); - int revSeparator = line.indexOf(" to ", index); - String prevRevision = - line.substring(index + FILE_HAS_CHANGED.length(), - revSeparator); - String revision = line.substring(revSeparator + TO_STRING.length()); - entry = new CvsTagEntry(filename, - revision, - prevRevision); - entries.addElement(entry); - log(entry.toString(), Project.MSG_VERBOSE); - } else if ((index = line.indexOf(FILE_WAS_REMOVED)) != -1) { - // it is a removed file - String filename = line.substring(0, index); - String rev = null; - int indexrev = line.indexOf(REVISION, index); - if (indexrev != -1) { - rev = line.substring(indexrev + REVISION.length()); - } - entry = new CvsTagEntry(filename, null, rev); - entries.addElement(entry); - log(entry.toString(), Project.MSG_VERBOSE); - } + // use || in a perl like fashion + boolean processed + = doFileIsNew(entries, line) + || doFileHasChanged(entries, line) + || doFileWasRemoved(entries, line); } line = reader.readLine(); } @@ -347,6 +311,64 @@ } } } + } + + private boolean doFileIsNew(Vector entries, String line) { + int index = line.indexOf(FILE_IS_NEW); + if (index == -1) { + return false; + } + // it is a new file + // set the revision but not the prevrevision + String filename = line.substring(0, index); + String rev = null; + int indexrev = line.indexOf(REVISION, index); + if (indexrev != -1) { + rev = line.substring(indexrev + REVISION.length()); + } + CvsTagEntry entry = new CvsTagEntry(filename, rev); + entries.addElement(entry); + log(entry.toString(), Project.MSG_VERBOSE); + return true; + } + + private boolean doFileHasChanged(Vector entries, String line) { + int index = line.indexOf(FILE_HAS_CHANGED); + if (index == -1) { + return false; + } + // it is a modified file + // set the revision and the prevrevision + String filename = line.substring(0, index); + int revSeparator = line.indexOf(" to ", index); + String prevRevision = + line.substring(index + FILE_HAS_CHANGED.length(), + revSeparator); + String revision = line.substring(revSeparator + TO_STRING.length()); + CvsTagEntry entry = new CvsTagEntry(filename, + revision, + prevRevision); + entries.addElement(entry); + log(entry.toString(), Project.MSG_VERBOSE); + return true; + } + + private boolean doFileWasRemoved(Vector entries, String line) { + int index = line.indexOf(FILE_WAS_REMOVED); + if (index == -1) { + return false; + } + // it is a removed file + String filename = line.substring(0, index); + String rev = null; + int indexrev = line.indexOf(REVISION, index); + if (indexrev != -1) { + rev = line.substring(indexrev + REVISION.length()); + } + CvsTagEntry entry = new CvsTagEntry(filename, null, rev); + entries.addElement(entry); + log(entry.toString(), Project.MSG_VERBOSE); + return true; } /** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]