removed duplicate code in PackageHtml and Translation

by introducing a protected helper method in AbstractFileSetCheck
This commit is contained in:
lkuehne 2003-02-15 16:07:29 +00:00
parent 83eb1ff5e6
commit 64f12b89cd
3 changed files with 17 additions and 8 deletions

View File

@ -112,4 +112,19 @@ public abstract class AbstractFileSetCheck
}
}
}
/**
* Returns the Message bundle name to use for this FileSetCheck.
* The default implementation uses the <code>messages</code> bundle
* in the same package as this FileSetCeck.
* @return the message bundle name
*/
protected String getMessageBundle()
{
final String className = getClass().getName();
final int pkgEndIndex = className.lastIndexOf('.');
final String pkgName = className.substring(0, pkgEndIndex);
final String bundle = pkgName + ".messages";
return bundle;
}
}

View File

@ -68,10 +68,7 @@ public class PackageHtmlCheck extends AbstractFileSetCheck
dispatcher.fireFileStarted(path);
if (!packageHtml.exists()) {
LocalizedMessage[] errors = new LocalizedMessage[1];
final String className = getClass().getName();
final int pkgEndIndex = className.lastIndexOf('.');
final String pkgName = className.substring(0, pkgEndIndex);
final String bundle = pkgName + ".messages";
String bundle = getMessageBundle();
errors[0] = new LocalizedMessage(
0, bundle, "javadoc.packageHtml", null);
getMessageDispatcher().fireErrors(path, errors);

View File

@ -189,10 +189,7 @@ public class TranslationCheck extends AbstractFileSetCheck
for (Iterator it = keysClone.iterator(); it.hasNext();) {
Object[] key = new Object[]{it.next()};
LocalizedMessage[] errors = new LocalizedMessage[1];
final String className = getClass().getName();
final int pkgEndIndex = className.lastIndexOf('.');
final String pkgName = className.substring(0, pkgEndIndex);
final String bundle = pkgName + ".messages";
final String bundle = getMessageBundle();
errors[0] = new LocalizedMessage(
0, bundle, "translation.missingKey", key);
getMessageDispatcher().fireErrors(path, errors);