Package com.beust.jcommander

Examples of com.beust.jcommander.ParameterException


  @Override
  public Long convert(String value) {
    try {
      return Long.parseLong(value);
    } catch(NumberFormatException ex) {
      throw new ParameterException(getErrorString(value, "a long"));
    }
  }
View Full Code Here


      m_properties = new Properties();
      URL url = ClassLoader.getSystemResource(fileName);
      if (url != null) {
        m_properties.load(url.openStream());
      } else {
        throw new ParameterException("Could not find property file: " + fileName
            + " on the class path");
      }
    }
    catch (IOException e) {
      throw new ParameterException("Could not open property file: " + fileName);
    }
  }
View Full Code Here

  @Override
  public Boolean convert(String value) {
    if ("false".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value)) {
      return Boolean.parseBoolean(value);
    } else {
      throw new ParameterException(getErrorString(value, "a boolean"));
    }
  }
View Full Code Here

  @Override
  public Integer convert(String value) {
    try {
      return Integer.parseInt(value);
    } catch(NumberFormatException ex) {
      throw new ParameterException(getErrorString(value, "an integer"));
    }
  }
View Full Code Here

  @Override
  public Long convert(String value) {
    try {
      return Long.parseLong(value);
    } catch(NumberFormatException ex) {
      throw new ParameterException(getErrorString(value, "a long"));
    }
  }
View Full Code Here

        @Override
        public void validate(String name, String value) throws ParameterException {
            File file = new File(value);
            if ( ! file.isFile()) {
                String msg = String.format("%s: '%s' is not a file.", name, value);
                throw new ParameterException(msg);
            }
            if ( ! file.canRead()) {
                String msg = String.format("%s: file '%s' is not readable.", name, value);
                throw new ParameterException(msg);
            }
        }
View Full Code Here

        @Override
        public void validate(String name, String value) throws ParameterException {
            File file = new File(value);
            if ( ! file.isDirectory()) {
                String msg = String.format("%s: '%s' is not a directory.", name, value);
                throw new ParameterException(msg);
            }
            if ( ! file.canRead()) {
                String msg = String.format("%s: directory '%s' is not readable.", name, value);
                throw new ParameterException(msg);
            }
        }
View Full Code Here

        public void validate(String name, String value) throws ParameterException {
            new ReadableDirectory().validate(name, value);
            File file = new File(value);
            if ( ! file.canWrite()) {
                String msg = String.format("%s: directory '%s' is not writable.", name, value);
                throw new ParameterException(msg);
            }
        }
View Full Code Here

        @Override
        public void validate(String name, String value) throws ParameterException {
            Integer i = Integer.parseInt(value);
            if ( i <= 0 ) {
                String msg = String.format("%s must be a positive integer.", name);
                throw new ParameterException(msg);
            }
        }
View Full Code Here

                    }
                }
            }
            if ( portUnavailable ) {
                String msg = String.format(": port %d is not available. %s.", port, reason);
                throw new ParameterException(msg);
            }
        }
View Full Code Here

TOP

Related Classes of com.beust.jcommander.ParameterException

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.