Package com.martiansoftware.jsap

Examples of com.martiansoftware.jsap.ParseException


        } else {
          try {
            format = new SimpleDateFormat(formatString);
          }
          catch( RuntimeException e ) {
            throw new ParseException( e );
          }
        }
    }
View Full Code Here


        Date result = null;
        try {
            result = format.parse(arg);
        } catch (java.text.ParseException e) {
            throw (
                new ParseException(
                    "Unable to convert '" + arg + "' to a Date.",
                    e));
        }
        return (result);
    }
View Full Code Here

        Byte result = null;
        try {
            result = Byte.decode(arg);
        } catch (NumberFormatException e) {
            throw (
                new ParseException(
                    "Unable to convert '" + arg + "' to a Byte.",
                    e));
        }
        return (result);
    }
View Full Code Here

    return INSTANCE;
  }

  public Object parse( String arg ) throws ParseException {
    final long size = LongSizeStringParser.parseSize( arg );
    if ( size > Integer.MAX_VALUE ) throw new ParseException( "Integer size '" + arg + "' is too big." );
    return new Integer( (int)size );
  }
View Full Code Here

  public Object parse( String arg ) throws ParseException {
    try {
      return forName.invoke( klass, new Object[] { arg } );
    }
    catch ( Exception e ) {
      throw new ParseException ( e );
    }
  }
View Full Code Here

    }
    if (!isCaseSensitive) {
      arg = arg.toLowerCase();
    }
    if (!isValidOptionName(arg)) {
      throw new ParseException("Wrong character in command line option value for enumerated option: '" + arg + "'"
        +"\nallowed are alphanumeric characters + '$' and '_' sign only",
        new IllegalArgumentException());
    }
    // we cannot use Arrays.binarySearch() because strings cannot be
    // sorted according to the required natural order!
    if (Arrays.asList(validOptionValuesArray).contains(arg)) {
      return arg;
    }
    else {
      throw new ParseException("Option has wrong value '" + arg + "'"
        + "; valid values are: "+Arrays.asList(validOptionValuesArray), new IllegalArgumentException());
    }
  }
View Full Code Here

        Short result = null;
        try {
            result = Short.decode(arg);
        } catch (NumberFormatException e) {
            throw (
                new ParseException(
                    "Unable to convert '" + arg + "' to a Short.",
                    e));
        }
        return (result);
    }
View Full Code Here

        BigDecimal result = null;
        try {
            result = new BigDecimal(arg);
        } catch (NumberFormatException e) {
            throw (
                new ParseException(
                    "Unable to convert '" + arg + "' to a BigDecimal.",
                    e));
        }
        return (result);
    }
View Full Code Here

    public Object parse(String arg) throws ParseException {
        InetAddress result = null;
        try {
            result = InetAddress.getByName(arg);
        } catch (UnknownHostException e) {
            throw (new ParseException("Unknown host: " + arg, e));
        }
        return (result);
    }
View Full Code Here

        BigInteger result = null;
        try {
            result = new BigInteger(arg);
        } catch (NumberFormatException e) {
            throw (
                new ParseException(
                    "Unable to convert '" + arg + "' to a BigInteger.",
                    e));
        }
        return (result);
    }
View Full Code Here

TOP

Related Classes of com.martiansoftware.jsap.ParseException

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.