public final class DefaultContentAssistProposals extends java.lang.Object implements 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.
ContentAssistProposals.ClassType, ContentAssistProposals.EnumProposals
Constructor and Description |
---|
DefaultContentAssistProposals(JPQLGrammar jpqlGrammar,
ContentAssistExtension extension)
Creates a new
DefaultContentAssistProposals . |
Modifier and Type | Method and Description |
---|---|
java.lang.Iterable<IEntity> |
abstractSchemaTypes()
Returns the collection of possible abstract schema types.
|
void |
addEntity(IEntity abstractSchemaType)
Adds the given
IEntity as a possible abstract schema type. |
void |
addEnumConstant(IType enumType,
java.lang.String enumConstant)
Adds the constants of the given enum constant as a valid proposal.
|
void |
addIdentificationVariable(java.lang.String identificationVariable)
Adds the given identification variable as a proposal.
|
void |
addIdentifier(java.lang.String identifier)
Adds the given JPQL identifier as a proposal.
|
void |
addMapping(IMapping mapping)
Adds the given
mapping (state field, association field or collection field)
as a valid proposal. |
void |
addMappings(java.util.Collection<IMapping> mappings)
Adds the given
mappings (state fields, association fields or collection fields)
as valid proposals. |
void |
addRangeIdentificationVariable(java.lang.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.Result |
buildEscapedQuery(java.lang.String jpqlQuery,
java.lang.String proposal,
int position,
boolean insert)
Creates a new JPQL query by inserting the given proposal at the given position.
|
int[] |
buildPositions(WordParser wordParser,
java.lang.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.Result |
buildQuery(java.lang.String jpqlQuery,
java.lang.String proposal,
int position,
boolean insert)
Creates a new JPQL query by inserting the given proposal at the given position.
|
ResultQuery |
buildXmlQuery(java.lang.String jpqlQuery,
java.lang.String proposal,
int position,
boolean insert)
Creates a new JPQL query by inserting the given proposal at the given position.
|
java.lang.Iterable<java.lang.String> |
classNames()
Returns the filtered list of possible class names.
|
java.lang.Iterable<java.lang.String> |
columnNames()
Returns the filtered list of possible column names.
|
java.lang.Iterable<ContentAssistProposals.EnumProposals> |
enumConstant()
Returns the filtered list of possible enum constant names.
|
IEntity |
getAbstractSchemaType(java.lang.String identificationVariable)
Retrieves the abstract schema type that is mapped with the given identification variable.
|
java.lang.String |
getClassNamePrefix()
Returns the prefix that will be used to filter the list of possible class names.
|
ContentAssistProposals.ClassType |
getClassType() |
java.lang.String |
getColumnNamePrefix()
Returns the prefix that will be used by
ContentAssistExtension to filter the column
names if the table name is not null . |
JPQLGrammar |
getGrammar()
Returns the
JPQLGrammar that defines how the JPQL query was parsed. |
IdentifierRole |
getIdentifierRole(java.lang.String identifier)
Returns the role of the given JPQL identifier.
|
java.lang.String |
getTableName()
Returns the table name that will be used by
ContentAssistExtension to retrieve the
column names. |
java.lang.String |
getTableNamePrefix()
Returns the prefix that will be used to filter the list of possible table names.
|
boolean |
hasProposals()
Determines whether there is at least one proposals.
|
java.lang.Iterable<java.lang.String> |
identificationVariables()
Returns the collection of possible identification variables.
|
java.lang.Iterable<java.lang.String> |
identifiers()
Returns the collection of possible JPQL identifiers.
|
protected void |
initialize(JPQLGrammar jpqlGrammar,
ContentAssistExtension extension) |
boolean |
isColumnName(java.lang.String proposal)
Determines whether the given proposal is a column name (which should be unqualified).
|
boolean |
isEnumConstant(java.lang.String proposal)
Determines whether the given proposal is an enum constant name (which should be unqualified).
|
boolean |
isMappingName(java.lang.String proposal)
Determines whether the given proposal is a mapping name.
|
java.lang.String |
longuestIdentifier(java.lang.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.
|
java.lang.Iterable<IMapping> |
mappings()
Returns the collection of possible
mappings , which can be state fields,
association fields and/or collection fields depending on the location used to retrieve the
possible proposals. |
protected void |
removeIdentifier(java.lang.String identifier)
Removes the given JPQL identifier.
|
void |
setClassNamePrefix(java.lang.String prefix,
ContentAssistProposals.ClassType classType)
Adds the given prefix that will be used to filter the list of possible class names.
|
void |
setTableName(java.lang.String tableName,
java.lang.String prefix)
Sets the table name and a prefix that will be used to filter the names of the table's columns.
|
void |
setTableNamePrefix(java.lang.String tableNamePrefix)
Adds the given prefix that will be used to filter the list of possible columns names.
|
int |
startPosition(WordParser wordParser,
java.lang.String proposal) |
java.lang.Iterable<java.lang.String> |
tableNames()
Returns the filtered list of possible table names.
|
java.lang.String |
toString() |
public DefaultContentAssistProposals(JPQLGrammar jpqlGrammar, ContentAssistExtension extension)
DefaultContentAssistProposals
.jpqlGrammar
- The JPQLGrammar
that 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
namespublic java.lang.Iterable<IEntity> abstractSchemaTypes()
abstractSchemaTypes
in interface ContentAssistProposals
entities
defined in the persistence contextpublic void addEntity(IEntity abstractSchemaType)
IEntity
as a possible abstract schema type.abstractSchemaType
- The abstract schema type that is a valid proposalpublic void addEnumConstant(IType enumType, java.lang.String enumConstant)
enumType
- The IType
of the enum typeenumConstant
- The enum constant to be added as a valid proposalpublic void addIdentificationVariable(java.lang.String identificationVariable)
identificationVariable
- The identification variable that is a valid proposalpublic void addIdentifier(java.lang.String identifier)
identifier
- The JPQL identifier that is a valid proposalpublic void addMapping(IMapping mapping)
mapping
(state field, association field or collection field)
as a valid proposal.mapping
- The IMapping
of the state field, association field or collection fieldpublic void addMappings(java.util.Collection<IMapping> mappings)
mappings
(state fields, association fields or collection fields)
as valid proposals.mappings
- The mappings
of the state fields, association fields or
collection fieldspublic void addRangeIdentificationVariable(java.lang.String identificationVariable, IEntity entity)
identificationVariable
- The range identification variable mapping the abstract schema nameentity
- The abstract type name that identifies the type of the variablepublic org.eclipse.persistence.jpa.jpql.tools.DefaultContentAssistProposals.Result buildEscapedQuery(java.lang.String jpqlQuery, java.lang.String proposal, int position, boolean insert)
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".
buildEscapedQuery
in interface ContentAssistProposals
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 proposalpublic int[] buildPositions(WordParser wordParser, java.lang.String proposal, boolean insert)
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 cursorpublic org.eclipse.persistence.jpa.jpql.tools.DefaultContentAssistProposals.Result buildQuery(java.lang.String jpqlQuery, java.lang.String proposal, int position, boolean insert)
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".
buildQuery
in interface ContentAssistProposals
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 proposalpublic ResultQuery buildXmlQuery(java.lang.String jpqlQuery, java.lang.String proposal, int position, boolean insert)
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".
buildXmlQuery
in interface ContentAssistProposals
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 proposalpublic java.lang.Iterable<java.lang.String> classNames()
classNames
in interface ContentAssistProposals
ConstructorExpression
public java.lang.Iterable<java.lang.String> columnNames()
columnNames
in interface ContentAssistProposals
public java.lang.Iterable<ContentAssistProposals.EnumProposals> enumConstant()
enumConstant
in interface ContentAssistProposals
public IEntity getAbstractSchemaType(java.lang.String identificationVariable)
getAbstractSchemaType
in interface ContentAssistProposals
identificationVariable
- The identification variable that, if defined as a range variable,
will be mapped to a managed typenull
if the given variable is mapped to something else or not mapped to anythingpublic java.lang.String getClassNamePrefix()
null
if it
was not set for the cursor position within the JPQL querypublic ContentAssistProposals.ClassType getClassType()
getClassType
in interface ContentAssistProposals
public java.lang.String getColumnNamePrefix()
ContentAssistExtension
to filter the column
names if the table name is not null
.null
if it has not been set along with the table namepublic JPQLGrammar getGrammar()
JPQLGrammar
that defines how the JPQL query was parsed.JPQLGrammar
that was used to parse this Expression
public IdentifierRole getIdentifierRole(java.lang.String identifier)
getIdentifierRole
in interface ContentAssistProposals
identifier
- The JPQL identifier to retrieve its roleIdentifierRole
for the given JPQL identifier or null
if no
role was defined or if the given string is not a valid JPQL identifierpublic java.lang.String getTableName()
ContentAssistExtension
to retrieve the
column names.public java.lang.String getTableNamePrefix()
null
if it
was not set for the cursor position within the JPQL querypublic boolean hasProposals()
hasProposals
in interface ContentAssistProposals
true
if there is at least one proposal; otherwise false
public java.lang.Iterable<java.lang.String> identificationVariables()
identificationVariables
in interface ContentAssistProposals
public java.lang.Iterable<java.lang.String> identifiers()
identifiers
in interface ContentAssistProposals
protected void initialize(JPQLGrammar jpqlGrammar, ContentAssistExtension extension)
public boolean isColumnName(java.lang.String proposal)
proposal
- The proposal that is being inserted into the JPQL querytrue
if the given proposal is a column name; false
otherwisepublic boolean isEnumConstant(java.lang.String proposal)
proposal
- The proposal that is being inserted into the JPQL querytrue
if the given proposal is a unqualified enum constant name;
false
otherwisepublic boolean isMappingName(java.lang.String proposal)
proposal
- The proposal that is being inserted into the JPQL querytrue
if the given proposal is a mapping name; false
otherwisepublic java.lang.String longuestIdentifier(java.lang.String proposal)
JOIN
or JOIN FETCH
is LEFT OUTER JOIN FETCH
.proposal
- The proposal to retrieve its longest form if one is associated with itpublic java.lang.Iterable<IMapping> mappings()
mappings
, which can be state fields,
association fields and/or collection fields depending on the location used to retrieve the
possible proposals.mappings
in interface ContentAssistProposals
mappings
protected void removeIdentifier(java.lang.String identifier)
identifier
- The identifier that was added but actually needs to be removedpublic void setClassNamePrefix(java.lang.String prefix, ContentAssistProposals.ClassType classType)
prefix
- The prefix that is used to filter the list of class namesclassType
- Determines how to filter the various types of classespublic void setTableName(java.lang.String tableName, java.lang.String prefix)
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 never
null
but can be an empty stringpublic void setTableNamePrefix(java.lang.String tableNamePrefix)
tableNamePrefix
- The prefix that is used to filter the list of columns namespublic int startPosition(WordParser wordParser, java.lang.String proposal)
public java.lang.Iterable<java.lang.String> tableNames()
tableNames
in interface ContentAssistProposals
public java.lang.String toString()
toString
in class java.lang.Object