Example #1
0
 public static void Val_by_obj(Db_stmt stmt, String key, Object val) {
   int tid = Type_adp_.To_tid_obj(val);
   switch (tid) {
     case Type_adp_.Tid__bool:
       stmt.Val_bool_as_byte(key, Bool_.cast(val));
       break;
     case Type_adp_.Tid__byte:
       stmt.Val_byte(key, Byte_.cast(val));
       break;
     case Type_adp_.Tid__int:
       stmt.Val_int(key, Int_.cast(val));
       break;
     case Type_adp_.Tid__long:
       stmt.Val_long(key, Long_.cast(val));
       break;
     case Type_adp_.Tid__float:
       stmt.Val_float(key, Float_.cast(val));
       break;
     case Type_adp_.Tid__double:
       stmt.Val_double(key, Double_.cast(val));
       break;
     case Type_adp_.Tid__str:
       stmt.Val_str(key, String_.cast(val));
       break;
     case Type_adp_.Tid__bry:
       stmt.Val_bry(key, Bry_.cast(val));
       break;
     default:
       throw Err_.new_unhandled_default(tid);
   }
 }
Example #2
0
 public float ReadFloatOr(String k, float or) {
   Object rv = ReadOr(k, or);
   if (rv == Nil) return or;
   return parse ? Float_.parse((String) rv) : Float_.cast(rv);
 }
Example #3
0
 public float ReadFloat(String k) {
   Object rv = ReadOr(k, 0);
   if (rv == Nil) ThrowNotFound(k);
   return parse ? Float_.parse((String) rv) : Float_.cast(rv);
 }
Example #4
0
 public static String CalcPctStr(long dividend, long divisor, String fmt) {
   if (divisor == 0) return "%ERR";
   return DecimalAdp_.float_(Float_.Div(dividend, divisor) * 100).Xto_str(fmt) + "%";
 }