interface MeinInterface {
void doFoo();
// enthaelt die Methoden ohne DE oder EN
}
class DEImpl implements MeinInterface {
void doFoo() {
// do foo for DE
}
// enthaelt die spezielle Implementierungen der Methoden für DE
}
class ENImpl implements MeinInterface {
void doFoo() {
// do foo for EN
}
// enthaelt die spezielle Implementierungen der Methoden für EN
}
class MeineFactory {
static MeinInterface create(String token) {
if (token.equals("de")) {
return new DEImpl();
} else if (token.equals("en")) {
return new ENImpl();
}
}
}
String[] array = new String[]{"de", "en"};
for(int i = 0; i < array.length; i ++) {
String token = array[i];
MeinInterface intf = MeineFactory.create(token);
intf.doFoo();
// hier die Methoden aufrufen, die Du brauchst, aber ohne Länderkürzel
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("startMonth",startMonth);
map.put("endMonth",endMonth);
Class cls = Class.forName("com.ef.cms.statistics.downloads.DownloadsManager");
Class param = HashMap.class;
String[] spArray = {"At", "Bn", "Ch", "De", "Fr", "Pt" };
Method execution;
for (int i = 0; i< spArray.length; i++) {
execution = cls.getMethod("select"+spArray[i]+"Date",param);
Object arg = {map};
downloadsAllList = (List<DownloadsBean>) execution.invoke(arg);
pageTotal = pageTotal + downloadsAllList.size();
}