return data;
}
static public String toCsvFormat(Object input) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
StringWriter writer = new StringWriter();
CSVWriter csvPrinter = new CSVWriter(writer);
Class<? extends Object> c = input.getClass();
Method methods[] = c.getMethods();
Vector<String> v = new Vector<String>();
for (Method method : methods) {
if (!method.getName().startsWith("get")) {
continue;
}
Object object = method.invoke(input, (Object[]) null);
if (object == null) {
v.add("");
}
else {
String value = "Unknown type for " + method.getName();
if (object instanceof String) {
value = (String) object;
}
if (object instanceof Integer) {
value = ((Integer) object).toString();
}
if (object instanceof Float) {
value = ((Float) object).toString();
}
if (object instanceof Double) {
value = ((Float) object).toString();
}
if (object instanceof Date) {
value = Format.getDate((Date) object);
}
v.add(value);
}
}
String tokens[] = new String[v.size()];
v.copyInto(tokens);
csvPrinter.writeNext(tokens);
return writer.toString();
}