Class ClassModel
java.lang.Object
org.jboss.logging.processor.generator.model.ClassModel
- Direct Known Subclasses:
ImplementationClassModel
,MessageBundleTranslator
,MessageLoggerTranslator
The basic java class model.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.jboss.jdeparser.JClassDef
private final String
private final String
private static final String
private static final String
private final MessageInterface
(package private) final ProcessingEnvironment
(package private) final org.jboss.jdeparser.JSourceFile
private final org.jboss.jdeparser.JSources
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionClassModel
(ProcessingEnvironment processingEnv, MessageInterface messageInterface, String className, String superClassName) Construct a class model. -
Method Summary
Modifier and TypeMethodDescription(package private) org.jboss.jdeparser.JMethodDef
addMessageMethod
(MessageMethod messageMethod) Adds a method to return the message value.(package private) org.jboss.jdeparser.JMethodDef
addMessageMethod
(MessageMethod messageMethod, String messageValue) Adds a method to return the message value.(package private) org.jboss.jdeparser.JCall
createLocaleGetter
(String locale, boolean override) Creates the method used to get the locale for formatting messages.protected org.jboss.jdeparser.JMethodDef
Creates the read resolve method and instance field.private org.jboss.jdeparser.JExpr
determineLocale
(String locale, org.jboss.jdeparser.JType localeType) final void
Writes the generated source file to the file system.(package private) org.jboss.jdeparser.JClassDef
Generate the code corresponding to this class modelfinal MessageInterface
Returns the message interface being used.final String
Get the class name.
-
Field Details
-
INSTANCE_FIELD_NAME
- See Also:
-
GET_INSTANCE_METHOD_NAME
- See Also:
-
sources
private final org.jboss.jdeparser.JSources sources -
classDef
private final org.jboss.jdeparser.JClassDef classDef -
messageInterface
-
className
-
superClassName
-
format
-
messageMethods
-
sourceFile
final org.jboss.jdeparser.JSourceFile sourceFile -
processingEnv
-
-
Constructor Details
-
ClassModel
ClassModel(ProcessingEnvironment processingEnv, MessageInterface messageInterface, String className, String superClassName) Construct a class model.- Parameters:
processingEnv
- the processing environmentmessageInterface
- the message interface to implement.superClassName
- the super class used for the translation implementations.
-
-
Method Details
-
messageInterface
Returns the message interface being used.- Returns:
- the message interface.
-
generateAndWrite
Writes the generated source file to the file system.- Throws:
IOException
- if the file could not be written
-
generateModel
Generate the code corresponding to this class model- Returns:
- the generated code
- Throws:
IllegalStateException
- if the class has already been defined.
-
addMessageMethod
Adds a method to return the message value. The method name should be the method name annotatedorg.jboss.logging.Message
. This method will be appended with$str
.If the message method has already been defined the previously created method is returned.
- Parameters:
messageMethod
- the message method- Returns:
- the newly created method.
- Throws:
IllegalStateException
- if this method is called before the generateModel method
-
addMessageMethod
Adds a method to return the message value. The method name should be the method name annotatedorg.jboss.logging.Message
. This method will be appended with$str
.If the message method has already been defined the previously created method is returned.
- Parameters:
messageMethod
- the message method.messageValue
- the message value.- Returns:
- the newly created method.
- Throws:
IllegalStateException
- if this method is called before the generateModel method
-
qualifiedClassName
Get the class name.- Returns:
- the class name
-
createReadResolveMethod
protected org.jboss.jdeparser.JMethodDef createReadResolveMethod()Creates the read resolve method and instance field.- Returns:
- the read resolve method.
-
createLocaleGetter
Creates the method used to get the locale for formatting messages.If the
locale
parameter isnull
theMessageLogger.rootLocale()
orMessageBundle.rootLocale()
will be used to determine the locale to use.- Parameters:
locale
- the locale to useoverride
-true
if theOverride
annotation should be added to the method- Returns:
- the call to the locale getter
-
determineLocale
private org.jboss.jdeparser.JExpr determineLocale(String locale, org.jboss.jdeparser.JType localeType)
-