Griffon 1.2.0

org.codehaus.griffon.ast
[Java] Class MessageSourceAwareASTTransformation

java.lang.Object
  org.codehaus.griffon.ast.AbstractASTTransformation
      org.codehaus.griffon.ast.MessageSourceAwareASTTransformation

@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
public class MessageSourceAwareASTTransformation
extends AbstractASTTransformation

Handles generation of code for the @MessageSourceAware annotation.

Authors:
Andres Almiray


Field Summary
private static String ARGS

private static String DEFAULT_MESSAGE

private static String KEY

private static String LOCALE

private static ClassNode LOCALE_TYPE

private static Logger LOG

private static ClassNode MESSAGE_SOURCE_AWARE_TYPE

private static ClassNode MESSAGE_SOURCE_TYPE

private static String METHOD_GET_MESSAGE

private static ClassNode NO_SUCH_MESSAGE_EXCEPTION_TYPE

private static ClassNode OBJECT_ARRAY_TYPE

 
Fields inherited from class AbstractASTTransformation
APPLICATION_HOLDER_TYPE, COLLECTIONS_CLASS
 
Constructor Summary
MessageSourceAwareASTTransformation()

 
Method Summary
static void addResourceLocatorIfNeeded(SourceUnit source, ClassNode classNode)

static void apply(ClassNode declaringClass)

Adds the necessary field and methods to support message resolution.

static boolean hasMessageSourceAwareAnnotation(AnnotatedNode node)

Convenience method to see if an annotated node is @MessageSourceAware.

protected static boolean needsMessageSource(ClassNode declaringClass, SourceUnit sourceUnit)

Snoops through the declaring class and all parents looking for methods

  • public String getMessage(java.lang.String)
  • public String getMessage(java.lang.String, java.util.Locale)
  • public String getMessage(java.lang.String, java.lang.Object[])
  • public String getMessage(java.lang.String, java.lang.Object[], java.util.Locale)
  • public String getMessage(java.lang.String, java.util.List)
  • public String getMessage(java.lang.String, java.util.List, java.util.Locale)
  • public String getMessage(java.lang.String, java.util.Map)
  • public String getMessage(java.lang.String, java.util.Map, java.util.Locale)
  • public String getMessage(java.lang.String, java.lang.String)
  • public String getMessage(java.lang.String, java.lang.String, java.util.Locale)
  • public String getMessage(java.lang.String, java.lang.Object[], java.lang.String)
  • public String getMessage(java.lang.String, java.lang.Object[], java.lang.String, java.util.Locale)
  • public String getMessage(java.lang.String, java.util.List, java.lang.String)
  • public String getMessage(java.lang.String, java.util.List, java.lang.String, java.util.Locale)
  • public String getMessage(java.lang.String, java.util.Map, java.lang.String)
  • public String getMessage(java.lang.String, java.util.Map, java.lang.String, java.util.Locale)
If any are defined all must be defined or a compilation error results.

void visit(ASTNode[] nodes, SourceUnit source)

Handles the bulk of the processing, mostly delegating to other methods.

 
Methods inherited from class AbstractASTTransformation
addError, applicationInstance, checkNodesForAnnotationAndType, emptyMap, makeClassSafe, makeClassSafe, makeClassSafe, newClass
 

Field Detail

ARGS

private static final String ARGS


DEFAULT_MESSAGE

private static final String DEFAULT_MESSAGE


KEY

private static final String KEY


LOCALE

private static final String LOCALE


LOCALE_TYPE

private static final ClassNode LOCALE_TYPE


LOG

private static final Logger LOG


MESSAGE_SOURCE_AWARE_TYPE

private static final ClassNode MESSAGE_SOURCE_AWARE_TYPE


MESSAGE_SOURCE_TYPE

private static final ClassNode MESSAGE_SOURCE_TYPE


METHOD_GET_MESSAGE

private static final String METHOD_GET_MESSAGE


NO_SUCH_MESSAGE_EXCEPTION_TYPE

private static final ClassNode NO_SUCH_MESSAGE_EXCEPTION_TYPE


OBJECT_ARRAY_TYPE

private static final ClassNode OBJECT_ARRAY_TYPE


 
Constructor Detail

MessageSourceAwareASTTransformation

MessageSourceAwareASTTransformation()


 
Method Detail

addResourceLocatorIfNeeded

public static void addResourceLocatorIfNeeded(SourceUnit source, ClassNode classNode)


apply

public static void apply(ClassNode declaringClass)
Adds the necessary field and methods to support message resolution.

Parameters:
declaringClass - the class to which we add the support field and methods


hasMessageSourceAwareAnnotation

public static boolean hasMessageSourceAwareAnnotation(AnnotatedNode node)
Convenience method to see if an annotated node is @MessageSourceAware.
Parameters:
node - the node to check
Returns:
true if the node is an event publisher


needsMessageSource

protected static boolean needsMessageSource(ClassNode declaringClass, SourceUnit sourceUnit)
Snoops through the declaring class and all parents looking for methodsIf any are defined all must be defined or a compilation error results.
Parameters:
declaringClass - the class to search
sourceUnit - the source unit, for error reporting. @NotNull.
Returns:
true if property change support should be added


visit

public void visit(ASTNode[] nodes, SourceUnit source)
Handles the bulk of the processing, mostly delegating to other methods.
Parameters:
nodes - the ast nodes
source - the source unit for the nodes


 

Groovy Documentation