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

clime.messadmin.providers.spi.BaseTabularDataProvider Maven / Gradle / Ivy

Go to download

Notification system and Session administration for J2EE Web Applications

There is a newer version: 4.1.1
Show newest version
/**
 * 
 */
package clime.messadmin.providers.spi;


/**
 * Base implementation class for DataProvider displaying tabular data.
 * @author Cédrik LIME
 */
public abstract class BaseTabularDataProvider {

	/**
	 * 
	 */
	public BaseTabularDataProvider() {
		super();
	}

//	/**
//	 * @param object
//	 * @return specific data labels for given object, or null if it can be determined
//	 */
//	public abstract String[] getTabularDataLabels(final Object object);
//	/**
//	 * @param object
//	 * @return specific data values for given object, or null if it can be determined
//	 */
//	public abstract Object[][] getTabularData(final Object object);
//
//	protected abstract String getTableCaption(String[] labels, Object[][] data);
//
//	protected String getXHTMLData(Object object) {
//		try {
//			String[] labels = getTabularDataLabels(object);
//			Object[][] values = getTabularData(object);
//			return buildXHTML(labels, values, tableId, getTableCaption(labels, values));
//		} catch (RuntimeException rte) {
//			return "Error in " + this.getClass().getName() + ": " + rte;
//		}
//	}

	protected String buildXHTML(String[] labels, Object[][] values, String tableId, String tableCaption) {
		if (labels == null || values == null || labels.length == 0 || values.length == 0) {
			return "";
		}
		StringBuffer buff = new StringBuffer(1024);
		buff.append("\n");
		buff.append("\n");
		buff.append("\n");
		for (int i = 0; i < labels.length; ++i) {
			String label = labels[i];
			buff.append("\n");
		}
		buff.append("\n");
		for (int i = 0; i < values.length; ++i) {
			Object[] raw = values[i];
			buff.append("\n");
			for (int j = 0; j < raw.length; ++j) {
				Object value = raw[j];
				buff.append("");
			}
			buff.append("\n");
		}
		buff.append("
").append(tableCaption).append("
").append(label).append("
"); if (value != null) { buff.append(""); buff.append(value); buff.append(""); } buff.append("
\n"); return buff.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy