Package org.eclipse.persistence.jpa.jpql.spi

Examples of org.eclipse.persistence.jpa.jpql.spi.IType


   * have been converted into the class of that primitive
   */
  public IType convertPrimitive(IType type) {

    // byte
    IType newType = toByteType(type);
    if (newType != type) {
      return newType;
    }

    // short
View Full Code Here


    TypeHelper typeHelper = getTypeHelper();

    for (int index = types1.length; --index >= 0; ) {

      // Convert a primitive to its Object type
      IType type1 = typeHelper.convertPrimitive(types1[index].getType());
      IType type2 = typeHelper.convertPrimitive(types2[index]);

      if (!type1.isAssignableTo(type2)) {
        return false;
      }
    }
View Full Code Here

    return isValid(expression, BooleanTypeValidator.class);
  }

  private boolean isComparisonEquivalentType(Expression expression1, Expression expression2) {

    IType type1 = getType(expression1);
    IType type2 = getType(expression2);

    // 1. The types are the same
    // 2. The type cannot be determined, pretend they are equivalent,
    //    another rule will validate it
    // 3. One is assignable to the other one
    TypeHelper typeHelper = getTypeHelper();

    return (type1 == type2) ||
           !type1.isResolvable() ||
           !type2.isResolvable() ||
            typeHelper.isNumericType(type1) && typeHelper.isNumericType(type2) ||
            typeHelper.isDateType(type1)    && typeHelper.isDateType(type2)    ||
            type1.isAssignableTo(type2) ||
            type2.isAssignableTo(type1);
  }
View Full Code Here

            type2.isAssignableTo(type1);
  }

  private boolean isEquivalentBetweenType(Expression expression1, Expression expression2) {

    IType type1 = getType(expression1);
    IType type2 = getType(expression2);

    // The type cannot be determined, pretend they are equivalent,
    // another rule will validate it
    if (!type1.isResolvable() || !type2.isResolvable()) {
      return true;
    }

    TypeHelper typeHelper = getTypeHelper();
View Full Code Here

  private boolean isIntegralType(Expression expression) {

    if (isNumericType(expression)) {

      TypeHelper typeHelper = getTypeHelper();
      IType type = getType(expression);

      if (type != typeHelper.unknownType()) {
        return typeHelper.isIntegralType(type);
      }
    }
View Full Code Here

       !collectionValuedPathExpression.endsWithDot()) {

      // A collection_valued_field is designated by the name of an association field in a
      // one-to-many or a many-to-many relationship or by the name of an element collection field
      Resolver resolver = getResolver(expression);
      IType type = resolver.getType();
      IMapping mapping = resolver.getMapping();

      // Does not resolve to a valid path
      if (!type.isResolvable() || (mapping == null)) {
        int startIndex = position(expression);
        int endIndex   = startIndex + length(expression);

        addProblem(
          expression,
View Full Code Here

    // A single_valued_object_field is designated by the name of an association field in a
    // one-to-one or many-to-one relationship or a field of embeddable class type
    if (expression.hasIdentificationVariable() &&
       !expression.endsWithDot()) {

      IType type = getType(expression);
      IMapping mapping = getMapping(expression);

      // Does not resolve to a valid path
      if (!type.isResolvable()) {
        addProblem(expression, StateFieldPathExpression_NotResolvable, expression.toParsedText());
      }
      // Make sure an enum constant was parsed as a state field path
      // expression before checking for a mapping
      else if ((mapping == null) && type.isEnum()) {
        String enumConstant = expression.getPath(expression.pathSize() - 1);
        boolean found = false;

        for (String constant : type.getEnumConstants()) {
          if (constant.equals(enumConstant)) {
            found = true;
            break;
          }
        }

        if (!found) {
          int startIndex = position(expression) + type.getName().length() + 1;
          int endIndex   = startIndex + enumConstant.length();
          addProblem(expression, startIndex, endIndex, StateFieldPathExpression_InvalidEnumConstant, enumConstant);
        }

        // Remove the used identification variable since it's is the first
View Full Code Here

          addProblem(expression, UpdateItem_NullNotAssignableToPrimitive);
        }
        return;
      }

      IType newValueType = getType(newValue);

      if (!newValueType.isResolvable() ||
         typeHelper.isDateType(type)    && typeHelper.isDateType(newValueType) ||
         typeHelper.isNumericType(type) && typeHelper.isNumericType(newValueType)) {

        return;
      }

      // The new value's type can't be assigned to the item's type
      if (!newValueType.isAssignableTo(type)) {
        addProblem(expression, UpdateItem_NotAssignable, newValueType.getName(), type.getName());
      }
    }
  }
View Full Code Here

    // collection member expressions
    if (expression.hasEntityExpression()) {
      Expression entityExpression = expression.getEntityExpression();

      // Check for embeddable type
      IType type = getType(entityExpression);
      IManagedType managedType = getManagedType(type);

      if (isEmbeddable(managedType)) {
        addProblem(entityExpression, CollectionMemberExpression_Embeddable);
      }
View Full Code Here

    String className = expression.getClassName();

    // Only test the constructor if it has been specified
    if (ExpressionTools.stringIsNotEmpty(className)) {
      IType type = getType(className);

      // Unknown type
      if (!type.isResolvable()) {
        int startIndex = position(expression) + 4; // NEW + space
        int endIndex   = startIndex + className.length();
        addProblem(expression, startIndex, endIndex, ConstructorExpression_UnknownType);
      }
      // Test the arguments' types with the constructors' types
      // TODO: Add support for ... (array)
      else if (expression.hasLeftParenthesis()) {

        boolean validated = false;

        // Retrieve the constructor's arguments so their type can be calculated
        ItemExpression visitor = new ItemExpression();
        expression.getConstructorItems().accept(visitor);
        IType[] calculatedTypes = null;

        // Retrieve the type's constructors
        for (IConstructor constructor : type.constructors()) {
          ITypeDeclaration[] types1 = constructor.getParameterTypes();

          // The number of items match, check their types are equivalent
          if (visitor.expressions.size() == types1.length) {
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jpa.jpql.spi.IType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.