Esempio n. 1
0
  /**
   * Method getTypes returns an array of the element classes. Null if the element is null.
   *
   * @return the types (type Class[]) of this Tuple object.
   */
  public Class[] getTypes() {
    Class[] types = new Class[elements.size()];

    for (int i = 0; i < elements.size(); i++) {
      Comparable value = elements.get(i);

      if (value != null) types[i] = value.getClass();
    }

    return types;
  }
Esempio n. 2
0
  private boolean compare_Comparable(int operation, Comparable value1, Object value2) {
    if (operation == SUBSTRING) {
      return false;
    }
    Constructor constructor;
    try {
      constructor = value1.getClass().getConstructor(constructorType);
    } catch (NoSuchMethodException e) {
      return false;
    }
    try {
      if (!constructor.isAccessible())
        AccessController.doPrivileged(new SetAccessibleAction(constructor));
      value2 = constructor.newInstance(new Object[] {((String) value2).trim()});
    } catch (IllegalAccessException e) {
      return false;
    } catch (InvocationTargetException e) {
      return false;
    } catch (InstantiationException e) {
      return false;
    }

    switch (operation) {
      case APPROX:
      case EQUAL:
        {
          return value1.compareTo(value2) == 0;
        }
      case GREATER:
        {
          return value1.compareTo(value2) >= 0;
        }
      case LESS:
        {
          return value1.compareTo(value2) <= 0;
        }
    }
    return false;
  }
 /**
  * Sets the maximum permissible value. If the <code>valueClass</code> has not been specified, and
  * <code>max</code> is non null, the <code>valueClass</code> will be set to that of the class of
  * <code>max</code>.
  *
  * @param max Maximum legal value that can be input
  * @see #setValueClass
  */
 public void setMaximum(Comparable max) {
   if (getValueClass() == null && max != null) {
     setValueClass(max.getClass());
   }
   this.max = max;
 }
 /**
  * Sets the minimum permissible value. If the <code>valueClass</code> has not been specified, and
  * <code>minimum</code> is non null, the <code>valueClass</code> will be set to that of the class
  * of <code>minimum</code>.
  *
  * @param minimum Minimum legal value that can be input
  * @see #setValueClass
  */
 public void setMinimum(Comparable minimum) {
   if (getValueClass() == null && minimum != null) {
     setValueClass(minimum.getClass());
   }
   min = minimum;
 }