Ejemplo n.º 1
0
  /**
   * Determine whether thisType is storable in otherType due to otherType being a user type.
   *
   * @param thisType The TypeId of the value to be stored
   * @param otherType The TypeId of the value to be stored in
   * @return true if thisType is storable in otherType
   */
  protected boolean userTypeStorable(TypeId thisType, TypeId otherType, ClassFactory cf) {
    /*
     ** If the other type is user-defined, use the java types to determine
     ** assignability.
     */
    if (otherType.userType()) {
      return cf.getClassInspector()
          .assignableTo(
              thisType.getCorrespondingJavaTypeName(), otherType.getCorrespondingJavaTypeName());
    }

    return false;
  }
Ejemplo n.º 2
0
  /**
   * Tell whether this numeric type can be converted to the given type.
   *
   * @param otherType The TypeId of the other type.
   * @param forDataTypeFunction was this called from a scalarFunction like CHAR() or DOUBLE()
   */
  public boolean numberConvertible(TypeId otherType, boolean forDataTypeFunction) {

    // Can't convert numbers to long types
    if (otherType.isLongConcatableTypeId()) return false;

    // Numbers can only be converted to other numbers,
    // and CHAR, (not VARCHARS or LONGVARCHAR).
    // Only with the CHAR() or VARCHAR()function can they be converted.
    boolean retval =
        ((otherType.isNumericTypeId()) || (otherType.isBooleanTypeId()) || (otherType.userType()));

    // For CHAR  Conversions, function can convert
    // Floating types
    if (forDataTypeFunction)
      retval = retval || (otherType.isFixedStringTypeId() && (getTypeId().isFloatingPointTypeId()));

    retval = retval || (otherType.isFixedStringTypeId() && (!getTypeId().isFloatingPointTypeId()));

    return retval;
  }