Пример #1
0
 /**
  * The method is called by an option implementation when there is a problem parsing the value for
  * an option supplied by the user on the command line. For example, if an integer is not in the
  * correct format, this method will be called, which will report an error.
  *
  * @param name the name of the option
  * @param type the value type
  * @param val the (invalid) value passed
  */
 protected void parseError(String name, String type, String val) {
   Util.userError(
       "Option Error",
       "invalid value for "
           + type
           + " option "
           + StringUtil.quote(name)
           + " = "
           + StringUtil.quote(val));
 }
Пример #2
0
    /**
     * The <code>set()</code> method updates the value of the option.
     *
     * @param val a string representation of the new value of the option.
     */
    @Override
    public void set(String val) {
      CharacterIterator iter = new StringCharacterIterator(val);
      try {
        // check for leading [
        if (!StringUtil.peekAndEat(iter, '[')) parseError(name, "interval", val);

        String lstr = StringUtil.readDecimalString(iter, 12);
        low = java.lang.Long.parseLong(lstr);

        // check for ',' separator
        if (!StringUtil.peekAndEat(iter, ',')) parseError(name, "interval", val);

        String hstr = StringUtil.readDecimalString(iter, 12);
        high = java.lang.Long.parseLong(hstr);

        // check for trailing ]
        if (!StringUtil.peekAndEat(iter, ']')) parseError(name, "interval", val);

      } catch (NumberFormatException e) {
        // in case of NumberFormatException
        parseError(name, "interval", val);
      }
    }
Пример #3
0
 private void parseString(String val) {
   orig = val;
   value = StringUtil.toList(val);
 }
Пример #4
0
 /**
  * The <code>printDescription()</code> method prints out a well-formatted representation of the
  * description of the item to the terminal.
  */
 public void printDescription() {
   Terminal.print(StringUtil.formatParagraphs(description, 8, 0, Terminal.MAXLINE));
   Terminal.nextln();
 }
Пример #5
0
 public Unexpected(Throwable t) {
   super(StringUtil.quote(t.getClass()));
   thrown = t;
 }