-
Version:
-
See Also:
-
DefaultRefactoringTool
,
EclipseLinkRefactoringTool
-
Author:
-
Pascal Filion
-
Since:
protected
RefactoringTool
(
IManagedTypeProvider
managedTypeProvider,
IJPQLQueryBuilder
jpqlQueryBuilder,
java.lang.CharSequence jpqlQuery)
Creates a new
RefactoringTool
.
protected
RefactoringTool
(
IManagedTypeProvider
managedTypeProvider,
IJPQLQueryBuilder
jpqlQueryBuilder,
java.lang.CharSequence jpqlFragment,
java.lang.String jpqlQueryBNFId)
Creates a new
RefactoringTool
.
protected
RefactoringTool.ClassNameRenamer
buildClassNameRenamer
(java.lang.String oldClassName,
java.lang.String newClassName)
Creates the visitor that will traverse the
StateObject
representation of the JPQL
query and will rename the fully qualified class name.
protected
RefactoringTool.EntityNameRenamer
buildEntityNameRenamer
(java.lang.String oldEntityName,
java.lang.String newEntityName)
Creates the visitor that will traverse the
StateObject
representation of the JPQL
query and will rename the entity name.
protected
RefactoringTool.EnumConstantRenamer
buildEnumConstantRenamer
(java.lang.String oldClassName,
java.lang.String newClassName)
Creates the visitor that will traverse the
StateObject
representation of the JPQL
query and will rename the enum constant.
protected
RefactoringTool.FieldNameRenamer
buildFieldNameRenamer
(java.lang.String typeName,
java.lang.String oldFieldName,
java.lang.String newFieldName)
Creates the visitor that will traverse the
StateObject
representation of the JPQL
query and will rename a type's attribute name.
protected abstract
IJPQLQueryFormatter
buildFormatter
()
Creates a new formatter that will convert the
StateObject
representation of the JPQL
query, once the refactoring occurred into a string.
protected abstract
JPQLQueryContext
buildJPQLQueryContext
()
Creates a new
JPQLQueryContext
that can retrieve information from the declaration
portion of the JPQL query.
protected
RefactoringTool.ResultVariableNameRenamer
buildResultVariableNameRenamer
(java.lang.String oldVariableName,
java.lang.String newVariableName)
Creates the visitor that will traverse the
StateObject
representation of the JPQL
query and will rename a result variable.
protected
JPQLQueryStateObject
buildStateObject
()
Creates the
StateObject
representation of the JPQL fragment to manipulate.
protected
RefactoringTool.VariableNameRenamer
buildVariableNameRenamer
(java.lang.String oldVariableName,
java.lang.String newVariableName)
Creates the visitor that will traverse the
StateObject
representation of the JPQL
query and will rename an identification variable.
IJPQLQueryFormatter
getFormatter
()
Returns the
IJPQLQueryFormatter
that creates an accurate representation of the
StateObject
, i.e. that output the JPQL query with the case used for the JPQL identifier.
JPQLGrammar
getGrammar
()
Returns the
JPQLGrammar
that is associated with this builder.
IJPQLQueryBuilder
getJPQLQueryBuilder
()
Returns the builder that creates the
StateObject
representation of the JPQL query.
JPQLQueryStateObject
getStateObject
()
Returns the
StateObject
representation of the JPQL query or JPQL fragment that was parsed.
renameClassName
(java.lang.String oldClassName,
java.lang.String newClassName)
Renames a fully qualified class name.
renameEntityName
(java.lang.String oldEntityName,
java.lang.String newEntityName)
Renames a given entity name.
renameEnumConstant
(java.lang.String oldEnumConstant,
java.lang.String newEnumConstant)
Renames an enum constant, which has to be fully qualified.
renameField
(java.lang.Class<?> type,
java.lang.String oldFieldName,
java.lang.String newFieldName)
Renames a field from the given type.
renameField
(
IType
type,
java.lang.String oldFieldName,
java.lang.String newFieldName)
Renames a field from the given type.
renameField
(java.lang.String typeName,
java.lang.String oldFieldName,
java.lang.String newFieldName)
Renames a field from the given type.
renameResultVariable
(java.lang.String oldVariableName,
java.lang.String newVariableName)
Renames a result variable name.
renameVariable
(java.lang.String oldVariableName,
java.lang.String newVariableName)
Renames a variable name.
setFormatter
(
IJPQLQueryFormatter
jpqlQueryFormatter)
Sets the
IJPQLQueryFormatter
that creates an accurate representation of the
StateObject
, i.e. that output the JPQL query with the case used for the JPQL identifier.
java.lang.String
toActualText
()
Returns the resulted of the refactoring operations.
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.
AbstractRefactoringTool
getJPQLFragment
,
getJPQLQueryBNFId
,
getManagedTypeProvider
,
isTolerant
,
setTolerant
RefactoringTool
protected RefactoringTool(IManagedTypeProvider managedTypeProvider,
IJPQLQueryBuilder jpqlQueryBuilder,
java.lang.CharSequence jpqlQuery)
Creates a new
RefactoringTool
.
-
Parameters:
-
managedTypeProvider
- The external form of a provider that gives access to the JPA metadata
-
jpqlQueryBuilder
- The builder that creates the
StateObject
representation of the
JPQL query
-
jpqlQuery
- The JPQL query to manipulate
RefactoringTool
protected RefactoringTool(IManagedTypeProvider managedTypeProvider,
IJPQLQueryBuilder jpqlQueryBuilder,
java.lang.CharSequence jpqlFragment,
java.lang.String jpqlQueryBNFId)
Creates a new
RefactoringTool
.
-
Parameters:
-
managedTypeProvider
- The external form of a provider that gives access to the JPA metadata
-
jpqlQueryBuilder
- The builder that creates the
StateObject
representation of the
JPQL query
-
jpqlFragment
- The JPQL query to manipulate or a single JPQL fragment, which is parsed
using the JPQL query BNF identifier by the given ID
-
jpqlQueryBNFId
- The unique identifier of the
parser.JPQLQueryBNF JPQLQueryBNF
that determines how to parse the JPQL fragment
buildClassNameRenamer
protected RefactoringTool.ClassNameRenamer buildClassNameRenamer(java.lang.String oldClassName,
java.lang.String newClassName)
Creates the visitor that will traverse the
StateObject
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
RefactoringTool.ClassNameRenamer
buildEntityNameRenamer
protected RefactoringTool.EntityNameRenamer buildEntityNameRenamer(java.lang.String oldEntityName,
java.lang.String newEntityName)
Creates the visitor that will traverse the
StateObject
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
RefactoringTool.EntityNameRenamer
buildEnumConstantRenamer
protected RefactoringTool.EnumConstantRenamer buildEnumConstantRenamer(java.lang.String oldClassName,
java.lang.String newClassName)
Creates the visitor that will traverse the
StateObject
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
RefactoringTool.EnumConstantRenamer
buildFieldNameRenamer
protected RefactoringTool.FieldNameRenamer buildFieldNameRenamer(java.lang.String typeName,
java.lang.String oldFieldName,
java.lang.String newFieldName)
Creates the visitor that will traverse the
StateObject
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
AttributeNameRenamer
buildFormatter
protected abstract IJPQLQueryFormatter buildFormatter()
Creates a new formatter that will convert the
StateObject
representation of the JPQL
query, once the refactoring occurred into a string.
-
Returns:
-
A new concrete instance of
IJPQLQueryFormatter
buildJPQLQueryContext
protected abstract JPQLQueryContext buildJPQLQueryContext()
Creates a new
JPQLQueryContext
that can retrieve information from the declaration
portion of the JPQL query.
NOTE:
This is temporary because the
StateObject
API does not have that
knowledge yet.
-
Returns:
-
A new concrete instance of
JPQLQueryContext
buildResultVariableNameRenamer
protected RefactoringTool.ResultVariableNameRenamer buildResultVariableNameRenamer(java.lang.String oldVariableName,
java.lang.String newVariableName)
Creates the visitor that will traverse the
StateObject
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
RefactoringTool.ResultVariableNameRenamer
buildStateObject
protected JPQLQueryStateObject buildStateObject()
Creates the
StateObject
representation of the JPQL fragment to manipulate.
-
Returns:
-
The parsed and editable JPQL query
-
See Also:
-
getStateObject()
buildVariableNameRenamer
protected RefactoringTool.VariableNameRenamer buildVariableNameRenamer(java.lang.String oldVariableName,
java.lang.String newVariableName)
Creates the visitor that will traverse the
StateObject
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
RefactoringTool.VariableNameRenamer
getFormatter
public IJPQLQueryFormatter getFormatter()
Returns the
IJPQLQueryFormatter
that creates an accurate representation of the
StateObject
, i.e. that output the JPQL query with the case used for the JPQL identifier.
-
Returns:
-
An instance of
IJPQLQueryFormatter
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
getJPQLQueryBuilder
public IJPQLQueryBuilder getJPQLQueryBuilder()
Returns the builder that creates the
StateObject
representation of the JPQL query.
-
Returns:
-
The builder of the
StateObject
to be manipulated
getStateObject
public JPQLQueryStateObject getStateObject()
Returns the
StateObject
representation of the JPQL query or JPQL fragment that was parsed.
-
Returns:
-
The editable state model
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
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
setFormatter
public void setFormatter(IJPQLQueryFormatter jpqlQueryFormatter)
Sets the
IJPQLQueryFormatter
that creates an accurate representation of the
StateObject
, i.e. that output the JPQL query with the case used for the JPQL identifier.
-
Parameters:
-
jpqlQueryFormatter
- This formatter converts a
StateObject
representation of the
JPQL query into a string representation
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