PageAnalysis analysis,
Collection<CheckErrorResult> errors, boolean onlyAutomatic) {
if (analysis == null) {
return false;
}
Namespace categoryNamespace = analysis.getWikiConfiguration().getNamespace(Namespace.CATEGORY);
if (categoryNamespace == null) {
return false;
}
Collection<PageElementCategory> categories = analysis.getCategories();
if (categories == null) {
return false;
}
boolean result = false;
for (PageElementCategory category : categories) {
String namespace = category.getCategoryNotTrimmed().trim();
boolean lowerCaseNamespace = false;
if ((namespace != null) &&
(namespace.length() > 0) &&
(Character.isLowerCase(namespace.charAt(0)))) {
lowerCaseNamespace = true;
namespace = "" + Character.toUpperCase(namespace.charAt(0)) + namespace.substring(1);
}
String categoryName = category.getNameNotTrimmed();
if (categoryName != null) {
categoryName = categoryName.trim();
}
boolean lowerCaseName = false;
if ((categoryName != null) &&
(categoryName.length() > 0) &&
(Character.isLowerCase(categoryName.charAt(0)))) {
lowerCaseName = true;
categoryName = "" + Character.toUpperCase(categoryName.charAt(0)) + categoryName.substring(1);
}
String categorySort = category.getSort();
if ("".equals(categorySort)) {
categorySort = category.getSortNotTrimmed();
}
/*boolean lowerCaseSort = false;
if ((categorySort != null) &&
(categorySort.length() > 0) &&
(Character.isLowerCase(categorySort.charAt(0)))) {
lowerCaseSort = true;
categorySort = "" + Character.toUpperCase(categorySort.charAt(0)) + categorySort.substring(1);
}*/
if (lowerCaseNamespace || lowerCaseName) {
if (errors == null) {
return true;
}
result = true;
CheckErrorResult errorResult = createCheckErrorResult(
analysis, category.getBeginIndex(), category.getEndIndex());
if (categorySort != null) {
errorResult.addReplacement(
"[[" + categoryNamespace.getTitle() + ":" + categoryName + "|" + categorySort + "]]");
} else {
errorResult.addReplacement(
"[[" + categoryNamespace.getTitle() + ":" + categoryName + "]]");
}
errors.add(errorResult);
}
}
return result;