EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql
Class BasicRefactoringTool

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.AbstractRefactoringTool
      extended by org.eclipse.persistence.jpa.jpql.BasicRefactoringTool
Direct Known Subclasses:
DefaultBasicRefactoringTool, EclipseLinkBasicRefactoringTool

public abstract class BasicRefactoringTool
extends AbstractRefactoringTool

The abstract implementation providing refactoring support for JPQL queries. This version does not changes the org.eclipse.persistence.jpa.jpql.model.query. but rather gather the changes in RefactoringDelta and it is the responsibility of the invoker to the actual change.

Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Version:
2.4
See Also:
DefaultBasicRefactoringTool, EclipseLinkBasicRefactoringTool
Author:
Pascal Filion
Since:
2.4

Nested Class Summary
protected  class BasicRefactoringTool.AbstractRenamer
          The abstract class that all refactoring classes should extend, it automatically provides the MultiTextEdit that will holds the TextEdit objects that are related to the same refactoring event.
protected  class BasicRefactoringTool.ClassNameRenamer
          This visitor renames a fully qualified class name.
protected  class BasicRefactoringTool.EntityNameRenamer
          This visitor renames an entity name.
protected  class BasicRefactoringTool.EnumConstantRenamer
          This visitor renames an enum constant.
protected  class BasicRefactoringTool.FieldNameRenamer
          This visitor renames any segment of a path expression.
protected  class BasicRefactoringTool.ResultVariableNameRenamer
          This visitor renames all the result variables found in the JPQL query.
protected  class BasicRefactoringTool.VariableNameRenamer
          This visitor renames all the identification variables found in the JPQL query.
 
Constructor Summary
protected BasicRefactoringTool(java.lang.CharSequence jpqlQuery, JPQLGrammar jpqlGrammar, IManagedTypeProvider managedTypeProvider)
          Creates a new BasicRefactoringTool.
protected BasicRefactoringTool(java.lang.CharSequence jpqlFragment, JPQLGrammar jpqlGrammar, IManagedTypeProvider managedTypeProvider, java.lang.String jpqlQueryBNFId)
          Creates a new BasicRefactoringTool.
 
Method Summary
protected  BasicRefactoringTool.ClassNameRenamer buildClassNameRenamer(java.lang.String oldClassName, java.lang.String newClassName)
          Creates the visitor that will traverse the representation of the JPQL query and will rename the fully qualified class name.
protected  BasicRefactoringTool.EntityNameRenamer buildEntityNameRenamer(java.lang.String oldEntityName, java.lang.String newEntityName)
          Creates the visitor that will traverse the representation of the JPQL query and will rename the entity name.
protected  BasicRefactoringTool.EnumConstantRenamer buildEnumConstantRenamer(java.lang.String oldClassName, java.lang.String newClassName)
          Creates the visitor that will traverse the representation of the JPQL query and will rename the enum constant.
protected  BasicRefactoringTool.FieldNameRenamer buildFieldNameRenamer(java.lang.String typeName, java.lang.String oldFieldName, java.lang.String newFieldName)
          Creates the visitor that will traverse the representation of the JPQL query and will rename a type's attribute name.
protected abstract  JPQLQueryContext buildJPQLQueryContext()
          Creates a new JPQLQueryContext that can retrieve information from the declaration portion of the JPQL query.
protected  BasicRefactoringTool.ResultVariableNameRenamer buildResultVariableNameRenamer(java.lang.String oldVariableName, java.lang.String newVariableName)
          Creates the visitor that will traverse the representation of the JPQL query and will rename a result variable.
protected  BasicRefactoringTool.VariableNameRenamer buildVariableNameRenamer(java.lang.String oldVariableName, java.lang.String newVariableName)
          Creates the visitor that will traverse the representation of the JPQL query and will rename an identification variable.
 RefactoringDelta getDelta()
          Returns the delta of the changes made to the JPQL query.
 JPQLExpression getExpression()
          Returns the parsed tree representation of the JPQL query.
 JPQLGrammar getGrammar()
          Returns the JPQLGrammar that is associated with this builder.
 JPQLQueryContext getQueryContext()
          Returns the JPQLQueryContext that is used by this visitor.
 boolean hasChanges()
          Determines whether some refactoring operations found changes to be made in the JPQL query.
 void renameClassName(java.lang.String oldClassName, java.lang.String newClassName)
          Renames a fully qualified class name.
 void renameEntityName(java.lang.String oldEntityName, java.lang.String newEntityName)
          Renames a given entity name.
 void renameEnumConstant(java.lang.String oldEnumConstant, java.lang.String newEnumConstant)
          Renames an enum constant, which has to be fully qualified.
 void renameField(java.lang.Class<?> type, java.lang.String oldFieldName, java.lang.String newFieldName)
          Renames a field from the given type.
 void renameField(IType type, java.lang.String oldFieldName, java.lang.String newFieldName)
          Renames a field from the given type.
 void renameField(java.lang.String typeName, java.lang.String oldFieldName, java.lang.String newFieldName)
          Renames a field from the given type.
 void renameResultVariable(java.lang.String oldVariableName, java.lang.String newVariableName)
          Renames a result variable name.
 void renameVariable(java.lang.String oldVariableName, java.lang.String newVariableName)
          Renames a variable name.
 java.lang.String toActualText()
          Returns the resulted of the refactoring operations.
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.AbstractRefactoringTool
getJPQLFragment, getJPQLQueryBNFId, getManagedTypeProvider, isTolerant, setTolerant
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicRefactoringTool

protected BasicRefactoringTool(java.lang.CharSequence jpqlQuery,
                               JPQLGrammar jpqlGrammar,
                               IManagedTypeProvider managedTypeProvider)
Creates a new BasicRefactoringTool.

Parameters:
jpqlQuery - The JPQL query to manipulate
jpqlGrammar - The JPQLGrammar that was used to parse the JPQL query
managedTypeProvider - The external form of a provider that gives access to the JPA metadata

BasicRefactoringTool

protected BasicRefactoringTool(java.lang.CharSequence jpqlFragment,
                               JPQLGrammar jpqlGrammar,
                               IManagedTypeProvider managedTypeProvider,
                               java.lang.String jpqlQueryBNFId)
Creates a new BasicRefactoringTool.

Parameters:
jpqlFragment - The JPQL query to manipulate or a single JPQL fragment, which is parsed using the JPQL query BNF identifier by the given ID
jpqlGrammar - The JPQLGrammar that was used to parse the JPQL fragment
managedTypeProvider - The external form of a provider that gives access to the JPA metadata
jpqlQueryBNFId - The unique identifier of the parser.JPQLQueryBNF JPQLQueryBNF that determines how to parse the JPQL fragment
Method Detail

buildClassNameRenamer

protected BasicRefactoringTool.ClassNameRenamer buildClassNameRenamer(java.lang.String oldClassName,
                                                                      java.lang.String newClassName)
Creates the visitor that will traverse the representation of the JPQL query and will rename the fully qualified class name.

Parameters:
oldClassName - The current name of the class to rename
newClassName - The new name of the class
Returns:
A new BasicRefactoringTool.ClassNameRenamer

buildEntityNameRenamer

protected BasicRefactoringTool.EntityNameRenamer buildEntityNameRenamer(java.lang.String oldEntityName,
                                                                        java.lang.String newEntityName)
Creates the visitor that will traverse the representation of the JPQL query and will rename the entity name.

Parameters:
oldEntityName - The current name of the entity to rename
newEntityName - The new name of the entity
Returns:
A new BasicRefactoringTool.EntityNameRenamer

buildEnumConstantRenamer

protected BasicRefactoringTool.EnumConstantRenamer buildEnumConstantRenamer(java.lang.String oldClassName,
                                                                            java.lang.String newClassName)
Creates the visitor that will traverse the representation of the JPQL query and will rename the enum constant.

Parameters:
oldClassName - The new name of the enum constant
newClassName - The current name of the enum constant to rename
Returns:
A new BasicRefactoringTool.EnumConstantRenamer

buildFieldNameRenamer

protected BasicRefactoringTool.FieldNameRenamer buildFieldNameRenamer(java.lang.String typeName,
                                                                      java.lang.String oldFieldName,
                                                                      java.lang.String newFieldName)
Creates the visitor that will traverse the representation of the JPQL query and will rename a type's attribute name.

Parameters:
typeName - The fully qualified name of the type that got one of its attributes renamed
oldFieldName - The current name of the attribute to rename
newFieldName - The new name of the attribute
Returns:
A new BasicRefactoringTool.FieldNameRenamer

buildJPQLQueryContext

protected abstract JPQLQueryContext buildJPQLQueryContext()
Creates a new JPQLQueryContext that can retrieve information from the declaration portion of the JPQL query.

Returns:
A new concrete instance of JPQLQueryContext

buildResultVariableNameRenamer

protected BasicRefactoringTool.ResultVariableNameRenamer buildResultVariableNameRenamer(java.lang.String oldVariableName,
                                                                                        java.lang.String newVariableName)
Creates the visitor that will traverse the representation of the JPQL query and will rename a result variable.

Parameters:
oldVariableName - The current result variable name
newVariableName - The new name of the result variable
Returns:
A new BasicRefactoringTool.ResultVariableNameRenamer

buildVariableNameRenamer

protected BasicRefactoringTool.VariableNameRenamer buildVariableNameRenamer(java.lang.String oldVariableName,
                                                                            java.lang.String newVariableName)
Creates the visitor that will traverse the representation of the JPQL query and will rename an identification variable.

Parameters:
oldVariableName - The current identification variable name
newVariableName - The new name of the identification variable
Returns:
A new BasicRefactoringTool.ResultVariableNameRenamer

getDelta

public RefactoringDelta getDelta()
Returns the delta of the changes made to the JPQL query.

Returns:
An object containing the refactoring events

getExpression

public JPQLExpression getExpression()
Returns the parsed tree representation of the JPQL query.

Returns:
The root of the parsed tree

getGrammar

public JPQLGrammar getGrammar()
Returns the JPQLGrammar that is associated with this builder.

Returns:
The JPQLGrammar that was used to parse the JPQL query or JPQL fragments

getQueryContext

public JPQLQueryContext getQueryContext()
Returns the JPQLQueryContext that is used by this visitor.

Returns:
The JPQLQueryContext holding onto the JPQL query and the cached information

hasChanges

public boolean hasChanges()
Determines whether some refactoring operations found changes to be made in the JPQL query.

Returns:
true if there is at least one TextEdit; false otherwise

renameClassName

public void renameClassName(java.lang.String oldClassName,
                            java.lang.String newClassName)
Renames a fully qualified class name.

Parameters:
oldClassName - The current fully qualified class name of the class to rename
newClassName - The new fully qualified class name

renameEntityName

public void renameEntityName(java.lang.String oldEntityName,
                             java.lang.String newEntityName)
Renames a given entity name.

Parameters:
oldEntityName - The current name of the entity to rename
newEntityName - The new name of the entity

renameEnumConstant

public void renameEnumConstant(java.lang.String oldEnumConstant,
                               java.lang.String newEnumConstant)
Renames an enum constant, which has to be fully qualified.

Parameters:
oldEnumConstant - The current fully qualified name of the enum constant to rename
newEnumConstant - The new fully qualified name of the enum constant

renameField

public void renameField(java.lang.Class<?> type,
                        java.lang.String oldFieldName,
                        java.lang.String newFieldName)
Renames a field from the given type.

Parameters:
type - The Java class from which the change originate
oldFieldName - The current name of the attribute to rename
newFieldName - The new name of the attribute

renameField

public void renameField(IType type,
                        java.lang.String oldFieldName,
                        java.lang.String newFieldName)
Renames a field from the given type.

Parameters:
type - The IType from which the change originate
oldFieldName - The current name of the attribute to rename
newFieldName - The new name of the attribute

renameField

public void renameField(java.lang.String typeName,
                        java.lang.String oldFieldName,
                        java.lang.String newFieldName)
Renames a field from the given type.

Parameters:
typeName - The fully qualified name of the type that got one of its attributes renamed
oldFieldName - The current name of the attribute to rename
newFieldName - The new name of the attribute

renameResultVariable

public void renameResultVariable(java.lang.String oldVariableName,
                                 java.lang.String newVariableName)
Renames a result variable name.

Parameters:
oldVariableName - The current identification variable name
newVariableName - The new name of the identification variable

renameVariable

public void renameVariable(java.lang.String oldVariableName,
                           java.lang.String newVariableName)
Renames a variable name.

Parameters:
oldVariableName - The current identification variable name
newVariableName - The new name of the identification variable

toActualText

public java.lang.String toActualText()
Returns the resulted of the refactoring operations. The list of changes will be removed after applying the changes.

Specified by:
toActualText in class AbstractRefactoringTool
Returns:
The string representation of the JPQL query that contains the changes

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference