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.Object
The basic java class model.
-
-
Field Summary
Fields Modifier and Type Field Description private org.jboss.jdeparser.JClassDef
classDef
private java.lang.String
className
private java.lang.String
format
private static java.lang.String
GET_INSTANCE_METHOD_NAME
private static java.lang.String
INSTANCE_FIELD_NAME
private MessageInterface
messageInterface
private java.util.Map<java.lang.String,org.jboss.jdeparser.JMethodDef>
messageMethods
(package private) javax.annotation.processing.ProcessingEnvironment
processingEnv
(package private) org.jboss.jdeparser.JSourceFile
sourceFile
private org.jboss.jdeparser.JSources
sources
private java.lang.String
superClassName
-
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.JMethodDef
addMessageMethod(MessageMethod messageMethod)
Adds a method to return the message value.(package private) org.jboss.jdeparser.JMethodDef
addMessageMethod(MessageMethod messageMethod, java.lang.String messageValue)
Adds a method to return the message value.(package private) org.jboss.jdeparser.JCall
createLocaleGetter(java.lang.String locale, boolean override)
Creates the method used to get the locale for formatting messages.protected org.jboss.jdeparser.JMethodDef
createReadResolveMethod()
Creates the read resolve method and instance field.private org.jboss.jdeparser.JExpr
determineLocale(java.lang.String locale, org.jboss.jdeparser.JType localeType)
void
generateAndWrite()
Writes the generated source file to the file system.(package private) org.jboss.jdeparser.JClassDef
generateModel()
Generate the code corresponding to this class modelMessageInterface
messageInterface()
Returns the message interface being used.java.lang.String
qualifiedClassName()
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.IOException
Writes 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.IllegalStateException
Generate 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
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(java.lang.String locale, org.jboss.jdeparser.JType localeType)
-
-