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

clime.messadmin.providers.spi.BaseTabularApplicationDataProvider 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;

import java.text.NumberFormat;

import javax.servlet.ServletContext;

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

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

	/**
	 * @param context
	 * @return application-specific data labels for given Application, or null if it can be determined
	 */
	public abstract String[] getApplicationTabularDataLabels(final ServletContext context);
	/**
	 * @param context
	 * @return application-specific data values for given Application, or null if it can be determined
	 */
	public abstract Object[][] getApplicationTabularData(final ServletContext context);

	protected String getTableCaption(String[] labels, Object[][] values) {
		NumberFormat numberFormatter = NumberFormat.getNumberInstance();
		return ""+numberFormatter.format(values.length)+" application-specific attributes";
	}

	/**
	 * {@inheritDoc}
	 */
	public String getXHTMLApplicationData(ServletContext context) {
		try {
			String[] labels = getApplicationTabularDataLabels(context);
			Object[][] values = getApplicationTabularData(context);
			return buildXHTML(labels, values, "extraApplicationAttributesTable-"+getClass().getName(), getTableCaption(labels, values));
		} catch (RuntimeException rte) {
			return "Error in " + this.getClass().getName() + ": " + rte;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy