}
protected String cmdString(String... cmds) {
- if (cmds.length == 0)
+ switch (cmds.length) {
+ case 0:
return "";
- else if (cmds.length == 1)
+ case 1:
return "\"" + escapeJava(cmds[0]) + "\"";
- else {
+ default:
StringBuilder sb = new StringBuilder(cmdString(cmds[0]));
for (int i=1; i<cmds.length; i++) {
sb.append(", ");
protected void run() throws Exception {
final AmazonS3 s3 = new AmazonS3(properties());
- if ("get".equals(op)) { //$NON-NLS-1$
+ if (op == null) {
+ throw die(MessageFormat.format(CLIText.get().unsupportedOperation, op));
+ }
+ switch (op) {
+ case "get": //$NON-NLS-1$
final URLConnection c = s3.get(bucket, key);
int len = c.getContentLength();
try (InputStream in = c.getInputStream()) {
}
outs.flush();
}
-
- } else if ("ls".equals(op) || "list".equals(op)) { //$NON-NLS-1$//$NON-NLS-2$
+ break;
+ case "ls": //$NON-NLS-1$
+ case "list": //$NON-NLS-1$
for (String k : s3.list(bucket, key))
outw.println(k);
-
- } else if ("rm".equals(op) || "delete".equals(op)) { //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case "rm": //$NON-NLS-1$
+ case "delete": //$NON-NLS-1$
s3.delete(bucket, key);
-
- } else if ("put".equals(op)) { //$NON-NLS-1$
+ break;
+ case "put": //$NON-NLS-1$
try (OutputStream os = s3.beginPut(bucket, key, null, null)) {
final byte[] tmp = new byte[2048];
int n;
while ((n = ins.read(tmp)) > 0)
os.write(tmp, 0, n);
}
- } else {
+ break;
+ default:
throw die(MessageFormat.format(CLIText.get().unsupportedOperation, op));
}
}
RemoteListCommand cmd = git.remoteList();
List<RemoteConfig> remotes = cmd.call();
print(remotes);
- } else if ("add".equals(command)) { //$NON-NLS-1$
- RemoteAddCommand cmd = git.remoteAdd();
- cmd.setName(name);
- cmd.setUri(new URIish(uri));
- cmd.call();
- } else if ("remove".equals(command) || "rm".equals(command)) { //$NON-NLS-1$ //$NON-NLS-2$
- RemoteRemoveCommand cmd = git.remoteRemove();
- cmd.setRemoteName(name);
- cmd.call();
- } else if ("set-url".equals(command)) { //$NON-NLS-1$
- RemoteSetUrlCommand cmd = git.remoteSetUrl();
- cmd.setRemoteName(name);
- cmd.setRemoteUri(new URIish(uri));
- cmd.setUriType(push ? UriType.PUSH : UriType.FETCH);
- cmd.call();
- } else if ("update".equals(command)) { //$NON-NLS-1$
- // reuse fetch command for basic implementation of remote update
+ return;
+ }
+ switch (command) {
+ case "add": //$NON-NLS-1$
+ RemoteAddCommand add = git.remoteAdd();
+ add.setName(name);
+ add.setUri(new URIish(uri));
+ add.call();
+ break;
+ case "remove": //$NON-NLS-1$
+ case "rm": //$NON-NLS-1$
+ RemoteRemoveCommand rm = git.remoteRemove();
+ rm.setRemoteName(name);
+ rm.call();
+ break;
+ case "set-url": //$NON-NLS-1$
+ RemoteSetUrlCommand remoteSetUrl = git.remoteSetUrl();
+ remoteSetUrl.setRemoteName(name);
+ remoteSetUrl.setRemoteUri(new URIish(uri));
+ remoteSetUrl.setUriType(push ? UriType.PUSH : UriType.FETCH);
+ remoteSetUrl.call();
+ break;
+ case "update": //$NON-NLS-1$
Fetch fetch = new Fetch();
fetch.init(db, gitdir);
-
- // redirect the output stream
StringWriter osw = new StringWriter();
fetch.outw = new ThrowingPrintWriter(osw);
- // redirect the error stream
StringWriter esw = new StringWriter();
fetch.errw = new ThrowingPrintWriter(esw);
-
List<String> fetchArgs = new ArrayList<>();
if (verbose) {
fetchArgs.add("--verbose"); //$NON-NLS-1$
if (name != null) {
fetchArgs.add(name);
}
-
fetch.execute(fetchArgs.toArray(new String[0]));
-
- // flush the streams
fetch.outw.flush();
fetch.errw.flush();
outw.println(osw.toString());
errw.println(esw.toString());
- } else {
+ break;
+ default:
throw new JGitInternalException(MessageFormat
.format(CLIText.get().unknownSubcommand, command));
}
.getProperty(SshConstants.HOST_KEY_ALGORITHMS);
if (hostKeyAlgorithms != null && !hostKeyAlgorithms.isEmpty()) {
char first = hostKeyAlgorithms.charAt(0);
- if (first == '+') {
+ switch (first) {
+ case '+':
// Additions make not much sense -- it's either in
// defaultSignatures already, or we have no implementation for
// it. No point in proposing it.
return String.join(",", defaultSignatures); //$NON-NLS-1$
- } else if (first == '-') {
+ case '-':
// This takes wildcard patterns!
removeFromList(defaultSignatures,
SshConstants.HOST_KEY_ALGORITHMS,
hostKeyAlgorithms));
}
return String.join(",", defaultSignatures); //$NON-NLS-1$
- } else {
+ default:
// Default is overridden -- only accept the ones for which we do
// have an implementation.
List<String> newNames = filteredList(defaultSignatures,
} else {
return String.join(",", newNames); //$NON-NLS-1$
}
+ break;
}
}
// No HostKeyAlgorithms; using default -- change order to put existing
DfsPackFile garbage = null;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
gc = pack;
- } else if (d.getPackSource() == UNREACHABLE_GARBAGE) {
+ break;
+ case UNREACHABLE_GARBAGE:
garbage = pack;
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
}
boolean garbagePackFound = false;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
gcPackFound = true;
assertTrue("has commit0", isObjectInPack(commit0, pack));
assertFalse("no commit1", isObjectInPack(commit1, pack));
- } else if (d.getPackSource() == UNREACHABLE_GARBAGE) {
+ break;
+ case UNREACHABLE_GARBAGE:
garbagePackFound = true;
assertFalse("no commit0", isObjectInPack(commit0, pack));
assertTrue("has commit1", isObjectInPack(commit1, pack));
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
}
assertTrue("gc pack found", gcPackFound);
boolean garbagePackFound = false;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
gcPackFound = true;
assertTrue("has commit0", isObjectInPack(commit0, pack));
assertFalse("no commit1", isObjectInPack(commit1, pack));
- } else if (d.getPackSource() == UNREACHABLE_GARBAGE) {
+ break;
+ case UNREACHABLE_GARBAGE:
garbagePackFound = true;
assertFalse("no commit0", isObjectInPack(commit0, pack));
assertTrue("has commit1", isObjectInPack(commit1, pack));
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
}
assertTrue("gc pack found", gcPackFound);
long inputPacksSize = 32;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
gcPackFound = true;
- } else if (d.getPackSource() == INSERT) {
+ break;
+ case INSERT:
insertPackFound = true;
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
inputPacksSize += d.getFileSize(PACK) - 32;
}
long inputPacksSize = 32;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC_REST) {
+ switch (d.getPackSource()) {
+ case GC_REST:
gcRestPackFound = true;
- } else if (d.getPackSource() == INSERT) {
+ break;
+ case INSERT:
insertPackFound = true;
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
inputPacksSize += d.getFileSize(PACK) - 32;
}
long insertPackSize = 0;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
gcPackFound = true;
gcPackSize = d.getFileSize(PACK);
- } else if (d.getPackSource() == GC_REST) {
+ break;
+ case GC_REST:
gcRestPackFound = true;
gcRestPackSize = d.getFileSize(PACK);
- } else if (d.getPackSource() == INSERT) {
+ break;
+ case INSERT:
insertPackFound = true;
insertPackSize = d.getFileSize(PACK);
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
}
assertTrue(gcPackFound);
gcRestPackFound = false;
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
gcPackFound = true;
assertEquals(gcPackSize + insertPackSize - 32,
pack.getPackDescription().getEstimatedPackSize());
- } else if (d.getPackSource() == GC_REST) {
+ break;
+ case GC_REST:
gcRestPackFound = true;
assertEquals(gcRestPackSize + insertPackSize - 32,
pack.getPackDescription().getEstimatedPackSize());
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
}
assertTrue(gcPackFound);
assertEquals(2, odb.getPacks().length);
for (DfsPackFile pack : odb.getPacks()) {
DfsPackDescription d = pack.getPackDescription();
- if (d.getPackSource() == GC) {
+ switch (d.getPackSource()) {
+ case GC:
// Even though just commit0 will end up in GC pack, because
// there is no good way to know that up front, both the pack
// sizes are considered while computing the estimated size of GC
// pack.
assertEquals(packSize0 + packSize1 - 32,
d.getEstimatedPackSize());
- } else if (d.getPackSource() == UNREACHABLE_GARBAGE) {
+ break;
+ case UNREACHABLE_GARBAGE:
// commit1 is moved to UNREACHABLE_GARBAGE pack.
assertEquals(packSize1, d.getEstimatedPackSize());
- } else {
+ break;
+ default:
fail("unexpected " + d.getPackSource());
+ break;
}
}
}
@Override
public boolean get(URIish uri, CredentialItem... items)
throws UnsupportedCredentialItem {
- if (items.length == 0) {
+ switch (items.length) {
+ case 0:
return true;
-
- } else if (items.length == 1) {
+ case 1:
final CredentialItem item = items[0];
if (item instanceof CredentialItem.InformationalMessage) {
} else {
return interactive(uri, items);
}
-
- } else {
+ default:
return interactive(uri, items);
}
}
// visited first by BlameGenerator when considering candidates.
int cnt = children.length;
- if (cnt == 0)
+ switch (cnt) {
+ case 0:
children = new ReverseCommit[] { c };
- else if (cnt == 1)
+ break;
+ case 1:
children = new ReverseCommit[] { c, children[0] };
- else {
+ break;
+ default:
ReverseCommit[] n = new ReverseCommit[1 + cnt];
n[0] = c;
System.arraycopy(children, 0, n, 1, cnt);
children = n;
+ break;
}
}
}
/** {@inheritDoc} */
+ @SuppressWarnings("nls")
@Override
public void startElement(
String uri,
String localName,
String qName,
Attributes attributes) throws SAXException {
- if ("project".equals(qName)) { //$NON-NLS-1$
- if (attributes.getValue("name") == null) { //$NON-NLS-1$
+ if (qName == null) {
+ return;
+ }
+ switch (qName) {
+ case "project":
+ if (attributes.getValue("name") == null) {
throw new SAXException(RepoText.get().invalidManifest);
}
- currentProject = new RepoProject(
- attributes.getValue("name"), //$NON-NLS-1$
- attributes.getValue("path"), //$NON-NLS-1$
- attributes.getValue("revision"), //$NON-NLS-1$
- attributes.getValue("remote"), //$NON-NLS-1$
- attributes.getValue("groups")); //$NON-NLS-1$
- currentProject.setRecommendShallow(
- attributes.getValue("clone-depth")); //$NON-NLS-1$
- } else if ("remote".equals(qName)) { //$NON-NLS-1$
- String alias = attributes.getValue("alias"); //$NON-NLS-1$
- String fetch = attributes.getValue("fetch"); //$NON-NLS-1$
- String revision = attributes.getValue("revision"); //$NON-NLS-1$
+ currentProject = new RepoProject(attributes.getValue("name"),
+ attributes.getValue("path"),
+ attributes.getValue("revision"),
+ attributes.getValue("remote"),
+ attributes.getValue("groups"));
+ currentProject
+ .setRecommendShallow(attributes.getValue("clone-depth"));
+ break;
+ case "remote":
+ String alias = attributes.getValue("alias");
+ String fetch = attributes.getValue("fetch");
+ String revision = attributes.getValue("revision");
Remote remote = new Remote(fetch, revision);
- remotes.put(attributes.getValue("name"), remote); //$NON-NLS-1$
- if (alias != null)
+ remotes.put(attributes.getValue("name"), remote);
+ if (alias != null) {
remotes.put(alias, remote);
- } else if ("default".equals(qName)) { //$NON-NLS-1$
- defaultRemote = attributes.getValue("remote"); //$NON-NLS-1$
- defaultRevision = attributes.getValue("revision"); //$NON-NLS-1$
- } else if ("copyfile".equals(qName)) { //$NON-NLS-1$
- if (currentProject == null)
+ }
+ break;
+ case "default":
+ defaultRemote = attributes.getValue("remote");
+ defaultRevision = attributes.getValue("revision");
+ break;
+ case "copyfile":
+ if (currentProject == null) {
throw new SAXException(RepoText.get().invalidManifest);
- currentProject.addCopyFile(new CopyFile(
- rootRepo,
- currentProject.getPath(),
- attributes.getValue("src"), //$NON-NLS-1$
- attributes.getValue("dest"))); //$NON-NLS-1$
- } else if ("linkfile".equals(qName)) { //$NON-NLS-1$
+ }
+ currentProject.addCopyFile(new CopyFile(rootRepo,
+ currentProject.getPath(), attributes.getValue("src"),
+ attributes.getValue("dest")));
+ break;
+ case "linkfile":
if (currentProject == null) {
throw new SAXException(RepoText.get().invalidManifest);
}
- currentProject.addLinkFile(new LinkFile(
- rootRepo,
- currentProject.getPath(),
- attributes.getValue("src"), //$NON-NLS-1$
- attributes.getValue("dest"))); //$NON-NLS-1$
- } else if ("include".equals(qName)) { //$NON-NLS-1$
- String name = attributes.getValue("name"); //$NON-NLS-1$
+ currentProject.addLinkFile(new LinkFile(rootRepo,
+ currentProject.getPath(), attributes.getValue("src"),
+ attributes.getValue("dest")));
+ break;
+ case "include":
+ String name = attributes.getValue("name");
if (includedReader != null) {
try (InputStream is = includedReader.readIncludeFile(name)) {
if (is == null) {
}
read(is);
} catch (Exception e) {
- throw new SAXException(MessageFormat.format(
- RepoText.get().errorIncludeFile, name), e);
+ throw new SAXException(MessageFormat
+ .format(RepoText.get().errorIncludeFile, name), e);
}
} else if (filename != null) {
int index = filename.lastIndexOf('/');
try (InputStream is = new FileInputStream(path)) {
read(is);
} catch (IOException e) {
- throw new SAXException(MessageFormat.format(
- RepoText.get().errorIncludeFile, path), e);
+ throw new SAXException(MessageFormat
+ .format(RepoText.get().errorIncludeFile, path), e);
}
}
- } else if ("remove-project".equals(qName)) { //$NON-NLS-1$
- String name = attributes.getValue("name"); //$NON-NLS-1$
- projects.removeIf((p) -> p.getName().equals(name));
+ break;
+ case "remove-project": {
+ String name2 = attributes.getValue("name");
+ projects.removeIf((p) -> p.getName().equals(name2));
+ break;
+ }
+ default:
+ break;
}
}
throws IOException, IllegalArgumentException {
for (int i = 0; i < in.length(); ++i) {
char ch = in.charAt(i);
- if (ch == '\r') {
+ switch (ch) {
+ case '\r':
if (i + 1 < in.length() && in.charAt(i + 1) == '\n') {
out.write('\n');
out.write(' ');
out.write('\n');
out.write(' ');
}
- } else if (ch == '\n') {
+ break;
+ case '\n':
out.write('\n');
out.write(' ');
- } else {
+ break;
+ default:
// sanity check
if (ch > 127)
throw new IllegalArgumentException(MessageFormat
.format(JGitText.get().notASCIIString, in));
out.write(ch);
+ break;
}
}
}
private static PlotLane[] addLane(PlotLane l, PlotLane[] lanes) {
final int cnt = lanes.length;
- if (cnt == 0)
+ switch (cnt) {
+ case 0:
lanes = new PlotLane[] { l };
- else if (cnt == 1)
+ break;
+ case 1:
lanes = new PlotLane[] { lanes[0], l };
- else {
+ break;
+ default:
final PlotLane[] n = new PlotLane[cnt + 1];
System.arraycopy(lanes, 0, n, 0, cnt);
n[cnt] = l;
lanes = n;
+ break;
}
return lanes;
}
void addChild(PlotCommit c) {
final int cnt = children.length;
- if (cnt == 0)
+ switch (cnt) {
+ case 0:
children = new PlotCommit[] { c };
- else if (cnt == 1) {
+ break;
+ case 1:
if (!c.getId().equals(children[0].getId()))
children = new PlotCommit[] { children[0], c };
- } else {
+ break;
+ default:
for (PlotCommit pc : children)
if (c.getId().equals(pc.getId()))
return;
System.arraycopy(children, 0, n, 0, cnt);
n[cnt] = c;
children = n;
+ break;
}
}
}
idBuffer.fromString(raw, ptr + 7);
final RevCommit p = walk.lookupCommit(idBuffer);
- if (nParents == 0) {
+ switch (nParents) {
+ case 0:
pList[nParents++] = p;
- } else if (nParents == 1) {
+ break;
+ case 1:
pList = new RevCommit[] { pList[0], p };
nParents = 2;
- } else {
+ break;
+ default:
if (pList.length <= nParents) {
RevCommit[] old = pList;
pList = new RevCommit[pList.length + 32];
System.arraycopy(old, 0, pList, 0, nParents);
}
pList[nParents++] = p;
+ break;
}
ptr += 48;
}
for (AdvertiseRefsHook hook : hooks)
if (hook != AdvertiseRefsHook.DEFAULT)
newHooks[i++] = hook;
- if (i == 0)
+ switch (i) {
+ case 0:
return AdvertiseRefsHook.DEFAULT;
- else if (i == 1)
+ case 1:
return newHooks[0];
- else
+ default:
return new AdvertiseRefsHookChain(newHooks, i);
+ }
}
/** {@inheritDoc} */
return AckNackResult.ACK;
final String arg = line.substring(44);
- if (arg.equals(" continue")) //$NON-NLS-1$
+ switch (arg) {
+ case " continue": //$NON-NLS-1$
return AckNackResult.ACK_CONTINUE;
- else if (arg.equals(" common")) //$NON-NLS-1$
+ case " common": //$NON-NLS-1$
return AckNackResult.ACK_COMMON;
- else if (arg.equals(" ready")) //$NON-NLS-1$
+ case " ready": //$NON-NLS-1$
return AckNackResult.ACK_READY;
+ default:
+ break;
+ }
}
if (line.startsWith("ERR ")) //$NON-NLS-1$
throw new PackProtocolException(line.substring(4));
for (PostReceiveHook hook : hooks)
if (hook != PostReceiveHook.NULL)
newHooks[i++] = hook;
- if (i == 0)
+ switch (i) {
+ case 0:
return PostReceiveHook.NULL;
- else if (i == 1)
+ case 1:
return newHooks[0];
- else
+ default:
return new PostReceiveHookChain(newHooks, i);
+ }
}
/** {@inheritDoc} */
for (PreReceiveHook hook : hooks)
if (hook != PreReceiveHook.NULL)
newHooks[i++] = hook;
- if (i == 0)
+ switch (i) {
+ case 0:
return PreReceiveHook.NULL;
- else if (i == 1)
+ case 1:
return newHooks[0];
- else
+ default:
return new PreReceiveHookChain(newHooks, i);
+ }
}
/** {@inheritDoc} */
}
// tries to parse a string with a relative time specification
+ @SuppressWarnings("nls")
private static Date parse_relative(String dateStr, Calendar now) {
Calendar cal;
SystemReader sysRead = SystemReader.getInstance();
// check for the static words "yesterday" or "now"
- if ("now".equals(dateStr)) { //$NON-NLS-1$
+ if ("now".equals(dateStr)) {
return ((now == null) ? new Date(sysRead.getCurrentTime()) : now
.getTime());
}
} else
cal = (Calendar) now.clone();
- if ("yesterday".equals(dateStr)) { //$NON-NLS-1$
+ if ("yesterday".equals(dateStr)) {
cal.add(Calendar.DATE, -1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
}
// parse constructs like "3 days ago", "5.week.2.day.ago"
- String[] parts = dateStr.split("\\.| "); //$NON-NLS-1$
+ String[] parts = dateStr.split("\\.| ");
int partsLength = parts.length;
// check we have an odd number of parts (at least 3) and that the last
// part is "ago"
if (partsLength < 3 || (partsLength & 1) == 0
- || !"ago".equals(parts[parts.length - 1])) //$NON-NLS-1$
+ || !"ago".equals(parts[parts.length - 1]))
return null;
int number;
for (int i = 0; i < parts.length - 2; i += 2) {
} catch (NumberFormatException e) {
return null;
}
- if ("year".equals(parts[i + 1]) || "years".equals(parts[i + 1])) //$NON-NLS-1$ //$NON-NLS-2$
+ if (parts[i + 1] == null){
+ return null;
+ }
+ switch (parts[i + 1]) {
+ case "year":
+ case "years":
cal.add(Calendar.YEAR, -number);
- else if ("month".equals(parts[i + 1]) //$NON-NLS-1$
- || "months".equals(parts[i + 1])) //$NON-NLS-1$
+ break;
+ case "month":
+ case "months":
cal.add(Calendar.MONTH, -number);
- else if ("week".equals(parts[i + 1]) //$NON-NLS-1$
- || "weeks".equals(parts[i + 1])) //$NON-NLS-1$
+ break;
+ case "week":
+ case "weeks":
cal.add(Calendar.WEEK_OF_YEAR, -number);
- else if ("day".equals(parts[i + 1]) || "days".equals(parts[i + 1])) //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case "day":
+ case "days":
cal.add(Calendar.DATE, -number);
- else if ("hour".equals(parts[i + 1]) //$NON-NLS-1$
- || "hours".equals(parts[i + 1])) //$NON-NLS-1$
+ break;
+ case "hour":
+ case "hours":
cal.add(Calendar.HOUR_OF_DAY, -number);
- else if ("minute".equals(parts[i + 1]) //$NON-NLS-1$
- || "minutes".equals(parts[i + 1])) //$NON-NLS-1$
+ break;
+ case "minute":
+ case "minutes":
cal.add(Calendar.MINUTE, -number);
- else if ("second".equals(parts[i + 1]) //$NON-NLS-1$
- || "seconds".equals(parts[i + 1])) //$NON-NLS-1$
+ break;
+ case "second":
+ case "seconds":
cal.add(Calendar.SECOND, -number);
- else
+ break;
+ default:
return null;
+ }
}
return cal.getTime();
}
int o = 0;
for (int i = 0; i < buf.length; ++i) {
char ch = in.charAt(i);
- if (ch == '\r') {
+ switch (ch) {
+ case '\r':
if (i + 1 < buf.length && in.charAt(i + 1) == '\n') {
buf[o++] = ' ';
++i;
} else
buf[o++] = ' ';
- } else if (ch == '\n')
+ break;
+ case '\n':
buf[o++] = ' ';
- else
+ break;
+ default:
buf[o++] = ch;
+ break;
+ }
}
return new String(buf, 0, o);
}
}
for (int i = off; i < off + len; ++i) {
final byte c = b[i];
- if (c == '\r') {
+ switch (c) {
+ case '\r':
buf = '\r';
- } else if (c == '\n') {
+ break;
+ case '\n':
if (buf != '\r') {
if (lastw < i) {
out.write(b, lastw, i - lastw);
lastw = i;
}
buf = -1;
- } else {
+ break;
+ default:
buf = -1;
+ break;
}
}
if (lastw < off + len) {
}
for (int i = off; i < off + len; ++i) {
final byte c = b[i];
- if (c == '\r') {
+ switch (c) {
+ case '\r':
// skip write r but backlog r
if (lastw < i) {
out.write(b, lastw, i - lastw);
}
lastw = i + 1;
buf = '\r';
- } else if (c == '\n') {
+ break;
+ case '\n':
if (buf == '\r') {
out.write('\n');
lastw = i + 1;
}
lastw = i + 1;
}
- } else {
+ break;
+ default:
if (buf == '\r') {
out.write('\r');
lastw = i;
}
buf = -1;
+ break;
}
}
if (lastw < off + len) {
private void recompress(int t) {
State s;
- if (t == 58) {
+ switch (t) {
+ case 58:
s = state58;
- } else if (t == 65) {
+ break;
+ case 65:
s = state65;
- } else {
+ break;
+ default:
throw new IllegalStateException();
}
int a = s.a, b = s.b, c = s.c, d = s.d, e = s.e;