예제 #1
0
  /**
   * Tell whether this numeric type can be stored into from the given type.
   *
   * @param thisType The TypeId of this type
   * @param otherType The TypeId of the other type.
   * @param cf A ClassFactory
   */
  public boolean numberStorable(TypeId thisType, TypeId otherType, ClassFactory cf) {
    /*
     ** Numbers can be stored into from other number types.
     ** Also, user types with compatible classes can be stored into numbers.
     */
    if ((otherType.isNumericTypeId()) || (otherType.isBooleanTypeId())) return true;

    /*
     ** If the other type is user-defined, use the java types to determine
     ** assignability.
     */
    return userTypeStorable(thisType, otherType, cf);
  }
예제 #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;
  }