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