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

clime.messadmin.providers.spi.BaseTabularSessionDataProvider 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.http.HttpSession;

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

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

	/**
	 * @param session
	 * @return application-specific data labels for given HttpSession, or null if it can be determined
	 */
	public abstract String[] getSessionTabularDataLabels(final HttpSession session);
	/**
	 * @param session
	 * @return application-specific data values for given HttpSession, or null if it can be determined
	 */
	public abstract Object[][] getSessionTabularData(final HttpSession session);

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

	/**
	 * {@inheritDoc}
	 */
	public String getXHTMLSessionData(HttpSession session) {
		try {
			String[] labels = getSessionTabularDataLabels(session);
			Object[][] values = getSessionTabularData(session);
			return buildXHTML(labels, values, "extraSessionAttributesTable-"+getClass().getName(), getTableCaption(labels, values));
		} catch (RuntimeException rte) {
			return "Error in " + this.getClass().getName() + ": " + rte;
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy