diff options
author | Sasa Zivkov <sasa.zivkov@sap.com> | 2010-05-19 16:59:28 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-05-19 14:37:16 -0700 |
commit | f3d8a8ecad614906a2c4ec0077cdb24129da6c6d (patch) | |
tree | 34d041692beff0f392c27869f49b76c0fc2053e6 /org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java | |
parent | 2e961989e42b1fe7e8bd9eaa7a3d2e88a0d1d001 (diff) | |
download | jgit-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/dircache/DirCache.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java index 3a8abc1a73..42fea48520 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java @@ -56,9 +56,11 @@ import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.security.DigestOutputStream; import java.security.MessageDigest; +import java.text.MessageFormat; import java.util.Arrays; import java.util.Comparator; +import org.eclipse.jgit.JGitText; import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.UnmergedPathException; import org.eclipse.jgit.lib.Constants; @@ -200,7 +202,7 @@ public class DirCache { throws CorruptObjectException, IOException { final DirCache c = new DirCache(indexLocation); if (!c.lock()) - throw new IOException("Cannot lock " + indexLocation); + throw new IOException(MessageFormat.format(JGitText.get().cannotLock, indexLocation)); try { c.read(); @@ -319,7 +321,7 @@ public class DirCache { */ public void read() throws IOException, CorruptObjectException { if (liveFile == null) - throw new IOException("DirCache does not have a backing file"); + throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); if (!liveFile.exists()) clear(); else if (liveFile.lastModified() != lastModified) { @@ -363,13 +365,13 @@ public class DirCache { IO.readFully(in, hdr, 0, 12); md.update(hdr, 0, 12); if (!is_DIRC(hdr)) - throw new CorruptObjectException("Not a DIRC file."); + throw new CorruptObjectException(JGitText.get().notADIRCFile); final int ver = NB.decodeInt32(hdr, 4); if (ver != 2) - throw new CorruptObjectException("Unknown DIRC version " + ver); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().unknownDIRCVersion, ver)); entryCnt = NB.decodeInt32(hdr, 8); if (entryCnt < 0) - throw new CorruptObjectException("DIRC has too many entries."); + throw new CorruptObjectException(JGitText.get().DIRCHasTooManyEntries); // Load the individual file entries. // @@ -398,9 +400,8 @@ public class DirCache { switch (NB.decodeInt32(hdr, 0)) { case EXT_TREE: { if (Integer.MAX_VALUE < sz) { - throw new CorruptObjectException("DIRC extension " - + formatExtensionName(hdr) + " is too large at " - + sz + " bytes."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().DIRCExtensionIsTooLargeAt + , formatExtensionName(hdr), sz)); } final byte[] raw = new byte[(int) sz]; IO.readFully(in, raw, 0, raw.length); @@ -421,16 +422,15 @@ public class DirCache { // _required_ to understand this index format. // Since we did not trap it above we must abort. // - throw new CorruptObjectException("DIRC extension " - + formatExtensionName(hdr) - + " not supported by this version."); + throw new CorruptObjectException(MessageFormat.format(JGitText.get().DIRCExtensionNotSupportedByThisVersion + , formatExtensionName(hdr))); } } } final byte[] exp = md.digest(); if (!Arrays.equals(exp, hdr)) { - throw new CorruptObjectException("DIRC checksum mismatch"); + throw new CorruptObjectException(JGitText.get().DIRCChecksumMismatch); } } @@ -441,9 +441,8 @@ public class DirCache { while (0 < sz) { int n = in.read(b, 0, (int) Math.min(b.length, sz)); if (n < 0) { - throw new EOFException("Short read of optional DIRC extension " - + formatExtensionName(hdr) + "; expected another " + sz - + " bytes within the section."); + throw new EOFException(MessageFormat.format(JGitText.get().shortReadOfOptionalDIRCExtensionExpectedAnotherBytes + , formatExtensionName(hdr), sz)); } md.update(b, 0, n); sz -= n; @@ -475,7 +474,7 @@ public class DirCache { */ public boolean lock() throws IOException { if (liveFile == null) - throw new IOException("DirCache does not have a backing file"); + throw new IOException(JGitText.get().dirCacheDoesNotHaveABackingFile); final LockFile tmp = new LockFile(liveFile); if (tmp.lock()) { tmp.setNeedStatInformation(true); @@ -585,10 +584,10 @@ public class DirCache { private void requireLocked(final LockFile tmp) { if (liveFile == null) - throw new IllegalStateException("DirCache is not locked"); + throw new IllegalStateException(JGitText.get().dirCacheIsNotLocked); if (tmp == null) - throw new IllegalStateException("DirCache " - + liveFile.getAbsolutePath() + " not locked."); + throw new IllegalStateException(MessageFormat.format(JGitText.get().dirCacheFileIsNotLocked + , liveFile.getAbsolutePath())); } /** |