@BeforeClass public static void setUpBeforeClass() throws Exception { sbu = new SevenBullUploader( X.getConfig("sevenbull.test.accessKey"), X.getConfig("sevenbull.test.secretKey")); sbu2 = new SevenBullUploader( "UIgBw7sNUlZ1ANb0GpLeydDrY8T59cpRGTDut0c2", "9uk-Ap8N9D7zQL2aOvEGygEYZTa4Cruu_yj1LXEO"); }
/** * set the value to target by method m using reflection automatic type parse for String>Date * String>Integer String>Long String>Double * * @param m * @param value * @param target */ private static void setValue(Method m, Object value, Object target) { if (value == null) { return; } Object v = null; // Parsing the data type if (value.getClass().equals(m.getParameterTypes()[0])) { v = value; } else if (value instanceof String) { if (Date.class.equals(m.getParameterTypes()[0])) { v = X.string2date((String) value, X.TIMEA); } else if (Integer.class.equals(m.getParameterTypes()[0])) { v = Integer.parseInt((String) value); } else if (Long.class.equals(m.getParameterTypes()[0])) { v = Long.parseLong((String) value); } else if (Double.class.equals(m.getParameterTypes()[0])) { v = Double.parseDouble((String) value); } } if (v != null) { try { // invoke the setter m.invoke(target, v); } catch (Exception e) { e.printStackTrace(); } } }