Package org.maltparserx.core.options

Examples of org.maltparserx.core.options.OptionException


   * @param name the name of the option.
   * @throws OptionException
   */
  public void setName(String name) throws MaltChainedException {
    if (name == null || name.length() == 0) {
      throw new OptionException("The option name has no value. ")
    }
    this.name = name.toLowerCase();
  }
View Full Code Here


    } else if (usage.toLowerCase().equals("both")) {
      this.usage = Option.BOTH;
    } else if (usage.toLowerCase().equals("save")) {
      this.usage = Option.SAVE;
    } else {
      throw new OptionException("Illegal use of the usage attibute value: "+usage+" for the '"+getName()+"' option. ");
    }
  }
View Full Code Here

   */
  public void setUsage(int usage) throws MaltChainedException {
    if (usage >= 0 && usage <= 4) {
      this.usage = usage;
    } else {
      throw new OptionException("Illegal use of the usage attibute value: "+usage+" for the '"+getName()+"' option. ");
    }
  }
View Full Code Here

   */
  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

   */
  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

    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

   * @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

   * @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

    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

   * @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

TOP

Related Classes of org.maltparserx.core.options.OptionException

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.