Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.jpa.internal.jpql
Class DefaultContentAssistProposals

java.lang.Object
  extended by org.eclipse.persistence.jpa.internal.jpql.DefaultContentAssistProposals

All Implemented Interfaces:
ContentAssistProposals

public final class DefaultContentAssistProposals
extends java.lang.Object
implements ContentAssistProposals

The default implementation of ContentAssistProposals which stores the valid proposals.

Since:
2.3
Version:
2.3
Author:
Pascal Filion

Nested Class Summary
private  class DefaultContentAssistProposals.Result
          This contains the result of inserting a proposal into a JPQL query at a given position.

 

Field Summary
private  java.util.Set<IEntity> abstractSchemaTypes
          The set of possible abstract schema types.
private  java.util.Set<java.lang.String> identificationVariables
          The set of possible identification variables.
private  java.util.Set<java.lang.String> identifiers
          The set of possible JPQL identifiers.
private static java.util.Map<java.lang.String,java.lang.String> LONGUEST_IDENTIFIERS
          A JPQL identifier that is mapped to its longest counterpart.
private  java.util.Set<IMapping> mappings
          The set of possible mappings, which can be state fields, association fields and/or collection fields.
private static java.util.Map<java.lang.String,java.util.List<java.lang.String>> ORDERED_IDENTIFIERS
          A JPQL identifier that is mapped to the list of counterparts used to find them in the query.
private  java.util.Map<java.lang.String,IEntity> rangeIdentificationVariables
          The identification variables mapped to their abstract schema types.

 

Constructor Summary
DefaultContentAssistProposals()
          Creates a new DefaultContentAssistProposals.

 

Method Summary
 java.lang.Iterable<IEntity> abstractSchemaTypes()
          Returns the collection of possible abstract schema types.
 void addAbstractSchemaType(IEntity abstractSchemaType)
          Adds the given IEntity as a possible abstract schema type.
 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 abstractSchemaType)
          Adds the given range identification variable that is mapping the given abstract schema type.
 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.
private static java.util.Map<java.lang.String,java.lang.String> buildLonguestIdentifiers()
           
private static java.util.Map<java.lang.String,java.util.List<java.lang.String>> buildOrderedIdentifiers()
           
private  int[] buildPositions(WordParser wordParser, java.lang.String proposal, boolean insert)
          Calculates the start and end position for correctly inserting the proposal into the query.
 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.
 IEntity getAbstractSchemaType(java.lang.String identificationVariable)
          Retrieves the abstract schema type that is mapped with the given identification variable.
 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.
private  void initialize()
           
private  java.lang.String longuestIdentifier(java.lang.String proposal)
           
 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.
 boolean remove(java.lang.String proposal)
          This is only used by the unit-tests, it removes the given proposal from one of the collection of possible proposals.
private  int startPositionImp(WordParser wordParser, java.lang.String proposal)
           
 java.lang.String toString()
          

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

abstractSchemaTypes

private java.util.Set<IEntity> abstractSchemaTypes
The set of possible abstract schema types.

identificationVariables

private java.util.Set<java.lang.String> identificationVariables
The set of possible identification variables.

identifiers

private java.util.Set<java.lang.String> identifiers
The set of possible JPQL identifiers.

mappings

private java.util.Set<IMapping> mappings
The set of possible mappings, which can be state fields, association fields and/or collection fields.

rangeIdentificationVariables

private java.util.Map<java.lang.String,IEntity> rangeIdentificationVariables
The identification variables mapped to their abstract schema types.

LONGUEST_IDENTIFIERS

private static final java.util.Map<java.lang.String,java.lang.String> LONGUEST_IDENTIFIERS
A JPQL identifier that is mapped to its longest counterpart.

ORDERED_IDENTIFIERS

private static final java.util.Map<java.lang.String,java.util.List<java.lang.String>> ORDERED_IDENTIFIERS
A JPQL identifier that is mapped to the list of counterparts used to find them in the query.

Constructor Detail

DefaultContentAssistProposals

public DefaultContentAssistProposals()
Creates a new DefaultContentAssistProposals.

Method Detail

buildLonguestIdentifiers

private static java.util.Map<java.lang.String,java.lang.String> buildLonguestIdentifiers()

buildOrderedIdentifiers

private static java.util.Map<java.lang.String,java.util.List<java.lang.String>> buildOrderedIdentifiers()

abstractSchemaTypes

public java.lang.Iterable<IEntity> abstractSchemaTypes()
Returns the collection of possible abstract schema types.
Specified by:
abstractSchemaTypes in interface ContentAssistProposals
Returns:
The entities defined in the persistence context

addAbstractSchemaType

public void addAbstractSchemaType(IEntity abstractSchemaType)
Adds the given IEntity as a possible abstract schema type.
Parameters:
abstractSchemaType - The abstract schema type that is a valid proposal

addIdentificationVariable

public void addIdentificationVariable(java.lang.String identificationVariable)
Adds the given identification variable as a proposal.
Parameters:
identificationVariable - The identification variable that is a valid proposal

addIdentifier

public void addIdentifier(java.lang.String identifier)
Adds the given JPQL identifier as a proposal.
Parameters:
identifier - The JPQL identifier that is a valid proposal

addMapping

public void addMapping(IMapping mapping)
Adds the given mapping (state field, association field or collection field) as a valid proposal.
Parameters:
mapping - The IMapping of the state field, association field or collection field

addMappings

public void addMappings(java.util.Collection<IMapping> mappings)
Adds the given mappings (state fields, association fields or collection fields) as valid proposals.
Parameters:
mappings - The mappings of the state fields, association fields or collection fields

addRangeIdentificationVariable

public void addRangeIdentificationVariable(java.lang.String identificationVariable,
                                           IEntity abstractSchemaType)
Adds the given range identification variable that is mapping the given abstract schema type.
Parameters:
identificationVariable - The range identification variable mapping the abstract schema name
abstractSchemaType - The abstract type name that identifies the type of the variable

buildEscapedQuery

public 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. The resulted JPQL query and position will be adjusted by converting the escaped characters escaped to string values, which means '\r' will have been converted to '\\r.

TODO: TO REWORD: If the proposal is has more than one identifier, for instance, IS NOT NULL, then the replacement will go further than just replacing the current word. If the cursor is in "IS NOT N|" and the proposal is "IS NOT NULL", then "IS NOT" will not be added twice. If the identifier is "IS NULL" and the proposal is "IS NOT NULL", then NOT will be inserted between IS and NULL.

Specified by:
buildEscapedQuery in interface ContentAssistProposals
Parameters:
jpqlQuery - The JPQL query to insert the given proposal
proposal - The proposal to insert into the query
position - The position of insertion
insert - Flag that determines if the partial word following the cursor should be left intact or replaced by the proposal
Returns:
The result of inserting the proposal into the query, including the adjust position, if it was required

buildPositions

private int[] buildPositions(WordParser wordParser,
                             java.lang.String proposal,
                             boolean insert)
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 position
proposal - The proposal to be inserted into the query
insert - 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 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.

TODO: TO REWORD: If the proposal is has more than one identifier, for instance, IS NOT NULL, then the replacement will go further than just replacing the current word. If the cursor is in "IS NOT N|" and the proposal is "IS NOT NULL", then "IS NOT" will not be added twice. If the identifier is "IS NULL" and the proposal is "IS NOT NULL", then NOT will be inserted between IS and NULL.

Specified by:
buildQuery in interface ContentAssistProposals
Parameters:
jpqlQuery - The JPQL query to insert the given proposal
proposal - The proposal to insert into the query
position - The position of insertion
insert - Flag that determines if the partial word following the cursor should be left intact or replaced by the proposal
Returns:
The result of inserting the proposal into the query, including the adjust position, if it was required

getAbstractSchemaType

public IEntity getAbstractSchemaType(java.lang.String identificationVariable)
Retrieves the abstract schema type that is mapped with the given identification variable.
Specified by:
getAbstractSchemaType in interface ContentAssistProposals
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 null if the given variable is mapped to something else or not mapped to anything

hasProposals

public boolean hasProposals()
Determines whether there is at least one proposals.
Specified by:
hasProposals in interface ContentAssistProposals
Returns:
true if there is at least one proposal; otherwise false

identificationVariables

public java.lang.Iterable<java.lang.String> identificationVariables()
Returns the collection of possible identification variables.
Specified by:
identificationVariables in interface ContentAssistProposals
Returns:
The list of possible identification variables

identifiers

public java.lang.Iterable<java.lang.String> identifiers()
Returns the collection of possible JPQL identifiers.
Specified by:
identifiers in interface ContentAssistProposals
Returns:
The list of possible JPQL identifiers

initialize

private void initialize()

longuestIdentifier

private java.lang.String longuestIdentifier(java.lang.String proposal)

mappings

public 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.
Specified by:
mappings in interface ContentAssistProposals
Returns:
The list of possible proposals mappings

remove

public boolean remove(java.lang.String proposal)
This is only used by the unit-tests, it removes the given proposal from one of the collection of possible proposals.
Parameters:
proposal - The proposal to remove
Returns:
true the given proposal was removed from one of the collections; false if it could not be found, thus not removed

startPositionImp

private int startPositionImp(WordParser wordParser,
                             java.lang.String proposal)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.