Examples of BadParameterException


Examples of com.dottydingo.hyperion.exception.BadParameterException

                return (T) Long.valueOf(argument);
            }
        }
        catch (IllegalArgumentException ex)
        {
            throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()));
        }

        // date
        if (type.equals(Date.class))
        {
            try
            {
                return (T) dateParser.parseDateTime(argument).toDate();
            }
            catch (IllegalArgumentException ex1)
            {
                throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()));
            }
        }

        // try to parse via valueOf(String s) method
        try
        {
            logger.debug("Trying to get and invoke valueOf(String s) method on {}", type);
            Method method = type.getMethod("valueOf", String.class);
            return (T) method.invoke(type, argument);

        }
        catch (NoSuchMethodException ex)
        {
            logger.warn("{} does not have method valueOf(String s)", type);
        }
        catch (Exception ex)
        {
            throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()),ex);
        }

        throw new BadParameterException(String.format("Could not convert \"%s\" to a %s",argument,type.getSimpleName()));
    }
View Full Code Here

Examples of org.commonlib.comunication.BadParameterException

        break;
      case 8:
        databit = SerialPort.DATABITS_8;
        break;
      default:
        throw new BadParameterException("illegal value for databit=" + pdatabit);
    }

    switch(pstopbit)
    {
      case 1:
        stopbit = SerialPort.STOPBITS_1;
        break;
      case 2:
        stopbit = SerialPort.STOPBITS_2;
        break;
      default:
        throw new BadParameterException("illegal value for stopbit=" + pstopbit);
    }

    switch(pparita)
    {
      case 'N':
        parita = SerialPort.PARITY_NONE;
        break;
      case 'P':
      case 'E':
        parita = SerialPort.PARITY_EVEN;
        break;
      case 'D':
      case 'O':
        parita = SerialPort.PARITY_ODD;
        break;
      case 'M':
        parita = SerialPort.PARITY_MARK;
        break;
      case 'S':
        parita = SerialPort.PARITY_SPACE;
        break;
      default:
        throw new BadParameterException("illegal value for parity=" + pparita);
    }

    switch(pflowctl)
    {
      case 'N':
        flowctl = SerialPort.FLOWCONTROL_NONE;
        break;
      case 'X':
        flowctl = SerialPort.FLOWCONTROL_XONXOFF_IN | SerialPort.FLOWCONTROL_XONXOFF_OUT;
        break;
      case 'R':
        flowctl = SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT;
        break;
      default:
        throw new BadParameterException("illegal value for flow control=" + pflowctl);
    }

    this.bdrate = pbdrate;
  }
View Full Code Here

Examples of org.commonlib.comunication.BadParameterException

        break;
      case 8:
        databit = SerialPort.DATABITS_8;
        break;
      default:
        throw new BadParameterException("illegal value for databit=" + pdatabit);
    }

    switch(pstopbit)
    {
      case 1:
        stopbit = SerialPort.STOPBITS_1;
        break;
      case 2:
        stopbit = SerialPort.STOPBITS_2;
        break;
      default:
        throw new BadParameterException("illegal value for stopbit=" + pstopbit);
    }

    switch(pparita)
    {
      case 'N':
        parita = SerialPort.PARITY_NONE;
        break;
      case 'P':
      case 'E':
        parita = SerialPort.PARITY_EVEN;
        break;
      case 'D':
      case 'O':
        parita = SerialPort.PARITY_ODD;
        break;
      case 'M':
        parita = SerialPort.PARITY_MARK;
        break;
      case 'S':
        parita = SerialPort.PARITY_SPACE;
        break;
      default:
        throw new BadParameterException("illegal value for parity=" + pparita);
    }

    switch(pflowctl)
    {
      case 'N':
        flowctl = SerialPort.FLOWCONTROL_NONE;
        break;
      case 'X':
        flowctl = SerialPort.FLOWCONTROL_XONXOFF_IN | SerialPort.FLOWCONTROL_XONXOFF_OUT;
        break;
      case 'R':
        flowctl = SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT;
        break;
      default:
        throw new BadParameterException("illegal value for flow control=" + pflowctl);
    }

    this.bdrate = pbdrate;
  }
View Full Code Here

Examples of org.commonlib.comunication.BadParameterException

        break;
      case SerialPort.DATABITS_8:
        arCmd.add("cs8");
        break;
      default:
        throw new BadParameterException("illegal value for databit=" + databit);
    }

    switch(stopbit)
    {
      case SerialPort.STOPBITS_1:
        arCmd.add("-cstopb");
        break;
      case SerialPort.STOPBITS_2:
        arCmd.add("cstopb");
        break;
      default:
        throw new BadParameterException("illegal value for stopbit=" + stopbit);
    }

    switch(parita)
    {
      case SerialPort.PARITY_NONE:
        arCmd.add("ignpar");
        arCmd.add("-parenb");
        break;
      case SerialPort.PARITY_EVEN:
        arCmd.add("parenb");
        arCmd.add("-parodd");
        break;
      case SerialPort.PARITY_ODD:
        arCmd.add("parenb");
        arCmd.add("parodd");
        break;
      case SerialPort.PARITY_MARK:
        arCmd.add("parmrk");
        break;
      default:
        throw new BadParameterException("illegal value for parity=" + parita);
    }

    if((flowctl & SerialPort.FLOWCONTROL_XONXOFF_IN) != 0
       || (flowctl & SerialPort.FLOWCONTROL_XONXOFF_OUT) != 0)
    {
View Full Code Here

Examples of ru.org.linux.site.BadParameterException

          @RequestParam("reason") String reason,
          @RequestParam(value = "bonus", defaultValue = "0") int bonus,
          HttpServletRequest request
  ) throws Exception {
    if (bonus < 0 || bonus > 20) {
      throw new BadParameterException("неправильный размер штрафа");
    }

    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isSessionAuthorized()) {
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.