org.springframework.roo.classpath
Interface TypeParsingService


public interface TypeParsingService


Method Summary
 String getCompilationUnitContents(ClassOrInterfaceTypeDetails cid)
          Returns the compilation unit contents that represents the passed class or interface details.
 ClassOrInterfaceTypeDetails getTypeAtLocation(String fileIdentifier, String declaredByMetadataId, org.springframework.roo.model.JavaType javaType)
          Builds a ClassOrInterfaceTypeDetails object that represents the requested JavaType from the type at the passed in type path.
 ClassOrInterfaceTypeDetails getTypeFromString(String typeContents, String declaredByMetadataId, org.springframework.roo.model.JavaType javaType)
          Builds a ClassOrInterfaceTypeDetails object that represents the requested JavaType from the passed compilation unit text.
 String updateAndGetCompilationUnitContents(String fileIdentifier, ClassOrInterfaceTypeDetails cid)
          Returns the compilation unit contents that represents the java file updated with the passed class or interface details.
 

Method Detail

getCompilationUnitContents

String getCompilationUnitContents(ClassOrInterfaceTypeDetails cid)
Returns the compilation unit contents that represents the passed class or interface details. This is useful if an add-on requires a compilation unit representation but doesn't wish to cause that representation to be emitted to disk via TypeManagementService. One concrete time this is useful is when an add-on wishes to emulate an ITD-like model for an external system that cannot support ITDs and may wish to insert a custom header etc before writing it to disk.

Parameters:
cid - a parsed representation of a class or interface (required)
Returns:
a valid Java compilation unit for the passed object (never null or empty)

getTypeAtLocation

ClassOrInterfaceTypeDetails getTypeAtLocation(String fileIdentifier,
                                              String declaredByMetadataId,
                                              org.springframework.roo.model.JavaType javaType)
Builds a ClassOrInterfaceTypeDetails object that represents the requested JavaType from the type at the passed in type path.

Parameters:
fileIdentifier - the location of the type to be parsed (required)
declaredByMetadataId - the metadata ID that should be used in the returned object (required)
javaType - the Java type to locate in the compilation unit and parse (required)
Returns:
a parsed representation of the requested type from the passed compilation unit (never null)

getTypeFromString

ClassOrInterfaceTypeDetails getTypeFromString(String typeContents,
                                              String declaredByMetadataId,
                                              org.springframework.roo.model.JavaType javaType)
Builds a ClassOrInterfaceTypeDetails object that represents the requested JavaType from the passed compilation unit text. This is useful if an add-on wishes to parse some arbitrary compilation unit contents it acquired from outside the user project, such as a template that ships with the add-on. The add-on can subsequently modify the returned object (via the builder) and eventually write the final version to the user's project. This therefore allows more elegant add-on usage patterns, as they need not write "stub" compilation units into a user project simply to parse them for subsequent re-writing.

Parameters:
typeContents - the text of a legal Java compilation unit (required)
declaredByMetadataId - the metadata ID that should be used in the returned object (required)
javaType - the Java type to locate in the compilation unit and parse (required)
Returns:
a parsed representation of the requested type from the passed compilation unit (never null)

updateAndGetCompilationUnitContents

String updateAndGetCompilationUnitContents(String fileIdentifier,
                                           ClassOrInterfaceTypeDetails cid)
Returns the compilation unit contents that represents the java file updated with the passed class or interface details. The difference with getCompilationUnitContents(ClassOrInterfaceTypeDetails) is that this method doesn't create a new compilation unit but tries to update the original return the final file contents.

Parameters:
fileIdentifier - canonical path of file
cid - a parsed representation of a class or interface (required)
Returns:
a valid Java compilation unit contents (never null or empty)


Copyright © 2009–2015. All rights reserved.