no.hiof.dcon.HtmlConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of data-conversion-library Show documentation
Show all versions of data-conversion-library Show documentation
A library for data conversion.
The newest version!
package no.hiof.dcon;
import java.lang.reflect.Field;
/**
* This class is used to perform conversions with Html format.
*/
public class HtmlConverter {
private HtmlConverter() {
throw new UnsupportedOperationException("HtmlConverter is a utility class and should not be instantiated.");
}
/**
* Converts the given object to a Html file
*
* @param object The object to be converted to Bson document.
* @return A string with the html code.
*/
public static String htmlFromObject(Object object) {
Class> clazz = object.getClass();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("");
stringBuilder.append("").append(clazz.getSimpleName()).append(" ");
stringBuilder.append("");
stringBuilder.append("");
stringBuilder.append("Property Value ");
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
stringBuilder.append("");
stringBuilder.append("").append(field.getName()).append(" ");
try {
Object value = field.get(object);
stringBuilder.append("").append(value).append(" ");
} catch (Exception e) {
stringBuilder.append("").append("N/A").append(" ");
}
stringBuilder.append(" ");
}
stringBuilder.append("
");
stringBuilder.append("");
stringBuilder.append("");
return stringBuilder.toString();
}
}