Some formatting cleanup.

This commit is contained in:
Michael Bayne
2006-07-12 16:59:15 +00:00
parent 16a45b2a2a
commit 5ecce1c8ba
@@ -89,7 +89,6 @@ public class JarDiffPatcher
// Files to implicit move // Files to implicit move
Set<String> oldjarNames = new HashSet<String>(); Set<String> oldjarNames = new HashSet<String>();
Enumeration<JarEntry> oldEntries = oldJar.entries(); Enumeration<JarEntry> oldEntries = oldJar.entries();
if (oldEntries != null) { if (oldEntries != null) {
while (oldEntries.hasMoreElements()) { while (oldEntries.hasMoreElements()) {
@@ -97,12 +96,11 @@ public class JarDiffPatcher
} }
} }
// size depends on the three parameters below, which is // size depends on the three parameters below, which is basically the
// basically the counter for each loop that do the actual // counter for each loop that do the actual writes to the output file
// writes to the output file // since oldjarNames.size() changes in the first two loop below, we
// since oldjarNames.size() changes in the first two loop // need to adjust the size accordingly also when oldjarNames.size()
// below, we need to adjust the size accordingly also when // changes
// oldjarNames.size() changes
double size = oldjarNames.size() + keys.length + jarDiff.size(); double size = oldjarNames.size() + keys.length + jarDiff.size();
double currentEntry = 0; double currentEntry = 0;
@@ -120,12 +118,12 @@ public class JarDiffPatcher
currentEntry++; currentEntry++;
writeEntry(jos, entry, jarDiff); writeEntry(jos, entry, jarDiff);
// Remove entry from oldjarNames since no implicit // Remove entry from oldjarNames since no implicit move is
//move is needed // needed
boolean wasInOld = oldjarNames.remove(entry.getName()); boolean wasInOld = oldjarNames.remove(entry.getName());
// Update progress counters. If it was in old, we do // Update progress counters. If it was in old, we do not
// not need an implicit move, so adjust total size. // need an implicit move, so adjust total size.
if (wasInOld) { if (wasInOld) {
size--; size--;
} }
@@ -145,7 +143,6 @@ public class JarDiffPatcher
// Get source JarEntry // Get source JarEntry
JarEntry oldEntry = oldJar.getJarEntry(oldName); JarEntry oldEntry = oldJar.getJarEntry(oldName);
if (oldEntry == null) { if (oldEntry == null) {
String moveCmd = MOVE_COMMAND + oldName + " " + newName; String moveCmd = MOVE_COMMAND + oldName + " " + newName;
throw new IOException("error.badmove: " + moveCmd); throw new IOException("error.badmove: " + moveCmd);
@@ -161,37 +158,32 @@ public class JarDiffPatcher
newEntry.setExtra(oldEntry.getExtra()); newEntry.setExtra(oldEntry.getExtra());
newEntry.setComment(oldEntry.getComment()); newEntry.setComment(oldEntry.getComment());
updateObserver(observer, currentEntry, size); updateObserver(observer, currentEntry, size);
currentEntry++; currentEntry++;
writeEntry(jos, newEntry, oldJar.getInputStream(oldEntry)); writeEntry(jos, newEntry, oldJar.getInputStream(oldEntry));
// Remove entry from oldjarNames since no implicit // Remove entry from oldjarNames since no implicit move is needed
//move is needed
boolean wasInOld = oldjarNames.remove(oldName); boolean wasInOld = oldjarNames.remove(oldName);
// Update progress counters. If it was in old, we do // Update progress counters. If it was in old, we do not need an
// not need an implicit move, so adjust total size. // implicit move, so adjust total size.
if (wasInOld) size--; if (wasInOld) {
size--;
}
} }
// implicit move // implicit move
Iterator iEntries = oldjarNames.iterator(); Iterator iEntries = oldjarNames.iterator();
if (iEntries != null) { if (iEntries != null) {
while (iEntries.hasNext()) { while (iEntries.hasNext()) {
String name = (String)iEntries.next(); String name = (String)iEntries.next();
JarEntry entry = oldJar.getJarEntry(name); JarEntry entry = oldJar.getJarEntry(name);
updateObserver(observer, currentEntry, size); updateObserver(observer, currentEntry, size);
currentEntry++; currentEntry++;
writeEntry(jos, entry, oldJar); writeEntry(jos, entry, oldJar);
} }
} }
updateObserver(observer, currentEntry, size); updateObserver(observer, currentEntry, size);
jos.finish(); jos.finish();
@@ -205,8 +197,8 @@ public class JarDiffPatcher
} }
} }
protected void determineNameMapping (JarFile jarDiff, Set<String> ignoreSet, protected void determineNameMapping (
Map<String, String> renameMap) JarFile jarDiff, Set<String> ignoreSet, Map<String, String> renameMap)
throws IOException throws IOException
{ {
InputStream is = jarDiff.getInputStream(jarDiff.getEntry(INDEX_NAME)); InputStream is = jarDiff.getInputStream(jarDiff.getEntry(INDEX_NAME));
@@ -232,17 +224,17 @@ public class JarDiffPatcher
ignoreSet.add(sub.get(0)); ignoreSet.add(sub.get(0));
} else if (line.startsWith(MOVE_COMMAND)) { } else if (line.startsWith(MOVE_COMMAND)) {
List<String> sub = getSubpaths(line.substring( List<String> sub = getSubpaths(
MOVE_COMMAND.length())); line.substring(MOVE_COMMAND.length()));
if (sub.size() != 2) { if (sub.size() != 2) {
throw new IOException("error.badmove: " + line); throw new IOException("error.badmove: " + line);
} }
// target of move should be the key // target of move should be the key
if (renameMap.put(sub.get(1), sub.get(0)) != null) { if (renameMap.put(sub.get(1), sub.get(0)) != null) {
// invalid move - should not move to same target twice // invalid move - should not move to same target twice
throw new IOException("error.badmove: " + line); throw new IOException("error.badmove: " + line);
} }
} else if (line.length() > 0) { } else if (line.length() > 0) {
throw new IOException("error.badcommand: " + line); throw new IOException("error.badcommand: " + line);
@@ -273,13 +265,11 @@ public class JarDiffPatcher
if (subString == null) { if (subString == null) {
subString = path.substring(last, index); subString = path.substring(last, index);
} } else {
else {
subString += path.substring(last, index); subString += path.substring(last, index);
} }
last = ++index; last = ++index;
} } else if (Character.isWhitespace(aChar)) {
else if (Character.isWhitespace(aChar)) {
break; break;
} }
index++; index++;
@@ -287,8 +277,7 @@ public class JarDiffPatcher
if (last != index) { if (last != index) {
if (subString == null) { if (subString == null) {
subString = path.substring(last, index); subString = path.substring(last, index);
} } else {
else {
subString += path.substring(last, index); subString += path.substring(last, index);
} }
} }