removed duplicate code in PackageHtml and Translation
by introducing a protected helper method in AbstractFileSetCheck
This commit is contained in:
parent
83eb1ff5e6
commit
64f12b89cd
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue