Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/TestReflection.java

95 lines
2.9 KiB
Java

import it.acxent.cc.Attivita;
import it.acxent.db.ApplParm;
import it.acxent.db.ApplParmFull;
import it.acxent.db.CRAdapter;
import it.acxent.db.DBAdapter;
import it.acxent.util.DbConsole;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Date;
import java.sql.Time;
public class TestReflection extends DbConsole {
public static void main(String[] args) {
new TestReflection().test();
}
private static boolean isNotEmpty(Object valueUpd, Class<?> tipo) {
boolean ret = false;
if (valueUpd != null) {
String sclass = valueUpd.getClass().getName();
if (sclass.indexOf("Long") > 0 || sclass.indexOf("Double") > 0 || sclass.indexOf("String") > 0 || sclass.indexOf("Date") > 0 ||
sclass.indexOf("Time") > 0)
if (tipo.getName() == "long") {
if ((Long)valueUpd == 0L || (Long)valueUpd == -1L) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName() == "double") {
if ((Double)valueUpd == 0.0D) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName().indexOf("String") > 0) {
if (((String)valueUpd).equals("") || ((String)valueUpd).isEmpty()) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName().indexOf("Date") > 0) {
Date data = (Date)valueUpd;
if (data == null) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName().indexOf("Time") > 0) {
if ((Time)valueUpd == null) {
ret = false;
} else {
ret = true;
}
}
}
return ret;
}
private static Object getFunctionName(String functionName, Class<?> tipo, CRAdapter thiss) {
Object value = null;
try {
Method method = thiss.getClass().getMethod(functionName);
value = method.invoke(thiss);
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {}
return value;
}
public void test() {
String db = "fotoeventi4";
int i = 0;
int se1 = 10;
int se2 = 100;
String hostname = "localhost:3308";
String temp = getCi().readLine("Hostname (" + hostname + "):");
if (!temp.isEmpty())
hostname = temp;
temp = getCi().readLine("Database name (" + db + "):");
if (!temp.isEmpty())
db = temp;
System.out.println("Db: " + db);
ApplParm ap = new ApplParm(17, "//" + hostname + "/" + db, db, "root", "root", 1, 10, 300);
ApplParmFull apTarget = new ApplParmFull(ap);
apTarget.setDebug(false);
Attivita attivita = new Attivita(apTarget);
DBAdapter.checkSerializable(attivita);
}
}