org.apache.beehive.netui.compiler
Class CompilerUtils

Object
  extended by CompilerUtils
All Implemented Interfaces:
JpfLanguageConstants

public class CompilerUtils
extends Object
implements JpfLanguageConstants


Nested Class Summary
static class CompilerUtils.BeanPropertyDeclaration
           
static class CompilerUtils.BeanPropertyDescriptor
           
static class CompilerUtils.ExtendedAnnotationProcessorEnvironment
           
static class CompilerUtils.Mutable<T>
           
 
Nested classes/interfaces inherited from interface JpfLanguageConstants
JpfLanguageConstants.ExtraInfoKeys
 
Field Summary
 
Fields inherited from interface JpfLanguageConstants
ACTION_ATTR, ACTION_EXTENSION, ACTION_EXTENSION_DOT, ACTION_OUTPUT_TAG_NAME, ACTION_OUTPUTS_ATTR, ACTION_TAG_NAME, ALTERNATE_WEB_ROOT_DIR_OPTION, ANNOTATION_INTERFACE_PREFIX, ANNOTATION_QUALIFIER, ANNOTATIONS_CLASSNAME, ANY_FORM_CLASS_NAME, APACHE_XMLOBJECT_CLASS_NAME, APPLY_TO_UNHANDLED_LOCALES_ATTR, ARG_ATTR, ARG_KEY_ATTR, ARRAY_TYPE_SUFFIX, BEA_XMLOBJECT_CLASS_NAME, BEGIN_ACTION_NAME, BOOLEAN_GETTER_PREFIX, BUNDLE_NAME_ATTR, BUNDLE_PATH_ATTR, CATCH_TAG_NAME, CATCHES_ATTR, CHARS_ATTR, COMMAND_HANDLER_TAG_NAME, CONDITION_ATTR, CONDITIONAL_FORWARDS_ATTR, CONTROLLER_TAG_NAME, COUNTRY_ATTR, CUSTOM_VALIDATOR_CONFIGS_ATTR, DEFAULT_SIMPLE_ACTION_FORWARD_NAME, DEFAULT_VALIDATION_MESSAGE_BUNDLE, DEFAULT_VALIDATION_MESSAGE_BUNDLE_NAME, DISPLAY_NAME_ATTR, DISPLAY_NAME_KEY_ATTR, DO_VALIDATION_ATTR, ERROR_TYPE_STR, EXCEPTION_HANDLER_TAG_NAME, EXTERNAL_REDIRECT_ATTR, FACES_BACKING_BEAN_CLASS, FACES_BACKING_FILE_EXTENSION, FACES_BACKING_FILE_EXTENSION_DOT, FACES_BACKING_TAG_NAME, FLOW_CONTROLLER_ACTION_CLASS, FLOWCONTROLLER_BASE_CLASS, FORM_BEAN_TAG_NAME, FORM_CLASS_NAME, FORWARD_CLASS_NAME, FORWARD_REF_ATTR, FORWARD_TAG_NAME, FORWARDS_ATTR, GETTER_PREFIX, GLOBALAPP_BASE_CLASS, GLOBALAPP_CLASSNAME, GLOBALAPP_FILE_EXTENSION, GLOBALAPP_FILE_EXTENSION_DOT, GLOBALAPP_FULL_CLASSNAME, GLOBALAPP_PACKAGE, GLOBALAPP_PARENT_PATH, GLOBALAPP_SHARED_FLOW_NAME, GLOBALAPP_SOURCE_NAME, GLOBALAPP_URI, JAVA_FILE_EXTENSION, JAVA_FILE_EXTENSION_DOT, JPF_BASE_CLASS, JPF_FILE_EXTENSION, JPF_FILE_EXTENSION_DOT, JSP_FILE_EXTENSION, KEY_ATTR, LANGUAGE_ATTR, LOCALE_RULES_ATTR, LOGIN_REQUIRED_ATTR, LONGLIVED_ATTR, MAX_FLOAT_ATTR, MAX_INT_ATTR, MESSAGE_ARG_TAG_NAME, MESSAGE_ARGS_ATTR, MESSAGE_ATTR, MESSAGE_BUNDLE_ATTR, MESSAGE_BUNDLE_TAG_NAME, MESSAGE_BUNDLES_ATTR, MESSAGE_KEY_ATTR, METHOD_ATTR, MIN_FLOAT_ATTR, MIN_INT_ATTR, MULTIPART_HANDLER_ATTR, MULTIPART_HANDLER_DISABLED_STR, MULTIPART_HANDLER_DISK_CLASSNAME, MULTIPART_HANDLER_DISK_STR, MULTIPART_HANDLER_MEMORY_CLASSNAME, MULTIPART_HANDLER_MEMORY_STR, NAME_ATTR, NAVIGATE_TO_ATTR, NAVIGATE_TO_CURRENT_PAGE_STR, NAVIGATE_TO_ENUM, NAVIGATE_TO_PAGE_LEGACY_STR, NAVIGATE_TO_PREVIOUS_ACTION_STR, NAVIGATE_TO_PREVIOUS_PAGE_STR, NESTED_ATTR, NETUI_PACKAGE, NULLABLE_ATTR, OBJECT_CLASS_NAME, OUTPUT_FORM_BEAN_ATTR, OUTPUT_FORM_BEAN_TYPE_ATTR, PAGE_FLOW_FIELD_TAG_NAME, PAGEFLOW_INTERNAL_PACKAGE, PAGEFLOW_PACKAGE, PAGEFLOW_RUNTIME_JAR, PATH_ATTR, PATTERN_ATTR, POSITION_ATTR, PREVENT_DOUBLE_SUBMIT_ATTR, PROPERTY_NAME_ATTR, RAISE_ACTION_TAG_NAME, RAISE_ACTIONS_ATTR, READONLY_ATTR, REDIRECT_ATTR, REGEX_ATTR, REQUIRED_ATTR, RESTORE_QUERY_STRING_ATTR, RETURN_ACTION_ATTR, ROLES_ALLOWED_ATTR, RULE_ATTR, RUNTIME_VERSION_ATTRIBUTE, SERIALIZABLE_CLASS_NAME, SHARED_FLOW_BASE_CLASS, SHARED_FLOW_CLASSNAME, SHARED_FLOW_FIELD_TAG_NAME, SHARED_FLOW_FILE_EXTENSION, SHARED_FLOW_FILE_EXTENSION_DOT, SHARED_FLOW_REF_TAG_NAME, SHARED_FLOW_REFS_ATTR, SIMPLE_ACTION_TAG_NAME, SIMPLE_ACTIONS_ATTR, STRICT_ATTR, STRING_CLASS_NAME, STRUTS_PACKAGE, STRUTSMERGE_ATTR, THROWABLE_CLASS_NAME, TILES_DEFINITION_ATTR, TILES_DEFINITIONS_CONFIGS_ATTR, TYPE_ATTR, USE_FORM_BEAN_ATTR, USE_FORM_BEAN_TYPE_ATTR, VALIDATABLE_BEANS_ATTR, VALIDATABLE_PROPERTIES_ATTR, VALIDATABLE_PROPERTY_TAG_NAME, VALIDATE_CREDIT_CARD_ATTR, VALIDATE_CREDIT_CARD_TAG_NAME, VALIDATE_CUSTOM_ATTR, VALIDATE_CUSTOM_TAG_NAME, VALIDATE_DATE_ATTR, VALIDATE_DATE_TAG_NAME, VALIDATE_EMAIL_ATTR, VALIDATE_EMAIL_TAG_NAME, VALIDATE_MASK_ATTR, VALIDATE_MASK_TAG_NAME, VALIDATE_MAX_LENGTH_ATTR, VALIDATE_MAX_LENGTH_TAG_NAME, VALIDATE_MIN_LENGTH_ATTR, VALIDATE_MIN_LENGTH_TAG_NAME, VALIDATE_RANGE_ATTR, VALIDATE_RANGE_TAG_NAME, VALIDATE_REQUIRED_ATTR, VALIDATE_REQUIRED_TAG_NAME, VALIDATE_TYPE_ATTR, VALIDATE_TYPE_TAG_NAME, VALIDATE_VALID_WHEN_ATTR, VALIDATE_VALID_WHEN_TAG_NAME, VALIDATION_BEAN_TAG_NAME, VALIDATION_BEANS_ATTR, VALIDATION_ERROR_FORWARD_ATTR, VALIDATION_LOCALE_RULES_TAG_NAME, VALIDATOR_MERGE_ATTR, VALIDATOR_VERSION_ATTR, VALIDATOR_VERSION_ONE_ONE_STR, VALIDATOR_VERSION_ONE_ZERO_STR, VALUE_ATTR, VARIABLES_ATTR, VARIANT_ATTR, VERSION_8_SP2_STRING, VERSION_9_0_STRING, VIEW_PROPERTIES_TAG_NAME, WEBAPP_ROOT_PACKAGE, WEBINF_DIR_NAME, WEBINF_SRC_DIR, WEBINF_SRC_PATH, XJSP_FILE_EXTENSION, XML_FORM_CLASS_NAME
 
Constructor Summary
CompilerUtils()
           
 
Method Summary
static boolean annotationsAreEqual(AnnotationMirror a1, AnnotationMirror a2, boolean allowExactDuplicates, AnnotationProcessorEnvironment env)
           
static FieldDeclaration findField(TypeDeclaration jclass, String fieldName)
           
static ClassDeclaration findInnerClass(TypeDeclaration jclass, String innerClassName)
           
static AnnotationMirror getAnnotation(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static AnnotationMirror getAnnotation(Declaration element, String unqualifiedName)
           
static List<AnnotationMirror> getAnnotationArray(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static List<AnnotationMirror> getAnnotationArray(AnnotationValue value)
           
static List<AnnotationMirror> getAnnotationArrayValue(Declaration element, String annotationName, String memberName, boolean defaultIsNull)
           
static AnnotationValue getAnnotationValue(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static AnnotationValue getAnnotationValue(Declaration element, String annotationName, String valueName)
           
static TypeMirror getArrayBaseType(ArrayType arrayType)
           
static Collection<CompilerUtils.BeanPropertyDeclaration> getBeanProperties(ClassDeclaration type, boolean getInheritedProperties)
           
static CompilerUtils.BeanPropertyDeclaration getBeanProperty(MethodDeclaration method)
           
static Boolean getBoolean(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static Boolean getBooleanValue(Declaration element, String annotationName, String memberName, boolean defaultIsNull)
           
static FieldDeclaration getClassField(TypeDeclaration jclass, String fieldName, String desiredAnnotation)
           
static Collection<FieldDeclaration> getClassFields(TypeDeclaration jclass)
           
static MethodDeclaration getClassMethod(TypeDeclaration jclass, String methodName, String desiredAnnotation)
           
static Collection<MethodDeclaration> getClassMethods(TypeDeclaration jclass, String desiredAnnotation)
           
static Collection<TypeDeclaration> getClassNestedTypes(TypeDeclaration jclass)
           
static TypeDeclaration getDeclaration(DeclaredType type)
           
static DeclaredType getDeclaredType(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static Double getDouble(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static String getEnumFieldName(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static String getEnumFieldName(AnnotationValue enumMember)
           
static File getFileRelativeToSourceFile(TypeDeclaration outerClass, String relativePath, AnnotationProcessorEnvironment env)
           
static Float getFloat(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static String getFormClassName(DeclaredType jclass, AnnotationProcessorEnvironment env)
           
static String getFormClassName(TypeDeclaration jclass, AnnotationProcessorEnvironment env)
          Get a Class.forName-able string for the given type signature.
static TypeMirror getGenericBoundsType(TypeMirror type)
           
static Integer getInteger(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static String getLoadableName(DeclaredType jclass)
           
static String getLoadableName(TypeDeclaration jclass)
          Get the qualified name of the given class, with '$' used to separate inner classes; the returned string can be used with Class.forName().
static Long getLong(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static File getOriginalFile(TypeDeclaration decl)
          Deprecated.  
static TypeDeclaration getOuterClass(MemberDeclaration classMember)
           
static TypeDeclaration getOutermostClass(MemberDeclaration classMember)
           
static String getQualifiedName(AnnotationMirror annotation)
           
static ReferenceType getReferenceType(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static String getSimpleName(AnnotationMirror annotation)
           
static File getSourceFile(TypeDeclaration decl, boolean mustBeNonNull)
           
static String getString(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static List<String> getStringArray(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static List<String> getStringArrayValue(Declaration element, String annotationName, String memberName, boolean defaultIsNull)
           
static String getStringValue(Declaration element, String annotationName, String memberName, boolean defaultIsNull)
           
static TypeMirror getTypeMirror(AnnotationMirror annotation, String memberName, boolean defaultIsNull)
           
static Object getValue(Declaration element, String annotationName, String memberName, boolean defaultIsNull)
           
static File getWebFilesRoot(File jpfSourceFile, boolean useAlternateLocation, AnnotationProcessorEnvironment env)
           
static boolean hasDefaultConstructor(TypeDeclaration jclass)
           
static boolean hasModifier(Declaration decl, Modifier modifier)
           
static TypeDeclaration inferTypeFromPath(String pathFromWebappRoot, AnnotationProcessorEnvironment env)
           
static boolean isAbsoluteURI(String uri)
          This is the same logic that we have in the runtime, in PageFlowRequestProcessor.
static boolean isAbsoluteURL(String path)
           
static boolean isAssignableFrom(String className, TypeDeclaration cl, AnnotationProcessorEnvironment env)
           
static boolean isAssignableFrom(String className, TypeMirror type, AnnotationProcessorEnvironment env)
           
static boolean isAssignableFrom(TypeDeclaration base, TypeDeclaration typeDecl)
           
static boolean isAssignableFrom(TypeDeclaration base, TypeMirror cl)
           
static boolean isAssignableFrom(TypeMirror base, TypeDeclaration cl)
           
static boolean isJpfAnnotation(AnnotationMirror annotation, String unqualifiedName)
           
static boolean isOfClass(TypeMirror type, String className, AnnotationProcessorEnvironment env)
           
static boolean isPageFlowClass(ClassDeclaration jclass, AnnotationProcessorEnvironment env)
           
static String removeFileExtension(String uri)
           
static boolean typesAreEqual(TypeDeclaration t1, TypeDeclaration t2)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompilerUtils

public CompilerUtils()
Method Detail

isJpfAnnotation

public static boolean isJpfAnnotation(AnnotationMirror annotation,
                                      String unqualifiedName)

getAnnotation

public static AnnotationMirror getAnnotation(Declaration element,
                                             String unqualifiedName)

getAnnotationValue

public static AnnotationValue getAnnotationValue(Declaration element,
                                                 String annotationName,
                                                 String valueName)

getStringValue

public static String getStringValue(Declaration element,
                                    String annotationName,
                                    String memberName,
                                    boolean defaultIsNull)

getAnnotationValue

public static AnnotationValue getAnnotationValue(AnnotationMirror annotation,
                                                 String memberName,
                                                 boolean defaultIsNull)

getStringArrayValue

public static List<String> getStringArrayValue(Declaration element,
                                               String annotationName,
                                               String memberName,
                                               boolean defaultIsNull)

getBooleanValue

public static Boolean getBooleanValue(Declaration element,
                                      String annotationName,
                                      String memberName,
                                      boolean defaultIsNull)

getString

public static String getString(AnnotationMirror annotation,
                               String memberName,
                               boolean defaultIsNull)

getTypeMirror

public static TypeMirror getTypeMirror(AnnotationMirror annotation,
                                       String memberName,
                                       boolean defaultIsNull)

getEnumFieldName

public static String getEnumFieldName(AnnotationMirror annotation,
                                      String memberName,
                                      boolean defaultIsNull)

getStringArray

public static List<String> getStringArray(AnnotationMirror annotation,
                                          String memberName,
                                          boolean defaultIsNull)

getDeclaredType

public static DeclaredType getDeclaredType(AnnotationMirror annotation,
                                           String memberName,
                                           boolean defaultIsNull)

getReferenceType

public static ReferenceType getReferenceType(AnnotationMirror annotation,
                                             String memberName,
                                             boolean defaultIsNull)

getInteger

public static Integer getInteger(AnnotationMirror annotation,
                                 String memberName,
                                 boolean defaultIsNull)

getLong

public static Long getLong(AnnotationMirror annotation,
                           String memberName,
                           boolean defaultIsNull)

getFloat

public static Float getFloat(AnnotationMirror annotation,
                             String memberName,
                             boolean defaultIsNull)

getDouble

public static Double getDouble(AnnotationMirror annotation,
                               String memberName,
                               boolean defaultIsNull)

getBoolean

public static Boolean getBoolean(AnnotationMirror annotation,
                                 String memberName,
                                 boolean defaultIsNull)

getValue

public static Object getValue(Declaration element,
                              String annotationName,
                              String memberName,
                              boolean defaultIsNull)

getAnnotationArrayValue

public static List<AnnotationMirror> getAnnotationArrayValue(Declaration element,
                                                             String annotationName,
                                                             String memberName,
                                                             boolean defaultIsNull)

getAnnotationArray

public static List<AnnotationMirror> getAnnotationArray(AnnotationMirror annotation,
                                                        String memberName,
                                                        boolean defaultIsNull)

getAnnotationArray

public static List<AnnotationMirror> getAnnotationArray(AnnotationValue value)

getQualifiedName

public static String getQualifiedName(AnnotationMirror annotation)

getSimpleName

public static String getSimpleName(AnnotationMirror annotation)

getAnnotation

public static AnnotationMirror getAnnotation(AnnotationMirror annotation,
                                             String memberName,
                                             boolean defaultIsNull)

hasModifier

public static boolean hasModifier(Declaration decl,
                                  Modifier modifier)

getClassMethod

public static MethodDeclaration getClassMethod(TypeDeclaration jclass,
                                               String methodName,
                                               String desiredAnnotation)

getClassField

public static FieldDeclaration getClassField(TypeDeclaration jclass,
                                             String fieldName,
                                             String desiredAnnotation)

getClassMethods

public static Collection<MethodDeclaration> getClassMethods(TypeDeclaration jclass,
                                                            String desiredAnnotation)

getClassFields

public static Collection<FieldDeclaration> getClassFields(TypeDeclaration jclass)

getClassNestedTypes

public static Collection<TypeDeclaration> getClassNestedTypes(TypeDeclaration jclass)

getFormClassName

public static String getFormClassName(TypeDeclaration jclass,
                                      AnnotationProcessorEnvironment env)
Get a Class.forName-able string for the given type signature.


getFormClassName

public static String getFormClassName(DeclaredType jclass,
                                      AnnotationProcessorEnvironment env)

isAbsoluteURL

public static boolean isAbsoluteURL(String path)

isAssignableFrom

public static boolean isAssignableFrom(String className,
                                       TypeMirror type,
                                       AnnotationProcessorEnvironment env)

isAssignableFrom

public static boolean isAssignableFrom(TypeDeclaration base,
                                       TypeDeclaration typeDecl)

isAssignableFrom

public static boolean isAssignableFrom(TypeMirror base,
                                       TypeDeclaration cl)

isAssignableFrom

public static boolean isAssignableFrom(TypeDeclaration base,
                                       TypeMirror cl)

isAssignableFrom

public static boolean isAssignableFrom(String className,
                                       TypeDeclaration cl,
                                       AnnotationProcessorEnvironment env)

isOfClass

public static boolean isOfClass(TypeMirror type,
                                String className,
                                AnnotationProcessorEnvironment env)

typesAreEqual

public static boolean typesAreEqual(TypeDeclaration t1,
                                    TypeDeclaration t2)

getOuterClass

public static TypeDeclaration getOuterClass(MemberDeclaration classMember)

getOutermostClass

public static TypeDeclaration getOutermostClass(MemberDeclaration classMember)

hasDefaultConstructor

public static boolean hasDefaultConstructor(TypeDeclaration jclass)

findField

public static FieldDeclaration findField(TypeDeclaration jclass,
                                         String fieldName)

findInnerClass

public static ClassDeclaration findInnerClass(TypeDeclaration jclass,
                                              String innerClassName)

getEnumFieldName

public static String getEnumFieldName(AnnotationValue enumMember)

getLoadableName

public static String getLoadableName(TypeDeclaration jclass)
Get the qualified name of the given class, with '$' used to separate inner classes; the returned string can be used with Class.forName().


getLoadableName

public static String getLoadableName(DeclaredType jclass)

getOriginalFile

public static File getOriginalFile(TypeDeclaration decl)
Deprecated. 


getSourceFile

public static File getSourceFile(TypeDeclaration decl,
                                 boolean mustBeNonNull)

annotationsAreEqual

public static boolean annotationsAreEqual(AnnotationMirror a1,
                                          AnnotationMirror a2,
                                          boolean allowExactDuplicates,
                                          AnnotationProcessorEnvironment env)

getBeanProperty

public static CompilerUtils.BeanPropertyDeclaration getBeanProperty(MethodDeclaration method)

getBeanProperties

public static Collection<CompilerUtils.BeanPropertyDeclaration> getBeanProperties(ClassDeclaration type,
                                                                                  boolean getInheritedProperties)

isPageFlowClass

public static boolean isPageFlowClass(ClassDeclaration jclass,
                                      AnnotationProcessorEnvironment env)

removeFileExtension

public static String removeFileExtension(String uri)

inferTypeFromPath

public static TypeDeclaration inferTypeFromPath(String pathFromWebappRoot,
                                                AnnotationProcessorEnvironment env)

getDeclaration

public static TypeDeclaration getDeclaration(DeclaredType type)

isAbsoluteURI

public static boolean isAbsoluteURI(String uri)
This is the same logic that we have in the runtime, in PageFlowRequestProcessor. Can't share the code, though.


getArrayBaseType

public static TypeMirror getArrayBaseType(ArrayType arrayType)

getGenericBoundsType

public static TypeMirror getGenericBoundsType(TypeMirror type)

getFileRelativeToSourceFile

public static File getFileRelativeToSourceFile(TypeDeclaration outerClass,
                                               String relativePath,
                                               AnnotationProcessorEnvironment env)

getWebFilesRoot

public static File getWebFilesRoot(File jpfSourceFile,
                                   boolean useAlternateLocation,
                                   AnnotationProcessorEnvironment env)