aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util
diff options
context:
space:
mode:
authorSasa Zivkov <sasa.zivkov@sap.com>2010-05-19 16:59:28 +0200
committerShawn O. Pearce <spearce@spearce.org>2010-05-19 14:37:16 -0700
commitf3d8a8ecad614906a2c4ec0077cdb24129da6c6d (patch)
tree34d041692beff0f392c27869f49b76c0fc2053e6 /org.eclipse.jgit/src/org/eclipse/jgit/util
parent2e961989e42b1fe7e8bd9eaa7a3d2e88a0d1d001 (diff)
downloadjgit-f3d8a8ecad614906a2c4ec0077cdb24129da6c6d.tar.gz
jgit-f3d8a8ecad614906a2c4ec0077cdb24129da6c6d.zip
Externalize strings from JGit
The strings are externalized into the root resource bundles. The resource bundles are stored under the new "resources" source folder to get proper maven build. Strings from tests are, in general, not externalized. Only in cases where it was necessary to make the test pass the strings were externalized. This was typically necessary in cases where e.getMessage() was used in assert and the exception message was slightly changed due to reuse of the externalized strings. Change-Id: Ic0f29c80b9a54fcec8320d8539a3e112852a1f7b Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java4
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java7
10 files changed, 55 insertions, 28 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
index 53c7beced8..1c7d397e9c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/Base64.java
@@ -9,6 +9,9 @@ package org.eclipse.jgit.util;
import java.io.Closeable;
import java.io.IOException;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
/**
@@ -702,7 +705,7 @@ public class Base64
} // end if: white space, equals sign or better
else
{
- System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" );
+ System.err.println(MessageFormat.format(JGitText.get().badBase64InputCharacterAt, i+ source[i]));
return null;
} // end else:
} // each input character
@@ -925,7 +928,7 @@ public class Base64
// Check for size of file
if( file.length() > Integer.MAX_VALUE )
{
- System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." );
+ System.err.println(MessageFormat.format(JGitText.get().fileIsTooBigForThisConvenienceMethod, file.length()));
return null;
} // end if: file too big for int index
buffer = new byte[ (int)file.length() ];
@@ -946,7 +949,7 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
- System.err.println( "Error decoding from file " + filename );
+ System.err.println(MessageFormat.format(JGitText.get().errorDecodingFromFile, filename));
} // end catch: IOException
finally
{
@@ -994,7 +997,7 @@ public class Base64
} // end try
catch( java.io.IOException e )
{
- System.err.println( "Error encoding from file " + filename );
+ System.err.println(MessageFormat.format(JGitText.get().errorEncodingFromFile, filename));
} // end catch: IOException
finally
{
@@ -1154,7 +1157,7 @@ public class Base64
else
{
// Must have broken out from above.
- throw new java.io.IOException( "Improperly padded Base64 input." );
+ throw new java.io.IOException(JGitText.get().improperlyPaddedBase64Input);
} // end
} // end else: decode
@@ -1192,7 +1195,7 @@ public class Base64
else
{
// When JDK1.4 is more accepted, use an assertion here.
- throw new java.io.IOException( "Error in Base64 code reading stream." );
+ throw new java.io.IOException(JGitText.get().errorInBase64CodeReadingStream);
} // end else
} // end read
@@ -1363,7 +1366,7 @@ public class Base64
} // end if: meaningful base64 character
else if( DECODABET[ theByte & 0x7f ] != WHITE_SPACE_ENC )
{
- throw new java.io.IOException( "Invalid character in Base64 data." );
+ throw new java.io.IOException(JGitText.get().invalidCharacterInBase64Data);
} // end else: not white space either
} // end else: decoding
} // end write
@@ -1413,7 +1416,7 @@ public class Base64
} // end if: encoding
else
{
- throw new java.io.IOException( "Base64 input not properly padded." );
+ throw new java.io.IOException(JGitText.get().base64InputNotProperlyPadded);
} // end else: decoding
} // end if: buffer partially full
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
index 2532593ec5..d3e1f60035 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/HttpSupport.java
@@ -53,6 +53,9 @@ import java.net.ProxySelector;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLEncoder;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
/** Extra utilities to support usage of HTTP. */
public class HttpSupport {
@@ -133,7 +136,7 @@ public class HttpSupport {
try {
urlstr.append(URLEncoder.encode(key, "UTF-8"));
} catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Could not URL encode to UTF-8", e);
+ throw new RuntimeException(JGitText.get().couldNotURLEncodeToUTF8, e);
}
}
@@ -158,7 +161,7 @@ public class HttpSupport {
// The standard J2SE error message is not very useful.
//
if ("Connection timed out: connect".equals(ce.getMessage()))
- throw new ConnectException("Connection time out: " + host);
+ throw new ConnectException(MessageFormat.format(JGitText.get().connectionTimeOut, host));
throw new ConnectException(ce.getMessage() + " " + host);
}
}
@@ -181,7 +184,7 @@ public class HttpSupport {
return proxySelector.select(u.toURI()).get(0);
} catch (URISyntaxException e) {
final ConnectException err;
- err = new ConnectException("Cannot determine proxy for " + u);
+ err = new ConnectException(MessageFormat.format(JGitText.get().cannotDetermineProxyFor, u));
err.initCause(e);
throw err;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
index 566b857460..1778654203 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/IO.java
@@ -53,6 +53,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
/**
* Input/Output utilities
@@ -95,7 +98,7 @@ public class IO {
try {
final long sz = in.getChannel().size();
if (sz > max)
- throw new IOException("File is too large: " + path);
+ throw new IOException(MessageFormat.format(JGitText.get().fileIsTooLarge, path));
final byte[] buf = new byte[(int) sz];
IO.readFully(in, buf, 0, buf.length);
return buf;
@@ -129,7 +132,7 @@ public class IO {
while (len > 0) {
final int r = fd.read(dst, off, len);
if (r <= 0)
- throw new EOFException("Short read of block.");
+ throw new EOFException(JGitText.get().shortReadOfBlock);
off += r;
len -= r;
}
@@ -158,7 +161,7 @@ public class IO {
while (len > 0) {
final int r = fd.read(ByteBuffer.wrap(dst, off, len), pos);
if (r <= 0)
- throw new EOFException("Short read of block.");
+ throw new EOFException(JGitText.get().shortReadOfBlock);
pos += r;
off += r;
len -= r;
@@ -187,7 +190,7 @@ public class IO {
while (toSkip > 0) {
final long r = fd.skip(toSkip);
if (r <= 0)
- throw new EOFException("Short skip of block");
+ throw new EOFException(JGitText.get().shortSkipOfBlock);
toSkip -= r;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java
index 67d67b90c4..f45bf2796b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawSubStringPattern.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.util;
+import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.Constants;
/**
@@ -67,7 +68,7 @@ public class RawSubStringPattern {
*/
public RawSubStringPattern(final String patternText) {
if (patternText.length() == 0)
- throw new IllegalArgumentException("Cannot match on empty string.");
+ throw new IllegalArgumentException(JGitText.get().cannotMatchOnEmptyString);
needleString = patternText;
final byte[] b = Constants.encode(patternText);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
index 582dce8aff..119c041570 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
@@ -43,6 +43,10 @@
package org.eclipse.jgit.util;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
+
/** Miscellaneous string comparison utility methods. */
public final class StringUtils {
private static final char[] LC;
@@ -135,7 +139,7 @@ public final class StringUtils {
*/
public static boolean toBoolean(final String stringValue) {
if (stringValue == null)
- throw new NullPointerException("Expected boolean string value");
+ throw new NullPointerException(JGitText.get().expectedBooleanStringValue);
if (equalsIgnoreCase("yes", stringValue)
|| equalsIgnoreCase("true", stringValue)
@@ -150,7 +154,7 @@ public final class StringUtils {
return false;
} else {
- throw new IllegalArgumentException("Not a boolean: " + stringValue);
+ throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notABoolean, stringValue));
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
index 95b3fa090b..6c421c5f50 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
@@ -53,6 +53,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import org.eclipse.jgit.JGitText;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor;
@@ -196,7 +197,7 @@ public abstract class TemporaryBuffer extends OutputStream {
public byte[] toByteArray() throws IOException {
final long len = length();
if (Integer.MAX_VALUE < len)
- throw new OutOfMemoryError("Length exceeds maximum array size");
+ throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize);
final byte[] out = new byte[(int) len];
int outPtr = 0;
for (final Block b : blocks) {
@@ -351,7 +352,7 @@ public abstract class TemporaryBuffer extends OutputStream {
final long len = length();
if (Integer.MAX_VALUE < len)
- throw new OutOfMemoryError("Length exceeds maximum array size");
+ throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize);
final byte[] out = new byte[(int) len];
final FileInputStream in = new FileInputStream(onDiskFile);
try {
@@ -419,7 +420,7 @@ public abstract class TemporaryBuffer extends OutputStream {
@Override
protected OutputStream overflow() throws IOException {
- throw new IOException("In-memory buffer limit exceeded");
+ throw new IOException(JGitText.get().inMemoryBufferLimitExceeded);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java
index e38660d632..d95849a76b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/DisabledOutputStream.java
@@ -46,6 +46,8 @@ package org.eclipse.jgit.util.io;
import java.io.IOException;
import java.io.OutputStream;
+import org.eclipse.jgit.JGitText;
+
/** An OutputStream which always throws IllegalStateExeption during write. */
public final class DisabledOutputStream extends OutputStream {
/** The canonical instance which always throws IllegalStateException. */
@@ -61,6 +63,6 @@ public final class DisabledOutputStream extends OutputStream {
// We shouldn't be writing output at this stage, there
// is nobody listening to us.
//
- throw new IllegalStateException("Writing not permitted");
+ throw new IllegalStateException(JGitText.get().writingNotPermitted);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java
index 91aa1cb6d2..575fa3ef0c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/InterruptTimer.java
@@ -43,6 +43,10 @@
package org.eclipse.jgit.util.io;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
+
/**
* Triggers an interrupt on the calling thread if it doesn't complete a block.
* <p>
@@ -113,7 +117,7 @@ public final class InterruptTimer {
*/
public void begin(final int timeout) {
if (timeout <= 0)
- throw new IllegalArgumentException("Invalid timeout: " + timeout);
+ throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTimeout, timeout));
Thread.interrupted();
state.begin(timeout);
}
@@ -193,7 +197,7 @@ public final class InterruptTimer {
synchronized void begin(final int timeout) {
if (terminated)
- throw new IllegalStateException("Timer already terminated");
+ throw new IllegalStateException(JGitText.get().timerAlreadyTerminated);
callingThread = Thread.currentThread();
deadline = now() + timeout;
notifyAll();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java
index 19d7933e1b..3670639c1d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutInputStream.java
@@ -47,6 +47,9 @@ import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
/** InputStream with a configurable timeout. */
public class TimeoutInputStream extends FilterInputStream {
@@ -80,7 +83,7 @@ public class TimeoutInputStream extends FilterInputStream {
*/
public void setTimeout(final int millis) {
if (millis < 0)
- throw new IllegalArgumentException("Invalid timeout: " + millis);
+ throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTimeout, millis));
timeout = millis;
}
@@ -134,6 +137,6 @@ public class TimeoutInputStream extends FilterInputStream {
}
private static InterruptedIOException readTimedOut() {
- return new InterruptedIOException("Read timed out");
+ return new InterruptedIOException(JGitText.get().readTimedOut);
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java
index a826086cd1..59ac7b21e5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/TimeoutOutputStream.java
@@ -46,6 +46,9 @@ package org.eclipse.jgit.util.io;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.OutputStream;
+import java.text.MessageFormat;
+
+import org.eclipse.jgit.JGitText;
/** OutputStream with a configurable timeout. */
public class TimeoutOutputStream extends OutputStream {
@@ -81,7 +84,7 @@ public class TimeoutOutputStream extends OutputStream {
*/
public void setTimeout(final int millis) {
if (millis < 0)
- throw new IllegalArgumentException("Invalid timeout: " + millis);
+ throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidTimeout, millis));
timeout = millis;
}
@@ -147,6 +150,6 @@ public class TimeoutOutputStream extends OutputStream {
}
private static InterruptedIOException writeTimedOut() {
- return new InterruptedIOException("Write timed out");
+ return new InterruptedIOException(JGitText.get().writeTimedOut);
}
}