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

org.bitbucket.gkutiel.in.my.mind.handler.Textual Maven / Gradle / Ivy

The newest version!
package org.bitbucket.gkutiel.in.my.mind.handler;

import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
import java.io.UnsupportedEncodingException;
import org.bitbucket.gkutiel.in.Handler;
import com.google.common.base.Strings;

public abstract class Textual extends Handler {

	protected abstract String getContentType();
	protected abstract String getText();

	@Override public final void handle() {
		try {
			res().getHeaders().addHeader(CONTENT_TYPE, getContentType() + ";charset=utf-8");
			res().writeBytes(Strings.nullToEmpty(getText()).getBytes("utf-8"));
		} catch (final UnsupportedEncodingException e) {
			throw new RuntimeException(e);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy