Class DefaultContentAssistProposals
- All Implemented Interfaces:
ContentAssistProposals
ContentAssistProposals which stores the valid proposals.
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.
- Since:
- 2.3
- Version:
- 2.5
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.persistence.jpa.jpql.tools.ContentAssistProposals
ContentAssistProposals.ClassType, ContentAssistProposals.EnumProposals -
Constructor Summary
ConstructorsConstructorDescriptionDefaultContentAssistProposals(JPQLGrammar jpqlGrammar, ContentAssistExtension extension) Creates a newDefaultContentAssistProposals. -
Method Summary
Modifier and TypeMethodDescriptionReturns the collection of possible abstract schema types.voidAdds the givenIEntityas a possible abstract schema type.voidaddEnumConstant(IType enumType, String enumConstant) Adds the constants of the given enum constant as a valid proposal.voidaddIdentificationVariable(String identificationVariable) Adds the given identification variable as a proposal.voidaddIdentifier(String identifier) Adds the given JPQL identifier as a proposal.voidaddMapping(IMapping mapping) Adds the givenmapping(state field, association field or collection field) as a valid proposal.voidaddMappings(Collection<IMapping> mappings) Adds the givenmappings(state fields, association fields or collection fields) as valid proposals.voidaddRangeIdentificationVariable(String identificationVariable, IEntity entity) Adds the given range identification variable that is mapping the given abstract schema type.org.eclipse.persistence.jpa.jpql.tools.DefaultContentAssistProposals.ResultbuildEscapedQuery(String jpqlQuery, String proposal, int position, boolean insert) Creates a new JPQL query by inserting the given proposal at the given position.int[]buildPositions(WordParser wordParser, String proposal, boolean insert) Calculates the start and end position for correctly inserting the proposal into the query.org.eclipse.persistence.jpa.jpql.tools.DefaultContentAssistProposals.ResultbuildQuery(String jpqlQuery, String proposal, int position, boolean insert) Creates a new JPQL query by inserting the given proposal at the given position.buildXmlQuery(String jpqlQuery, String proposal, int position, boolean insert) Creates a new JPQL query by inserting the given proposal at the given position.Returns the filtered list of possible class names.Returns the filtered list of possible column names.Returns the filtered list of possible enum constant names.getAbstractSchemaType(String identificationVariable) Retrieves the abstract schema type that is mapped with the given identification variable.Returns the prefix that will be used to filter the list of possible class names.Returns the prefix that will be used byContentAssistExtensionto filter the column names if the table name is notnull.Returns theJPQLGrammarthat defines how the JPQL query was parsed.getIdentifierRole(String identifier) Returns the role of the given JPQL identifier.Returns the table name that will be used byContentAssistExtensionto retrieve the column names.Returns the prefix that will be used to filter the list of possible table names.booleanDetermines whether there is at least one proposals.Returns the collection of possible identification variables.Returns the collection of possible JPQL identifiers.protected voidinitialize(JPQLGrammar jpqlGrammar, ContentAssistExtension extension) booleanisColumnName(String proposal) Determines whether the given proposal is a column name (which should be unqualified).booleanisEnumConstant(String proposal) Determines whether the given proposal is an enum constant name (which should be unqualified).booleanisMappingName(String proposal) Determines whether the given proposal is a mapping name.longuestIdentifier(String proposal) Returns the longest possible JPQL identifier that is related to the given proposal if the proposal is a JPQL identifier and contains multiple words.mappings()Returns the collection of possiblemappings, which can be state fields, association fields and/or collection fields depending on the location used to retrieve the possible proposals.protected voidremoveIdentifier(String identifier) Removes the given JPQL identifier.voidsetClassNamePrefix(String prefix, ContentAssistProposals.ClassType classType) Adds the given prefix that will be used to filter the list of possible class names.voidsetTableName(String tableName, String prefix) Sets the table name and a prefix that will be used to filter the names of the table's columns.voidsetTableNamePrefix(String tableNamePrefix) Adds the given prefix that will be used to filter the list of possible columns names.intstartPosition(WordParser wordParser, String proposal) Returns the filtered list of possible table names.toString()
-
Constructor Details
-
DefaultContentAssistProposals
Creates a newDefaultContentAssistProposals.- Parameters:
jpqlGrammar- TheJPQLGrammarthat defines how the JPQL query was parsedextension- This extension can be used to provide additional support to JPQL content assist that is outside the scope of providing proposals related to JPA metadata. It adds support for providing suggestions related to class names, enum constants, table names, column names
-
-
Method Details
-
abstractSchemaTypes
Description copied from interface:ContentAssistProposalsReturns the collection of possible abstract schema types.- Specified by:
abstractSchemaTypesin interfaceContentAssistProposals- Returns:
- The
entitiesdefined in the persistence context
-
addEntity
Adds the givenIEntityas a possible abstract schema type.- Parameters:
abstractSchemaType- The abstract schema type that is a valid proposal
-
addEnumConstant
Adds the constants of the given enum constant as a valid proposal.- Parameters:
enumType- TheITypeof the enum typeenumConstant- The enum constant to be added as a valid proposal- Since:
- 2.5
-
addIdentificationVariable
Adds the given identification variable as a proposal.- Parameters:
identificationVariable- The identification variable that is a valid proposal
-
addIdentifier
Adds the given JPQL identifier as a proposal.- Parameters:
identifier- The JPQL identifier that is a valid proposal
-
addMapping
Adds the givenmapping(state field, association field or collection field) as a valid proposal.- Parameters:
mapping- TheIMappingof the state field, association field or collection field
-
addMappings
Adds the givenmappings(state fields, association fields or collection fields) as valid proposals.- Parameters:
mappings- Themappingsof the state fields, association fields or collection fields
-
addRangeIdentificationVariable
Adds the given range identification variable that is mapping the given abstract schema type.- Parameters:
identificationVariable- The range identification variable mapping the abstract schema nameentity- The abstract type name that identifies the type of the variable
-
buildEscapedQuery
public org.eclipse.persistence.jpa.jpql.tools.DefaultContentAssistProposals.Result buildEscapedQuery(String jpqlQuery, String proposal, int position, boolean insert) Description copied from interface:ContentAssistProposalsCreates a new JPQL query by inserting the given proposal at the given position. The updated JPQL query and position will be adjusted by converting some characters into their corresponding escaped characters, for instance '\r' will be converted to '\\r.The replacement will also handle compound JPQL identifiers when updating the JPQL query.
Example: If the cursor is within "IS NOT N|" and the proposal is "IS NOT NULL", then "IS NOT" will not be added twice. If the word to replace is "IS NULL" and the proposal is "IS NOT NULL", then "NOT" will be inserted between "IS" and "NULL".
- Specified by:
buildEscapedQueryin interfaceContentAssistProposals- Parameters:
jpqlQuery- The JPQL query to modify with the given proposalproposal- The proposal to insert into the queryposition- The position of insertioninsert- Flag that determines if the partial word following the cursor should be left intact or should be replaced by the proposal- Returns:
- The result of inserting the proposal into the query, including the adjust position, if it was required
-
buildPositions
Calculates the start and end position for correctly inserting the proposal into the query.- Parameters:
wordParser- This parser can be used to retrieve words from the cursor positionproposal- The proposal to be inserted into the queryinsert- Flag that determines if the proposal is simply inserted or it should also replace the partial word following the position of the cursor- Returns:
- The start and end positions
-
buildQuery
public org.eclipse.persistence.jpa.jpql.tools.DefaultContentAssistProposals.Result buildQuery(String jpqlQuery, String proposal, int position, boolean insert) Description copied from interface:ContentAssistProposalsCreates a new JPQL query by inserting the given proposal at the given position.The replacement will also handle compound JPQL identifiers when updating the JPQL query.
Example: If the cursor is within "IS NOT N|" and the proposal is "IS NOT NULL", then "IS NOT" will not be added twice. If the word to replace is "IS NULL" and the proposal is "IS NOT NULL", then "NOT" will be inserted between "IS" and "NULL".
- Specified by:
buildQueryin interfaceContentAssistProposals- Parameters:
jpqlQuery- The JPQL query to modify with the given proposalproposal- The proposal to insert into the queryposition- The position of insertioninsert- Flag that determines if the partial word following the cursor should be left intact or should be replaced by the proposal- Returns:
- The result of inserting the proposal into the query, including the adjust position, if it was required
-
buildXmlQuery
Description copied from interface:ContentAssistProposalsCreates a new JPQL query by inserting the given proposal at the given position. The updated JPQL query and position will be adjusted by converting some characters into their corresponding escaped characters, for instance '>' will be converted to '>'.The replacement will also handle compound JPQL identifiers when updating the JPQL query.
Example: If the cursor is within "IS NOT N|" and the proposal is "IS NOT NULL", then "IS NOT" will not be added twice. If the word to replace is "IS NULL" and the proposal is "IS NOT NULL", then "NOT" will be inserted between "IS" and "NULL".
- Specified by:
buildXmlQueryin interfaceContentAssistProposals- Parameters:
jpqlQuery- The JPQL query to modify with the given proposal, which should be the non- converted string, i.e. any escaped characters should not be convertedproposal- The proposal to insert into the queryposition- The position of insertion, which was derived from the parsed tree representation of the JPQL queryinsert- Flag that determines if the partial word following the cursor should be left intact or should be replaced by the proposal- Returns:
- The result of inserting the proposal into the query, including the adjust position, if it was required
-
classNames
Description copied from interface:ContentAssistProposalsReturns the filtered list of possible class names. This is usually available when the cursor is within the constructor name of the constructor expression.- Specified by:
classNamesin interfaceContentAssistProposals- Returns:
- The filtered list of possible class names
- See Also:
-
columnNames
Description copied from interface:ContentAssistProposalsReturns the filtered list of possible column names.- Specified by:
columnNamesin interfaceContentAssistProposals- Returns:
- The filtered list of possible column names
-
enumConstant
Description copied from interface:ContentAssistProposalsReturns the filtered list of possible enum constant names. This is usually available when the cursor is after the dot separating a fully qualified enum type and the enum constant.- Specified by:
enumConstantin interfaceContentAssistProposals- Returns:
- The filtered list of possible enum constant names associated with its enum type
-
getAbstractSchemaType
Description copied from interface:ContentAssistProposalsRetrieves the abstract schema type that is mapped with the given identification variable.- Specified by:
getAbstractSchemaTypein interfaceContentAssistProposals- Parameters:
identificationVariable- The identification variable that, if defined as a range variable, will be mapped to a managed type- Returns:
- The abstract schema type mapped with the given identification variable or
nullif the given variable is mapped to something else or not mapped to anything
-
getClassNamePrefix
Returns the prefix that will be used to filter the list of possible class names.- Returns:
- The prefix that is used to filter the list of class names or
nullif it was not set for the cursor position within the JPQL query - Since:
- 2.5
-
getClassType
- Specified by:
getClassTypein interfaceContentAssistProposals
-
getColumnNamePrefix
Returns the prefix that will be used byContentAssistExtensionto filter the column names if the table name is notnull.- Returns:
- The prefix that is used to filter the list of columns names, which is
nullif it has not been set along with the table name - Since:
- 2.5
-
getGrammar
Returns theJPQLGrammarthat defines how the JPQL query was parsed.- Returns:
- The
JPQLGrammarthat was used to parse thisExpression
-
getIdentifierRole
Description copied from interface:ContentAssistProposalsReturns the role of the given JPQL identifier.- Specified by:
getIdentifierRolein interfaceContentAssistProposals- Parameters:
identifier- The JPQL identifier to retrieve its role- Returns:
- The
IdentifierRolefor the given JPQL identifier ornullif no role was defined or if the given string is not a valid JPQL identifier
-
getTableName
Returns the table name that will be used byContentAssistExtensionto retrieve the column names.- Returns:
- The name of the table for which its column names should be retrieve as possible proposals
- Since:
- 2.5
-
getTableNamePrefix
Returns the prefix that will be used to filter the list of possible table names.- Returns:
- The prefix that is used to filter the list of table names or
nullif it was not set for the cursor position within the JPQL query - Since:
- 2.5
-
hasProposals
public boolean hasProposals()Description copied from interface:ContentAssistProposalsDetermines whether there is at least one proposals.- Specified by:
hasProposalsin interfaceContentAssistProposals- Returns:
trueif there is at least one proposal; otherwisefalse
-
identificationVariables
Description copied from interface:ContentAssistProposalsReturns the collection of possible identification variables.- Specified by:
identificationVariablesin interfaceContentAssistProposals- Returns:
- The list of possible identification variables
-
identifiers
Description copied from interface:ContentAssistProposalsReturns the collection of possible JPQL identifiers.- Specified by:
identifiersin interfaceContentAssistProposals- Returns:
- The list of possible JPQL identifiers
-
initialize
-
isColumnName
Determines whether the given proposal is a column name (which should be unqualified).- Parameters:
proposal- The proposal that is being inserted into the JPQL query- Returns:
trueif the given proposal is a column name;falseotherwise- Since:
- 2.5
-
isEnumConstant
Determines whether the given proposal is an enum constant name (which should be unqualified).- Parameters:
proposal- The proposal that is being inserted into the JPQL query- Returns:
trueif the given proposal is a unqualified enum constant name;falseotherwise- Since:
- 2.5
-
isMappingName
Determines whether the given proposal is a mapping name.- Parameters:
proposal- The proposal that is being inserted into the JPQL query- Returns:
trueif the given proposal is a mapping name;falseotherwise- Since:
- 2.5
-
longuestIdentifier
Returns the longest possible JPQL identifier that is related to the given proposal if the proposal is a JPQL identifier and contains multiple words. For instance, the longest form ofJOINorJOIN FETCHisLEFT OUTER JOIN FETCH.- Parameters:
proposal- The proposal to retrieve its longest form if one is associated with it- Returns:
- Either the given proposal if it's not a JPQL identifier or it does not have a longer form or the longest version of the JPQL identifier
-
mappings
Description copied from interface:ContentAssistProposalsReturns the collection of possiblemappings, which can be state fields, association fields and/or collection fields depending on the location used to retrieve the possible proposals.- Specified by:
mappingsin interfaceContentAssistProposals- Returns:
- The list of possible proposals
mappings
-
removeIdentifier
Removes the given JPQL identifier.- Parameters:
identifier- The identifier that was added but actually needs to be removed
-
setClassNamePrefix
Adds the given prefix that will be used to filter the list of possible class names.- Parameters:
prefix- The prefix that is used to filter the list of class namesclassType- Determines how to filter the various types of classes- Since:
- 2.5
-
setTableName
Sets the table name and a prefix that will be used to filter the names of the table's columns.- Parameters:
tableName- The name of the table for which its column names should be retrieve as possible proposalsprefix- The prefix that is used to filter the list of columns names, which is nevernullbut can be an empty string- Since:
- 2.5
-
setTableNamePrefix
Adds the given prefix that will be used to filter the list of possible columns names.- Parameters:
tableNamePrefix- The prefix that is used to filter the list of columns names- Since:
- 2.5
-
startPosition
-
tableNames
Description copied from interface:ContentAssistProposalsReturns the filtered list of possible table names.- Specified by:
tableNamesin interfaceContentAssistProposals- Returns:
- The filtered list of possible table names
-
toString
-