org.springframework.roo.model
Class ImportRegistrationResolverImpl

java.lang.Object
  extended by org.springframework.roo.model.ImportRegistrationResolverImpl
All Implemented Interfaces:
ImportRegistrationResolver

public class ImportRegistrationResolverImpl
extends Object
implements ImportRegistrationResolver


Constructor Summary
ImportRegistrationResolverImpl(JavaPackage compilationUnitPackage)
           
 
Method Summary
 void addImport(JavaType javaType)
          Explicitly registers an import.
 JavaPackage getCompilationUnitPackage()
           
 Set<JavaType> getRegisteredImports()
          Provides access to the registered imports.
 boolean isAdditionLegal(JavaType javaType)
          Indicates whether the presented JavaType can be legally presented to ImportRegistrationResolver.addImport(JavaType).
 boolean isFullyQualifiedFormRequired(JavaType javaType)
          Determines whether the presented JavaType must be used in a fully-qualified form or not.
 boolean isFullyQualifiedFormRequiredAfterAutoImport(JavaType javaType)
          Automatically invokes ImportRegistrationResolver.isAdditionLegal(JavaType), then ImportRegistrationResolver.addImport(JavaType), and finally ImportRegistrationResolver.isFullyQualifiedFormRequired(JavaType), returning the result of the final method.
static boolean isPartOfJavaLang(String simpleTypeName)
          Determines whether the presented simple type name is part of java.lang or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportRegistrationResolverImpl

public ImportRegistrationResolverImpl(JavaPackage compilationUnitPackage)
Method Detail

addImport

public void addImport(JavaType javaType)
Description copied from interface: ImportRegistrationResolver
Explicitly registers an import. Note that no verification will be performed to ensure an import is legal or does not conflict with an existing import (use ImportRegistrationResolver.isAdditionLegal(JavaType) for verification).

Specified by:
addImport in interface ImportRegistrationResolver
Parameters:
javaType - to register (required)

getCompilationUnitPackage

public JavaPackage getCompilationUnitPackage()
Specified by:
getCompilationUnitPackage in interface ImportRegistrationResolver
Returns:
the package this compilation unit belongs to (never null)

getRegisteredImports

public Set<JavaType> getRegisteredImports()
Description copied from interface: ImportRegistrationResolver
Provides access to the registered imports.

Specified by:
getRegisteredImports in interface ImportRegistrationResolver
Returns:
an unmodifiable representation of all registered imports (never null, but may be empty)

isAdditionLegal

public boolean isAdditionLegal(JavaType javaType)
Description copied from interface: ImportRegistrationResolver
Indicates whether the presented JavaType can be legally presented to ImportRegistrationResolver.addImport(JavaType). It is considered legal only if the presented JavaType is of type DataType.TYPE, there is not an existing conflicting registered import, and the proposed type is not within the default package. Note it is legal to add types from the same package as the compilation unit, and indeed may be required by implementations that are otherwise unaware of all the types available in a particular package.

Specified by:
isAdditionLegal in interface ImportRegistrationResolver
Returns:

isFullyQualifiedFormRequired

public boolean isFullyQualifiedFormRequired(JavaType javaType)
Description copied from interface: ImportRegistrationResolver
Determines whether the presented JavaType must be used in a fully-qualified form or not. It may only be used in simple form if:

Note that advanced implementations may be able to determine all types available in a particular package, but this is not required.

Specified by:
isFullyQualifiedFormRequired in interface ImportRegistrationResolver
Parameters:
javaType - to lookup (required)
Returns:
true if a fully-qualified form must be used, or false if a simple form can be used

isFullyQualifiedFormRequiredAfterAutoImport

public boolean isFullyQualifiedFormRequiredAfterAutoImport(JavaType javaType)
Description copied from interface: ImportRegistrationResolver
Automatically invokes ImportRegistrationResolver.isAdditionLegal(JavaType), then ImportRegistrationResolver.addImport(JavaType), and finally ImportRegistrationResolver.isFullyQualifiedFormRequired(JavaType), returning the result of the final method. This method is the main method that should be used by callers, as it will automatically attempt to cause a JavaType to be used in its simple form if at all possible.

Specified by:
isFullyQualifiedFormRequiredAfterAutoImport in interface ImportRegistrationResolver
Parameters:
javaType - to automatically register (if possible) and lookup whether simplified used is available (required)
Returns:
true if a fully-qualified form must be used, or false if a simple form can be used

isPartOfJavaLang

public static boolean isPartOfJavaLang(String simpleTypeName)
Determines whether the presented simple type name is part of java.lang or not.

Parameters:
simpleTypeName - the simple type name (required)
Returns:
whether the type is declared as part of java.lang


Copyright © 2009-2010 VMware, Inc. All Rights Reserved.