Package com.beust.jcommander

Examples of com.beust.jcommander.ParameterException


    @Override
    public void validate(String name, String value) throws ParameterException {
      try {
        int batch = Integer.parseInt(value);
        if(batch < 0) {
          throw new ParameterException("Parameter " + name + " should be non-negative number.");
        }
      } catch (NumberFormatException e) {
        throw new ParameterException("Parameter " + name + " should be non-negative number.");
      }

    }
View Full Code Here


            try {
                for (String Kstr : value) {
                    final int K = Integer.parseInt(Kstr);
                    if (ParameterChecker.isNumSourceSymbolsPerBlockOutOfBounds(K)) {
                        throw new ParameterException(String.format(
                            "Number of source symbols (%d) must be within [%d, %d]",
                            K,
                            ParameterChecker.minNumSourceSymbolsPerBlock(),
                            ParameterChecker.maxNumSourceSymbolsPerBlock()));
                    }
                }
            }
            catch (NumberFormatException e) {
                throw new ParameterException("Invalid number of source symbols: " + e.getMessage());
            }
        }
View Full Code Here

        @Override
        public void validate(@SuppressWarnings("unused") String name, Integer value) throws ParameterException {

            if (ParameterChecker.isSymbolSizeOutOfBounds(value)) {
                throw new ParameterException(String.format(
                    "Symbol size (%d) must be within [%d, %d] bytes",
                    value,
                    ParameterChecker.minSymbolSize(),
                    ParameterChecker.maxSymbolSize()));
            }
View Full Code Here

                for (String symboverStr : value) {
                    NON_NEGATIVE_VALIDATOR.validate(name, Integer.valueOf(symboverStr));
                }
            }
            catch (NumberFormatException e) {
                throw new ParameterException("Invalid symbol overhead: " + e.getMessage());
            }
        }
View Full Code Here

        @Override
        public void validate(String name, Integer value) throws ParameterException {

            if (value < 0) {
                throw new ParameterException("Option \"" + name + "\": number must be non-negative");
            }
        }
View Full Code Here

      BufferedReader in = new BufferedReader(isr);
      String result = in.readLine();
      return result.toCharArray();
    }
    catch (IOException e) {
      throw new ParameterException(e);
    }
  }
View Full Code Here

            final Matcher httpMatcher = HTTP_DOCUMENT_PATTERN.matcher(value);
            if (httpMatcher.find()) {
                try {
                    return new HTTPDocumentSource(DefaultHTTPClient.createInitializedHTTPClient(), value);
                } catch ( URISyntaxException e ) {
                    throw new ParameterException("Invalid source URI: '" + value + "'");
                }
            }
            final Matcher fileMatcher = FILE_DOCUMENT_PATTERN.matcher(value);
            if (fileMatcher.find()) {
                return new FileDocumentSource( new File( fileMatcher.group(1) ) );
            }
            throw new ParameterException("Invalid source protocol: '" + value + "'");
        }
View Full Code Here

      writer.flush();
      Method readPasswordMethod = console.getClass().getDeclaredMethod("readPassword", new Class<?>[0]);
      return (char[]) readPasswordMethod.invoke(console, new Object[0]);
    }
    catch (Exception e) {
      throw new ParameterException(e);
    }
  }
View Full Code Here

      in.close();
      isr.close();
      return result.toCharArray();
    }
    catch (IOException e) {
      throw new ParameterException(e);
    }
  }
View Full Code Here

            final Matcher httpMatcher = HTTP_DOCUMENT_PATTERN.matcher(value);
            if (httpMatcher.find()) {
                try {
                    return new HTTPDocumentSource(DefaultHTTPClient.createInitializedHTTPClient(), value);
                } catch ( URISyntaxException e ) {
                    throw new ParameterException("Invalid source URI: '" + value + "'");
                }
            }
            final Matcher fileMatcher = FILE_DOCUMENT_PATTERN.matcher(value);
            if (fileMatcher.find()) {
                return new FileDocumentSource( new File( fileMatcher.group(1) ) );
            }
            throw new ParameterException("Invalid source protocol: '" + value + "'");
        }
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.