Package org.eclipse.persistence.jpa.jpql

Examples of org.eclipse.persistence.jpa.jpql.TypeHelper


    if (mapping == null) {
      return null;
    }

    TypeHelper typeHelper = getTypeHelper();
    ITypeDeclaration typeDeclaration = mapping.getTypeDeclaration();
    IType type = typeDeclaration.getType();

    // Collection type cannot be traversed
    if (typeHelper.isCollectionType(type)) {

      ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();

      if (typeParameters.length == 0) {
        return null;
      }

      type = typeParameters[0].getType();
    }
    // Wrap the Map into a virtual IManagedType so it can be returned and the
    // IType for the Map can be used to retrieve the type of the key and value
    else if (typeHelper.isMapType(type)) {
      return new MapManagedType(getManagedTypeProvider(), type);
    }

    // Retrieve the corresponding managed type for the mapping's type
    return getManagedTypeProvider().getManagedType(type);
View Full Code Here


    if (types1.length != types1.length) {
      return false;
    }

    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

    // 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

    // another rule will validate it
    if (!type1.isResolvable() || !type2.isResolvable()) {
      return true;
    }

    TypeHelper typeHelper = getTypeHelper();

    if (type1 == type2) {
      return typeHelper.isNumericType(type1) ||
      typeHelper.isStringType(type1||
      typeHelper.isDateType(type1);
    }
    else {
      return typeHelper.isNumericType(type1) && typeHelper.isNumericType(type2) ||
             typeHelper.isStringType(type1&& typeHelper.isStringType(type2||
             typeHelper.isDateType(type1)    && typeHelper.isDateType(type2);
    }
  }
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);
      }
    }

    return false;
  }
View Full Code Here

  private void validateUpdateItemTypes(UpdateItem expression, IType type) {

    if (expression.hasNewValue()) {

      Expression newValue = expression.getNewValue();
      TypeHelper typeHelper = getTypeHelper();
      boolean nullValue = isNullValue(newValue);

      // A NULL value is ignored, except if the type is a primitive, null cannot be
      // assigned to a mapping of primitive type
      if (nullValue) {
        if (typeHelper.isPrimitiveType(type)) {
          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
View Full Code Here

   */
  @Override
  IType buildType() {

    IType type = getTypeDeclaration().getType();
    TypeHelper helper = getTypeHelper();

    // Integral types: int/Integer, long/Long => the result is a Long
    if (helper.isIntegralType(type)) {
      return helper.longType();
    }

    // Floating types: float/Float, double/Double => the result is a Double
    if (helper.isFloatingType(type)) {
      return helper.doubleType();
    }

    // BigInteger, the result is the same
    IType bigIntegerType = helper.bigInteger();

    if (type.equals(bigIntegerType)) {
      return bigIntegerType;
    }

    // BigDecimal, the result is the same
    IType bigDecimalType = helper.bigDecimal();

    if (type.equals(bigDecimalType)) {
      return bigDecimalType;
    }

    // Anything else is an invalid type
    return helper.objectType();
  }
View Full Code Here

   */
  @Override
  IType buildType() {

    List<IType> types = new ArrayList<IType>(resolvers.size());
    TypeHelper helper = getTypeHelper();
    IType unresolvableType = helper.unknownType();

    // Convert any primitive types into its Class type and any non-number into Object
    for (Resolver typeResolver : resolvers) {

      IType type = typeResolver.getType();

      // Only a resolvable type will be added to the list
      if (type != unresolvableType) {
        // Non-numeric type cannot be added
        if (!helper.isNumericType(type)) {
          type = helper.objectType();
        }
        types.add(type);
      }
    }

    if (types.isEmpty()) {
      return helper.unknownType();
    }

    // Comparing the types will result in putting the
    // result at the beginning of the list
    Collections.sort(types, new NumericTypeComparator(helper));
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  IType buildType() {

    TypeHelper helper = getTypeHelper();
    IType unknownType = helper.unknownType();
    IType type = null;

    for (int index = 0, count = resolvers.size(); index < count; index++) {
      IType anotherType = resolvers.get(index).getType();

      if (anotherType == unknownType) {
        continue;
      }

      if (type == null) {
        type = anotherType;
      }
      // Two types are not the same, then the type is Object
      else if (!type.equals(anotherType)) {
        return helper.objectType();
      }
    }

    if (type == null) {
      type = unknownType;
View Full Code Here

   */
  @Override
  IType buildType() {

    List<IType> types = new ArrayList<IType>(resolvers.size());
    TypeHelper helper = getTypeHelper();
    IType unresolvableType = helper.unknownType();

    // Convert any primitive types into its Class type and any non-number into Object
    for (Resolver typeResolver : resolvers) {

      IType type = typeResolver.getType();

      // Only a resolvable type will be added to the list
      if (type != unresolvableType) {
        // Non-numeric type cannot be added
        if (!helper.isNumericType(type)) {
          type = helper.objectType();
        }
        types.add(type);
      }
    }

    if (types.isEmpty()) {
      return helper.unknownType();
    }

    // Comparing the types will result in putting the
    // result at the beginning of the list
    Collections.sort(types, new NumericTypeComparator(helper));
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jpa.jpql.TypeHelper

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.