Package de.lmu.ifi.dbs.elki.utilities.optionhandling

Examples of de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException


      return;
    }

    for(List<Double> vec : vector.getValue()) {
      if(vec.size() != size.getValue()) {
        throw new WrongParameterValueException("Global Parameter Constraint Error.\n" + "The vectors of vector list parameter " + vector.getName() + " have not the required dimension of " + size.getValue() + " given by integer parameter " + size.getName() + ".");
      }
    }
  }
View Full Code Here


   *         equal to the list size constraint specified.
   */
  @Override
  public void test(List<T> t) throws ParameterException {
    if(t.size() != sizeConstraint) {
      throw new WrongParameterValueException("Parameter Constraint Error.\n" + "List parameter has not the required size. (Requested size: " + +sizeConstraint + ", current size: " + t.size() + ").\n");
    }
  }
View Full Code Here

     */
    @Override
    public void test(List<N> t) throws ParameterException {
        for (Number n : t) {
            if (n.doubleValue() < constraintValue.doubleValue()) {
                throw new WrongParameterValueException("Parameter Constraint Error: \n"
                    + "The parameter values specified have to be greater than or equal to " + constraintValue.toString()
                    + ". (current value: " + t + ")\n");
            }
        }
    }
View Full Code Here

      else {
        notSet.add(p.getName());
      }
    }
    if(!set.isEmpty() && !notSet.isEmpty()) {
      throw new WrongParameterValueException("Global Constraint Error.\n" + "Either all of the parameters " + OptionUtil.optionsNamesToString(parameterList) + " must be set or none of them. " + "Parameter(s) currently set: " + set.toString() + ", parameters currently " + "not set: " + notSet.toString());
    }
  }
View Full Code Here

          set.add(p.getName());
        }
      }
    }
    if(set.size() > 1) {
      throw new WrongParameterValueException("Global Parameter Constraint Error.\n" + "Only one of the parameters " + OptionUtil.optionsNamesToString(parameters) + " is allowed to be set. " + "Parameters currently set: " + set.toString());
    }
  }
View Full Code Here

   * length restrictions. If not, a parameter exception is thrown.
   */
  @Override
  public void test(String t) throws ParameterException {
    if(t.length() < minlength) {
      throw new WrongParameterValueException("Parameter Constraint Error.\n" + "Parameter value length must be at least " + minlength + ".");
    }
    if(maxlength > 0 && t.length() > maxlength) {
      throw new WrongParameterValueException("Parameter Constraint Error.\n" + "Parameter value length must be at most " + maxlength + ".");
    }
  }
View Full Code Here

     *
     */
    @Override
    public void test(Number t) throws ParameterException {
        if (t.doubleValue() < constraintValue.doubleValue()) {
            throw new WrongParameterValueException("Parameter Constraint Error: \n"
                + "The parameter value specified has to be greater equal than "
                + constraintValue.toString() +
                ". (current value: " + t.doubleValue() + ")\n");
        }
    }
View Full Code Here

      if(t.equalsIgnoreCase(constraint)) {
        return;
      }
    }

    throw new WrongParameterValueException("Parameter Constraint Error.\n" + "Parameter value must be one of the following values: " + constraintStrings());
  }
View Full Code Here

    }
    try {
      return Long.parseLong(obj.toString());
    }
    catch(NullPointerException e) {
      throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a double value, read: " + obj + "!\n");
    }
    catch(NumberFormatException e) {
      throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a double value, read: " + obj + "!\n");
    }
  }
View Full Code Here

    try {
      List<?> l = List.class.cast(obj);
      // do extra validation:
      for(Object o : l) {
        if(!(o instanceof File)) {
          throw new WrongParameterValueException("Wrong parameter format for parameter \"" + getName() + "\". Given list contains objects of different type!");
        }
      }
      // TODO: can we use reflection to get extra checks?
      return (List<File>) l;
    }
    catch(ClassCastException e) {
      // continue with others
    }
    if(obj instanceof String) {
      String[] values = SPLIT.split((String) obj);
      ArrayList<File> fileValue = new ArrayList<File>(values.length);
      for(String val : values) {
        fileValue.add(new File(val));
      }
      return fileValue;
    }
    throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a list of file values!");
  }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException

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.