Package com.meidusa.amoeba.sqljep

Examples of com.meidusa.amoeba.sqljep.ParseException


        long l1 = ((Number)param1).longValue();
        long l2 = ((Number)param2).longValue();
        return l1 % l2;
      }
    } else {
      throw new ParseException(WRONG_TYPE+"  ("+param1.getClass()+"%"+param2.getClass()+")");
    }
  }
View Full Code Here


      }
      BigDecimal b1 = getBigDecimal((Number)param1);
      BigDecimal b2 = getBigDecimal((Number)param2);
      return b1.divide(b2, 40, BigDecimal.ROUND_HALF_UP);
    } else {
      throw new ParseException(WRONG_TYPE+"  ("+param1.getClass()+"/"+param2.getClass()+")");
    }
  }
View Full Code Here

      return new Double(Math.abs(((Number)param).doubleValue()));
    }
    if (param instanceof Number) {    // Long, Integer, Short, Byte
      return new Long(Math.abs(((Number)param).longValue()));
    }
    throw new ParseException(WRONG_TYPE+" abs("+param.getClass()+")");
  }
View Full Code Here

      return null;
    }
    if (param1 instanceof Boolean && param2 instanceof Boolean) {
      return (((Boolean)param1).booleanValue()) && (((Boolean)param2).booleanValue());
    }
    throw new ParseException(WRONG_TYPE+ param1.getClass()+" and "+ param2.getClass());
  }
View Full Code Here

        if (d.scale() < 0) {
          d = d.setScale(0);
        }
        return d;
      } catch (NumberFormatException ex) {
        throw new ParseException(param+" Not a number");
      }
    }
  }
View Full Code Here

    else if (param instanceof String) {
      try {
        BigDecimal d = new BigDecimal((String)param);
        return d.intValueExact();
      } catch (Exception e) {
        throw new ParseException("Cant parse integer: '"+(String)param+"'");
      }
    }
    throw new ParseException("Not Integer: "+(param != null ? param.getClass() : "null"));
  }
View Full Code Here

    }
    else if (param instanceof String) {
      try {
        return Double.valueOf((String)param);
      } catch (NumberFormatException e) {
        throw new ParseException("Cant parse double: '"+(String)param+"'");
      }
    }
    throw new ParseException("Not Double: "+(param != null ? param.getClass() : "null"));
  }
View Full Code Here

        int p2 = i;
        if (param1 instanceof BigDecimal) {
          try {
            return ((BigDecimal)param1).pow(p2);
          } catch (ArithmeticException e) {
            throw new ParseException(e.getMessage());
          }
        }
        if (param1 instanceof Double || param1 instanceof Float) {
          return Math.pow(((Number)param1).doubleValue(), p2);
        } else {
          long l1 = ((Number)param1).longValue();
          long res = l1;
          for (; p2 > 1; p2--) {
            long old = res;
            res *= l1;
            if (res < old) {
              return Math.pow(l1, p2);
            }
          }
          if (res >= 0) {
            return res;
          }
        }
      }
      throw new ParseException("Power should be integer value");
    } else {
      throw new ParseException(WRONG_TYPE+"  power("+param1.getClass()+","+param2.getClass()+")");
    }
  }
View Full Code Here

      Comparable<?>  param1 = runtime.stack.pop();
      return new Comparable<?>[]{param1,param2};
    } else {
      // remove all parameters from stack and push null
      removeParams(runtime.stack, num);
      throw new ParseException(PARAMS_NUMBER+" for ltrim");
    }
  }
View Full Code Here

        }
      }
    }
    else if (param1 instanceof Timestamp || param2 instanceof Timestamp) {
      if (param1 instanceof Timestamp && param2 instanceof Timestamp) {
        throw new ParseException(DATE_ADDITION);
      }
      Timestamp d;
      Number n;
      if (param1 instanceof Timestamp) {
        d = (Timestamp)param1;
        if (param2 instanceof Number) {
          n = (Number)param2;
        } else {
          throw new ParseException(DATE_ADDITION);
        }
        return new Timestamp(d.getTime()+toDay(n));
      }
      else if (param2 instanceof Timestamp) {
        d = (Timestamp)param2;
        if (param1 instanceof Number) {
          n = (Number)param1;
        } else {
          throw new ParseException(DATE_ADDITION);
        }
        return new Timestamp(d.getTime()+toDay(n));
      }
      throw new ParseException(INTERNAL_ERROR);
    } else {
      throw new ParseException(WRONG_TYPE+"  ("+param1.getClass()+"+"+param2.getClass()+")");
    }
  }
View Full Code Here

TOP

Related Classes of com.meidusa.amoeba.sqljep.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.