JBoss Logging I18n Tools 1.0.0.Beta7

org.jboss.logging.model
Class ClassModel

java.lang.Object
  extended by org.jboss.logging.model.ClassModel
Direct Known Subclasses:
ImplementationClassModel, MessageBundleTranslator, MessageLoggerTranslator

public abstract class ClassModel
extends Object

The basic java class model.

Author:
Kevin Pollet - SERLI - (kevin.pollet@serli.com), James R. Perkins

Constructor Summary
  ClassModel(String className, String superClassName)
          Construct a class model.
protected ClassModel(String className, String projectCode, String superClassName, String... interfaceNames)
          Construct a class model.
 
Method Summary
protected  com.sun.codemodel.internal.JMethod addMessageMethod(MethodDescriptor methodDescriptor)
          Adds a method to return the message value.
protected  com.sun.codemodel.internal.JMethod addMessageMethod(MethodDescriptor methodDescriptor, String messageValue)
          Adds a method to return the message value.
 void create(JavaFileObject fileObject)
          Creates the source file.
protected  com.sun.codemodel.internal.JCodeModel generateModel()
          Generate the code corresponding to this class model
 String getClassName()
          Get the class name.
 com.sun.codemodel.internal.JCodeModel getCodeModel()
           
 com.sun.codemodel.internal.JDefinedClass getDefinedClass()
          Returns the main enclosing class.
 String getProjectCode()
          Get the project code from the annotation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassModel

public ClassModel(String className,
                  String superClassName)
Construct a class model.

Parameters:
className - the qualified class name.
superClassName - the qualified super class name.

ClassModel

protected ClassModel(String className,
                     String projectCode,
                     String superClassName,
                     String... interfaceNames)
Construct a class model.

Parameters:
className - the qualified class name.
projectCode - the project code.
superClassName - the super class name.
interfaceNames - an array of interfaces to implement.
Method Detail

create

public final void create(JavaFileObject fileObject)
                  throws IOException,
                         IllegalStateException
Creates the source file.

Parameters:
fileObject - the files object to write the source to.
Throws:
IOException - if the file could not be written.
IllegalStateException - if the implementation is in an invalid state.

generateModel

protected com.sun.codemodel.internal.JCodeModel generateModel()
                                                       throws IllegalStateException
Generate the code corresponding to this class model

Returns:
the generated code
Throws:
IllegalStateException - if the class has already been defined.

addMessageMethod

protected com.sun.codemodel.internal.JMethod addMessageMethod(MethodDescriptor methodDescriptor)
Adds a method to return the message value. The method name should be the method name annotated org.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:
methodDescriptor - the method descriptor.
Returns:
the newly created method.
Throws:
IllegalStateException - if this method is called before the generateModel method

addMessageMethod

protected com.sun.codemodel.internal.JMethod addMessageMethod(MethodDescriptor methodDescriptor,
                                                              String messageValue)
Adds a method to return the message value. The method name should be the method name annotated org.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:
methodDescriptor - the method descriptor.
messageValue - the message value.
Returns:
the newly created method.
Throws:
IllegalStateException - if this method is called before the generateModel method

getCodeModel

public com.sun.codemodel.internal.JCodeModel getCodeModel()

getDefinedClass

public final com.sun.codemodel.internal.JDefinedClass getDefinedClass()
Returns the main enclosing class.

Returns:
the main enclosing class.

getClassName

public final String getClassName()
Get the class name.

Returns:
the class name

getProjectCode

public String getProjectCode()
Get the project code from the annotation.

Returns:
the project code or null if one was not specified.

JBoss Logging I18n Tools 1.0.0.Beta7

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.