All Downloads are FREE. Search and download functionalities are using the official Maven repository.

no.hiof.dcon.HtmlConverter Maven / Gradle / Ivy

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("");
        for (Field field : clazz.getDeclaredFields()) {
            field.setAccessible(true);
            stringBuilder.append("");
            stringBuilder.append("");
            try {
                Object value = field.get(object);
                stringBuilder.append("");
            } catch (Exception e) {
                stringBuilder.append("");
            }
            stringBuilder.append("");
        }
        stringBuilder.append("
PropertyValue
").append(field.getName()).append("").append(value).append("").append("N/A").append("
"); stringBuilder.append(""); stringBuilder.append(""); return stringBuilder.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy