org.springframework.roo.model
Interface ImportRegistrationResolver

All Known Implementing Classes:
ImportRegistrationResolverImpl

public interface ImportRegistrationResolver

Represents the known imports for a particular compilation unit, and resolves whether a particular type name can be expressed as a simple type name or requires a fully-qualified type name.

Since:
1.0
Author:
Ben Alex

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 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 isAdditionLegal(JavaType), then addImport(JavaType), and finally isFullyQualifiedFormRequired(JavaType), returning the result of the final method.
 

Method Detail

getCompilationUnitPackage

JavaPackage getCompilationUnitPackage()
Returns:
the package this compilation unit belongs to (never null)

isFullyQualifiedFormRequired

boolean isFullyQualifiedFormRequired(JavaType javaType)
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.

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

boolean isFullyQualifiedFormRequiredAfterAutoImport(JavaType javaType)
Automatically invokes isAdditionLegal(JavaType), then addImport(JavaType), and finally 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.

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

isAdditionLegal

boolean isAdditionLegal(JavaType javaType)
Indicates whether the presented JavaType can be legally presented to 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.

Parameters:
javaType -
Returns:

addImport

void addImport(JavaType javaType)
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 isAdditionLegal(JavaType) for verification).

Parameters:
javaType - to register (required)

getRegisteredImports

Set<JavaType> getRegisteredImports()
Provides access to the registered imports.

Returns:
an unmodifiable representation of all registered imports (never null, but may be empty)


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