Exemplo n.º 1
0
  public static void quicksort(
      Object[] vector, String property, int primero, int ultimo, boolean asc) {
    int i, j, central;
    Object pivote;
    if (ultimo < primero) {
      return;
    }
    central = (primero + ultimo) / 2;
    pivote = vector[central];
    i = primero;
    j = ultimo;

    do {
      if (asc) {
        while (((Comparable) ReflectionFunc.evaluateProperty(vector[i], property))
                .compareTo((Comparable) ReflectionFunc.evaluateProperty(pivote, property))
            < 0) {
          i++;
        }
      } else {
        while (((Comparable) ReflectionFunc.evaluateProperty(vector[i], property))
                .compareTo(ReflectionFunc.evaluateProperty(pivote, property))
            > 0) {
          i++;
        }
      }

      if (asc) {
        while (((Comparable) ReflectionFunc.evaluateProperty(vector[j], property))
                .compareTo(ReflectionFunc.evaluateProperty(pivote, property))
            > 0) {
          j--;
        }
      } else {
        while (((Comparable) ReflectionFunc.evaluateProperty(vector[j], property))
                .compareTo(ReflectionFunc.evaluateProperty(pivote, property))
            < 0) {
          j--;
        }
      }

      if (i <= j) {
        Object temp;
        temp = vector[i];
        vector[i] = vector[j];
        vector[j] = temp;

        i++;
        j--;
      }
    } while (i <= j);

    if (primero < j) {
      quicksort(vector, property, primero, j, asc);
    }

    if (i < ultimo) {
      quicksort(vector, property, i, ultimo, asc);
    }
  }
Exemplo n.º 2
0
  public Object getValueAt(int arg0, int arg1) {

    if (data.size() == arg0) {
      return null;
    }

    return ReflectionFunc.evaluateProperty(((List<T>) data).get(arg0), properties[arg1]);
  }
Exemplo n.º 3
0
  @Override
  public void setValueAt(Object arg0, int arg1, int arg2) {

    if (data.size() == arg1) {
      if (this.NuevolistenerList.getListenerList().length > 0) {
        // data.add(((CollectionTableModelNewObjectListener<T>)
        // this.NuevolistenerList.getListenerList()[1]).newObj(this));
        ((CollectionTableModelNewObjectListener<T>) this.NuevolistenerList.getListenerList()[1])
            .newObj(this);
      } else {
        return;
      }
    }

    ReflectionFunc.setProperty(((List<T>) data).get(arg1), properties[arg2], arg0);
  }