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 AbstractGeneratorThe 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 Classes Modifier and Type Class Description private classTranslationClassGenerator.TranslationFileFilterTranslation file Filter.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSKIP_TRANSLATIONSprivate booleanskipTranslationsprivate static java.lang.StringTRANSLATION_FILE_EXTENSION_PATTERNThe properties file pattern.static java.lang.StringTRANSLATION_FILES_PATH_OPTIONprivate java.lang.StringtranslationFilesPath-
Fields inherited from class org.jboss.logging.processor.apt.AbstractGenerator
processingEnv
-
-
Constructor Summary
Constructors Constructor Description TranslationClassGenerator(javax.annotation.processing.ProcessingEnvironment processingEnv)Construct an instance of the Translation Class Generator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.Map<java.io.File,java.util.Map<MessageMethod,java.lang.String>>allInterfaceTranslations(MessageInterface messageInterface, java.util.List<java.io.File> files)private java.util.List<java.io.File>findTranslationFiles(MessageInterface messageInterface)private voidgenerateSourceFileFor(MessageInterface messageInterface, java.io.File translationFile, java.util.Map<MessageMethod,java.lang.String> translations)Generate a class for the given translation file.private static FormatValidatorgetValidatorFor(MessageMethod messageMethod, java.lang.String translationMessage)voidprocessTypeElement(javax.lang.model.element.TypeElement annotation, javax.lang.model.element.TypeElement element, MessageInterface messageInterface)Processes a type element.private java.util.Map<MessageMethod,java.lang.String>validateTranslationMessages(MessageInterface messageInterface, java.io.File file)Returns only the valid translations message corresponding to the declaredMessageMethodmethods in theMessageBundleorMessageLoggerinterface.-
Methods inherited from class org.jboss.logging.processor.apt.AbstractGenerator
getName, getSupportedOptions, logger
-
-
-
-
Field Detail
-
TRANSLATION_FILES_PATH_OPTION
public static final java.lang.String TRANSLATION_FILES_PATH_OPTION
- See Also:
- Constant Field Values
-
SKIP_TRANSLATIONS
public static final java.lang.String SKIP_TRANSLATIONS
- See Also:
- Constant Field Values
-
TRANSLATION_FILE_EXTENSION_PATTERN
private static final java.lang.String 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:
- Constant Field Values
-
translationFilesPath
private final java.lang.String translationFilesPath
-
skipTranslations
private final boolean skipTranslations
-
-
Method Detail
-
processTypeElement
public void processTypeElement(javax.lang.model.element.TypeElement annotation, javax.lang.model.element.TypeElement element, MessageInterface messageInterface)Description copied from class:AbstractGeneratorProcesses a type element.- Specified by:
processTypeElementin classAbstractGenerator- Parameters:
annotation- the annotation who trigger the processingelement- the element that contains the methods.messageInterface- the message interface to implement.
-
allInterfaceTranslations
private java.util.Map<java.io.File,java.util.Map<MessageMethod,java.lang.String>> allInterfaceTranslations(MessageInterface messageInterface, java.util.List<java.io.File> files) throws java.io.IOException
- Throws:
java.io.IOException
-
findTranslationFiles
private java.util.List<java.io.File> findTranslationFiles(MessageInterface messageInterface) throws java.io.IOException
- Throws:
java.io.IOException
-
validateTranslationMessages
private java.util.Map<MessageMethod,java.lang.String> validateTranslationMessages(MessageInterface messageInterface, java.io.File file)
Returns only the valid translations message corresponding to the declaredMessageMethodmethods in theMessageBundleorMessageLoggerinterface.- Parameters:
messageInterface- the message interface.file- the translation file- Returns:
- the valid translations messages
-
generateSourceFileFor
private void generateSourceFileFor(MessageInterface messageInterface, java.io.File translationFile, java.util.Map<MessageMethod,java.lang.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, java.lang.String translationMessage)
-
-