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.JClassDefprivate final Stringprivate final Stringprivate static final Stringprivate static final Stringprivate final MessageInterface(package private) final ProcessingEnvironment(package private) final org.jboss.jdeparser.JSourceFileprivate final org.jboss.jdeparser.JSourcesprivate 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.JMethodDefaddMessageMethod(MessageMethod messageMethod) Adds a method to return the message value.(package private) org.jboss.jdeparser.JMethodDefaddMessageMethod(MessageMethod messageMethod, String messageValue) Adds a method to return the message value.(package private) org.jboss.jdeparser.JCallcreateLocaleGetter(String locale, boolean override) Creates the method used to get the locale for formatting messages.protected org.jboss.jdeparser.JMethodDefCreates the read resolve method and instance field.private org.jboss.jdeparser.JExprdetermineLocale(String locale, org.jboss.jdeparser.JType localeType) final voidWrites the generated source file to the file system.(package private) org.jboss.jdeparser.JClassDefGenerate the code corresponding to this class modelfinal MessageInterfaceReturns the message interface being used.final StringGet 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
localeparameter isnulltheMessageLogger.rootLocale()orMessageBundle.rootLocale()will be used to determine the locale to use.- Parameters:
locale- the locale to useoverride-trueif theOverrideannotation 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)
-