Class ClassModel
- java.lang.Object
-
- org.jboss.logging.processor.generator.model.ClassModel
-
- Direct Known Subclasses:
ImplementationClassModel,MessageBundleTranslator,MessageLoggerTranslator
public abstract class ClassModel extends java.lang.ObjectThe basic java class model.
-
-
Field Summary
Fields Modifier and Type Field Description private org.jboss.jdeparser.JClassDefclassDefprivate java.lang.StringclassNameprivate java.lang.Stringformatprivate static java.lang.StringGET_INSTANCE_METHOD_NAMEprivate static java.lang.StringINSTANCE_FIELD_NAMEprivate MessageInterfacemessageInterfaceprivate java.util.Map<java.lang.String,org.jboss.jdeparser.JMethodDef>messageMethods(package private) javax.annotation.processing.ProcessingEnvironmentprocessingEnv(package private) org.jboss.jdeparser.JSourceFilesourceFileprivate org.jboss.jdeparser.JSourcessourcesprivate java.lang.StringsuperClassName
-
Constructor Summary
Constructors Constructor Description ClassModel(javax.annotation.processing.ProcessingEnvironment processingEnv, MessageInterface messageInterface, java.lang.String className, java.lang.String superClassName)Construct a class model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) org.jboss.jdeparser.JMethodDefaddMessageMethod(MessageMethod messageMethod)Adds a method to return the message value.(package private) org.jboss.jdeparser.JMethodDefaddMessageMethod(MessageMethod messageMethod, java.lang.String messageValue)Adds a method to return the message value.(package private) org.jboss.jdeparser.JCallcreateLocaleGetter(java.lang.String locale, boolean override)Creates the method used to get the locale for formatting messages.protected org.jboss.jdeparser.JMethodDefcreateReadResolveMethod()Creates the read resolve method and instance field.private org.jboss.jdeparser.JExprdetermineLocale(java.lang.String locale, org.jboss.jdeparser.JType localeType)voidgenerateAndWrite()Writes the generated source file to the file system.(package private) org.jboss.jdeparser.JClassDefgenerateModel()Generate the code corresponding to this class modelMessageInterfacemessageInterface()Returns the message interface being used.java.lang.StringqualifiedClassName()Get the class name.
-
-
-
Field Detail
-
INSTANCE_FIELD_NAME
private static final java.lang.String INSTANCE_FIELD_NAME
- See Also:
- Constant Field Values
-
GET_INSTANCE_METHOD_NAME
private static final java.lang.String GET_INSTANCE_METHOD_NAME
- See Also:
- Constant Field Values
-
sources
private final org.jboss.jdeparser.JSources sources
-
classDef
private final org.jboss.jdeparser.JClassDef classDef
-
messageInterface
private final MessageInterface messageInterface
-
className
private final java.lang.String className
-
superClassName
private final java.lang.String superClassName
-
format
private final java.lang.String format
-
messageMethods
private final java.util.Map<java.lang.String,org.jboss.jdeparser.JMethodDef> messageMethods
-
sourceFile
final org.jboss.jdeparser.JSourceFile sourceFile
-
processingEnv
final javax.annotation.processing.ProcessingEnvironment processingEnv
-
-
Constructor Detail
-
ClassModel
ClassModel(javax.annotation.processing.ProcessingEnvironment processingEnv, MessageInterface messageInterface, java.lang.String className, java.lang.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 Detail
-
messageInterface
public final MessageInterface messageInterface()
Returns the message interface being used.- Returns:
- the message interface.
-
generateAndWrite
public final void generateAndWrite() throws java.io.IOExceptionWrites the generated source file to the file system.- Throws:
java.io.IOException- if the file could not be written
-
generateModel
org.jboss.jdeparser.JClassDef generateModel() throws java.lang.IllegalStateExceptionGenerate the code corresponding to this class model- Returns:
- the generated code
- Throws:
java.lang.IllegalStateException- if the class has already been defined.
-
addMessageMethod
org.jboss.jdeparser.JMethodDef addMessageMethod(MessageMethod messageMethod)
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:
java.lang.IllegalStateException- if this method is called before the generateModel method
-
addMessageMethod
org.jboss.jdeparser.JMethodDef addMessageMethod(MessageMethod messageMethod, java.lang.String messageValue)
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:
java.lang.IllegalStateException- if this method is called before the generateModel method
-
qualifiedClassName
public final java.lang.String 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
org.jboss.jdeparser.JCall createLocaleGetter(java.lang.String locale, boolean override)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(java.lang.String locale, org.jboss.jdeparser.JType localeType)
-
-