Package org.jboss.logging.processor.apt
Class TranslationClassGenerator
java.lang.Object
org.jboss.logging.processor.apt.AbstractGenerator
org.jboss.logging.processor.apt.TranslationClassGenerator
@SupportedOptions({"translationFilesPath","skipTranslations"})
final class TranslationClassGenerator
extends AbstractGenerator
The translation class generator.
The aim of this generator is to generate the classes corresponding to translation files of a MessageLogger or MessageBundle.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
Translation file Filter. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
private final boolean
private static final String
The properties file pattern.static final String
private final String
Fields inherited from class org.jboss.logging.processor.apt.AbstractGenerator
processingEnv
-
Constructor Summary
ConstructorsConstructorDescriptionTranslationClassGenerator
(ProcessingEnvironment processingEnv) Construct an instance of the Translation Class Generator. -
Method Summary
Modifier and TypeMethodDescriptionprivate Map<File,
Map<MessageMethod, String>> allInterfaceTranslations
(MessageInterface messageInterface, List<File> files) findTranslationFiles
(MessageInterface messageInterface) private void
generateSourceFileFor
(MessageInterface messageInterface, File translationFile, Map<MessageMethod, String> translations) Generate a class for the given translation file.private static FormatValidator
getValidatorFor
(MessageMethod messageMethod, String translationMessage) void
processTypeElement
(TypeElement annotation, TypeElement element, MessageInterface messageInterface) Processes a type element.private Map<MessageMethod,
String> validateTranslationMessages
(MessageInterface messageInterface, File file) Returns only the valid translations message corresponding to the declaredMessageMethod
methods in theMessageBundle
orMessageLogger
interface.Methods inherited from class org.jboss.logging.processor.apt.AbstractGenerator
getName, getSupportedOptions, logger
-
Field Details
-
TRANSLATION_FILES_PATH_OPTION
- See Also:
-
SKIP_TRANSLATIONS
- See Also:
-
TRANSLATION_FILE_EXTENSION_PATTERN
The properties file pattern. The property file must match the given pattern org.pkgname.InterfaceName.i18n_locale.properties where locale is :- xx - where xx is the language like (e.g. en)
- xx_YY - where xx is the language and YY is the country like (e.g. en_US)
- xx_YY_ZZ - where xx is the language, YY is the country and ZZ is the variant like (e.g. en_US_POSIX)
- See Also:
-
translationFilesPath
-
skipTranslations
private final boolean skipTranslations
-
-
Constructor Details
-
TranslationClassGenerator
Construct an instance of the Translation Class Generator.- Parameters:
processingEnv
- the processing environment
-
-
Method Details
-
processTypeElement
public void processTypeElement(TypeElement annotation, TypeElement element, MessageInterface messageInterface) Description copied from class:AbstractGenerator
Processes a type element.- Specified by:
processTypeElement
in classAbstractGenerator
- Parameters:
annotation
- the annotation who trigger the processingelement
- the element that contains the methods.messageInterface
- the message interface to implement.
-
allInterfaceTranslations
private Map<File,Map<MessageMethod, allInterfaceTranslationsString>> (MessageInterface messageInterface, List<File> files) throws IOException - Throws:
IOException
-
findTranslationFiles
- Throws:
IOException
-
validateTranslationMessages
private Map<MessageMethod,String> validateTranslationMessages(MessageInterface messageInterface, File file) Returns only the valid translations message corresponding to the declaredMessageMethod
methods in theMessageBundle
orMessageLogger
interface.- Parameters:
messageInterface
- the message interface.file
- the translation file- Returns:
- the valid translations messages
-
generateSourceFileFor
private void generateSourceFileFor(MessageInterface messageInterface, File translationFile, Map<MessageMethod, String> translations) Generate a class for the given translation file.- Parameters:
messageInterface
- the message interfacetranslationFile
- the translation filetranslations
- the translations message
-
getValidatorFor
private static FormatValidator getValidatorFor(MessageMethod messageMethod, String translationMessage)
-