4.5.1. getShortInfo

The method getShortInfo has to return a short sentence describing the provided functionality of the rule. This needs to be plain text without markup. The text is intended to be displayed in the user interface. The languageCode argument passes the current user interface language. Therefore, the text returned by this method should be in the language given by the languageCode argument. If the description is not available in the passed language, then the returned description should be in English.
Therefore, a simple implementation of this method could be as follows:
public String getShortInfo(String languageCode)
{
    return "Checks the length and reports or removes empty span elements.";
}
As language dependent text should not be defined in the Java source directly, you could also load the description from the plug-in's locale.properties file, as shown in the following example:
public String getShortInfo(String languageCode)
{
    return label(languageCode, "shortInfo");
}

private String label(String lang, String msg, Object... args)
{
    return PluginUtil.getLabel(lang, msg, args);
}
Localized strings can be retrieved through the getLabel method of the org.docma.plugin.PluginUtil class. Because retrieving localized strings is needed more than once, the functionality has been placed in a separate method named label.
Given this implementation of the getShortInfo method, you have to define the localized strings in the locale.properties file with the key "shortInfo". See Chapter 4.2, Creating a plug-in package for more information.
Loading localized strings from a class-specific XML file
Although it is common to place locale dependent text in the plug-in's locale.properties file, for rule implementations it can be useful to have the localized text directly attached to the class. This can be achieved by using the getResourceString method instead of the getLabel method. Therefore the implementation of the label method could be changed as follows:
private String label(String lang, String msg, Object... args)
{
    return PluginUtil.getResourceString(this.getClass(), lang, msg, args);
}
The first parameter of the getResourceString method has to be the class for which to retrieve the localized string. Given this implementation, the localized text has to be stored as a XML properties file in the same folder where the .class file resides. The filename of the XML properties file has to be the name of the class, followed by an underscore, followed by the language code, followed by the file extension .xml. Given our example, to provide localized strings for the language "English", we have to place a file named MyHTMLRule_en.xml in the plug-in package within the folder where the MyHTMLRule.class file resides. The format of the XML properties file is defined by the java.util.Properties class. The complete XML properties file for our example is given in Section 4.5.11, “The complete example” below.