Examples of OptionException


Examples of org.maltparserx.core.options.OptionException

   */
  public Object getValueObject(String value) throws MaltChainedException {
    try {
      return new Integer(Integer.parseInt(value));
    } catch (NumberFormatException e) {
      throw new OptionException("Illegal integer value '"+value+"' for the '"+getName()+"' option. ", e);
   
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

   */
  public void setDefaultValue(String defaultValue) throws MaltChainedException {
    try {
      this.defaultValue = Integer.parseInt(defaultValue);
    } catch (NumberFormatException e) {
      throw new OptionException("Illegal integer default value '"+defaultValue+"' for the '"+getName()+"' option. ", e);
    }
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

    if (value == null) {
      return null;
    } else if (legalValues.contains(value)) {
      return legalValueClass.get(value);
    } else {
      throw new OptionException("'"+value+"' is not a legal value for the '"+getName()+"' option. ");
   
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

   * @see org.maltparser.core.options.option.Option#setDefaultValue(java.lang.String)
   */
  public void setDefaultValue(String defaultValue) throws MaltChainedException {
    if (defaultValue == null) {
      if (legalValues.isEmpty()) {
        throw new OptionException("The default value is null and the legal value set is empty for the '"+getName()+"' option. ");
      } else {
        this.defaultValue = legalValueClass.get(((TreeSet<String>)legalValueClass.keySet()).first());
      }
    } else if (legalValues.contains(defaultValue.toLowerCase())) {
      this.defaultValue = legalValueClass.get(defaultValue.toLowerCase());
    } else {
      throw new OptionException("The default value '"+defaultValue+"' is not a legal value for the '"+getName()+"' option. ");
    }
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

   * @param classname  the fully qualified name of the class
   * @throws OptionException
   */
  public void addLegalValue(String value, String desc, String classname) throws MaltChainedException {
    if (value == null || value.equals("")) {
      throw new OptionException("The legal value is missing for the '"+getName()+"' option. ");
    } else if (legalValues.contains(value.toLowerCase())) {
      throw new OptionException("The legal value for the '"+getName()+"' option already exists. ");
    } else {
      legalValues.add(value.toLowerCase());
      if (desc == null || desc.equals("")) {
        legalValueDesc.put(value.toLowerCase(), "Description is missing. ");
      } else {
        legalValueDesc.put(value.toLowerCase(), desc);
      }
      if (classname == null || classname.equals("")) {
        throw new OptionException("The class name used by the '"+getName()+"' option is missing. ");
      } else {
        try {
          Class<?> clazz = null;
          if (PluginLoader.instance() != null) {
            clazz = PluginLoader.instance().getClass(classname);
          }
          if (clazz == null) {
            clazz = Class.forName(classname);
          }
          legalValueClass.put(value, clazz);
          classLegalValues.put(clazz, value);
        } catch (ClassNotFoundException e) {
          throw new OptionException("The class "+classname+" for the '"+getName()+"' option could not be found. ", e);
        }
      }
    }
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

    if (value == null) {
      return null;
    } else if (legalValues.contains(value)) {
      return new String(value);
    } else {
      throw new OptionException("'"+value+"' is not a legal value for the '"+getName()+"' option. ");
   
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

   * @see org.maltparser.core.options.option.Option#setDefaultValue(java.lang.String)
   */
  public void setDefaultValue(String defaultValue) throws MaltChainedException {
    if (defaultValue == null) {
      if (legalValues.isEmpty()) {
        throw new OptionException("The default value of the '"+getName()+"' option is null and the legal value set is empty.");
      } else {
        this.defaultValue = legalValues.first();
      }
    } else if (legalValues.contains(defaultValue.toLowerCase())) {
      this.defaultValue = defaultValue.toLowerCase();
    } else {
      throw new OptionException("The default value '"+defaultValue+"' for the '"+getName()+"' option is not a legal value. ");
    }
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

   * @param desc  a short description of the legal value
   * @throws OptionException
   */
  public void addLegalValue(String value, String desc) throws MaltChainedException {
    if (value == null || value.equals("")) {
      throw new OptionException("The legal value is missing for the '"+getName()+"' option. ");
    } else if (legalValues.contains(value.toLowerCase())) {
      throw new OptionException("The legal value '"+value+"' already exists for the '"+getName()+"' option. ");
    } else {
      legalValues.add(value.toLowerCase());
      if (desc == null || desc.equals("")) {
        legalValueDesc.put(value.toLowerCase(), "Description is missing. ");
      } else {
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

    if (value.equalsIgnoreCase("true")) {
      return new Boolean(true);
    } else if (value.equalsIgnoreCase("false")) {
      return new Boolean(false);
    } else {
      throw new OptionException("Illegal boolean value '"+value+"' for the '"+getName()+"' option. ");
    }
  }
View Full Code Here

Examples of org.maltparserx.core.options.OptionException

    if (defaultValue.equalsIgnoreCase("true")) {
      this.defaultValue = true;
    } else if (defaultValue.equalsIgnoreCase("false")) {
      this.defaultValue = false;
    } else {
      throw new OptionException("Illegal boolean default value '"+defaultValue+"' for the '"+getName()+"' option. ");
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.