Examples of ParameterException


Examples of cn.com.byd.exceptions.ParameterException

        int idx = 0;
        for (ParameterType paraType : parameters) {
            if (!StringUtil.isEmptyAndNull(paraType.getReferenceValue())) {
                obj = methodContext.getIdValue(paraType.getReferenceValue());
                if (!paraType.getClazz().equals(obj.getClass())) {
                    throw new ParameterException("parameter type not matching.args[" + idx + "],expect " + paraType.getClazz());
                }
                args[idx++] = obj;
            } else if (paraType.getBeanFieldMap() != null && !paraType.getBeanFieldMap().isEmpty()) {
                Map<String, Object> mapValue = new HashMap<String, Object>();
                for (String key : paraType.getBeanFieldMap().keySet()) {
View Full Code Here

Examples of cn.com.byd.exceptions.ParameterException

     * @param arges
     * @throws ParameterException
     */
    public void checkParameters(Object... arges) throws ParameterException {
        if (arges.length != parameters.size()) {
            throw new ParameterException("parameter not matching.");
        }
        int idx = 0;
        // 验证参数类型是否一致
        for (Object obj : arges) {
            if (!obj.getClass().equals(parameters.get(idx).getClazz())) {
                throw new ParameterException("parameter[" + idx + "] type not matching.");
            }
            idx++;
        }
    }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

    public static class ValidateRequiredValue implements IParameterValidator {
        @Override
        public void validate (String name, String value) throws ParameterException {
            if (value == null || value.isEmpty()) {
                // this should never happen because jcommander bug
                throw new ParameterException("Expected a value after parameter " + name);
            }
            if (value.startsWith("-") && !value.equals("--")) {
                throw new ParameterException("Expected a value after parameter " + name + ". Looks like argument " + value);
            }
        }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

  public static class NamedLikeRFile implements IParameterValidator {
    @Override
    public void validate(String name, String value) throws ParameterException {
      if (!value.endsWith(".rf")) {
        throw new ParameterException("File must end with .rf and '" + value + "' does not.");
      }
    }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

  public static class IsSupportedCompressionAlgorithm implements IParameterValidator {
    @Override
    public void validate(String name, String value) throws ParameterException {
      String[] algorithms = TFile.getSupportedCompressionAlgorithms();
      if (!((Arrays.asList(algorithms)).contains(value))) {
        throw new ParameterException("Compression codec must be one of " + Arrays.toString(TFile.getSupportedCompressionAlgorithms()));
      }
    }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

public class FileExistsValidator implements IParameterValidator {

    @Override
    public void validate(String name, String value) throws ParameterException {
        if (!new File(value).exists()) {
            throw new ParameterException("File with path [" + value + "] specified in [" + name + "] does not exist");
        }

    }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

        @Override
        public Pattern convert( String value ) {
            try {
                return Pattern.compile( value );
            } catch (PatternSyntaxException pse) {
                throw new ParameterException( format("Invalid page filter, '%s' must be a regular expression.", value) );
            }
        }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

            uri = uri.trim();
            if (uri.toLowerCase().startsWith("http:") || uri.toLowerCase().startsWith("https:")) {
                try {
                    return new URL(uri).toString();
                } catch (MalformedURLException murle) {
                    throw new ParameterException(format("Invalid URI: '%s': %s", uri, murle.getMessage()));
                }
            }

            final File f = new File(uri);
            if (!f.exists()) {
                throw new ParameterException(format("No such file: [%s]", f.getAbsolutePath()));
            }
            if (f.isDirectory()) {
                throw new ParameterException(format("Found a directory: [%s]", f.getAbsolutePath()));
            }
            return f.toURI().toString();
        }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

        public PrintStream convert( String value ) {
            final File file = new File(value);
            try {
                return new PrintStream(file);
            } catch (FileNotFoundException fnfe) {
                throw new ParameterException(format("Cannot open file '%s': %s", file, fnfe.getMessage()));
            }
        }
View Full Code Here

Examples of com.beust.jcommander.ParameterException

    try {
      boolean hasToken = (token != null);
      boolean hasTokenOptions = !loginOptions.isEmpty();

      if (hasToken && password != null) {
        throw new ParameterException("Can not supply '--pass' option with '--tokenClass' option");
      }

      Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
          reader.getTerminal().setEchoEnabled(true);
        }
      });

      // Need either both a token and options, or neither, but not just one.
      if (hasToken != hasTokenOptions) {
        throw new ParameterException("Must supply either both or neither of '--tokenClass' and '--tokenProperty'");
      } else if (hasToken) { // implied hasTokenOptions
        // Fully qualified name so we don't shadow java.util.Properties
        org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties props;
        // and line wrap it because the package name is so long
        props = new org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties();

        props.putAllStrings(loginOptions);
        token.init(props);
      } else {
        // Read password if the user explicitly asked for it, or didn't specify anything at all
        if ("stdin".equals(password) || password == null) {
          password = reader.readLine("Password: ", '*');
        }

        if (password == null) {
          // User cancel, e.g. Ctrl-D pressed
          throw new ParameterException("No password or token option supplied");
        } else {
          this.token = new PasswordToken(password);
        }
      }

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.