java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
com.puppycrawl.tools.checkstyle.checks.TranslationCheck
- All Implemented Interfaces:
- com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable, com.puppycrawl.tools.checkstyle.api.FileSetCheck
- public class TranslationCheck
- extends com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
The TranslationCheck class helps to ensure the correct translation of code by
checking property files for consistency regarding their keys.
Two property files describing one and the same context are consistent if they
contain the same keys.
An example of how to configure the check is:
<module name="Translation"/>
| Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TranslationCheck
public TranslationCheck()
- Creates a new
TranslationCheck instance.
extractPropertyIdentifier
private static java.lang.String extractPropertyIdentifier(java.io.File aFile)
- Gets the basename (the unique prefix) of a property file. For example
"xyz/messages" is the basename of "xyz/messages.properties",
"xyz/messages_de_AT.properties", "xyz/messages_en.properties", etc.
arrangePropertyFiles
private static java.util.Map arrangePropertyFiles(java.io.File[] aPropFiles)
- Arranges a set of property files by their prefix.
The method returns a Map object. The filename prefixes
work as keys each mapped to a set of files.
loadKeys
private java.util.Set loadKeys(java.io.File aFile)
- Loads the keys of the specified property file into a set.
logIOException
private void logIOException(java.io.IOException aEx,
java.io.File aFile)
- helper method to log an io exception.
compareKeySets
private void compareKeySets(java.util.Set aKeys,
java.util.Map aFileMap)
- Compares the key sets of the given property files (arranged in a map)
with the specified key set. All missing keys are reported.
checkPropertyFileSets
private void checkPropertyFileSets(java.util.Map aPropFiles)
- Tests whether the given property files (arranged by their prefixes
in a Map) contain the proper keys.
Each group of files must have the same keys. If this is not the case
an error message is posted giving information which key misses in
which file.
process
public void process(java.io.File[] aFiles)
- This method searches for property files in the specified file array
and checks whether the key usage is consistent.
Two property files which have the same prefix should use the same
keys. If this is not the case the missing keys are reported.