Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
 public String To_str(Object o) {
   if (o == null) return "<<NULL>>";
   Class<?> type = Type_adp_.ClassOf_obj(o);
   String rv = null;
   if (type == String.class) rv = String_.cast(o);
   else if (Int_.TypeMatch(type)) return Int_.To_str(Int_.cast(o));
   else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) return Yn.To_str(Bool_.cast(o));
   else if (type == DateAdp.class) return DateAdp_.cast(o).XtoStr_gplx();
   else rv = Object_.Xto_str_strict_or_empty(o);
   return String_.Replace(rv, "'", "''");
 }