

package protocol;

/**
 * 
 * @author Chandan R. Rupakheti (rupakhcr@clarkson.edu)
 */
public class HttpStatusCode {

	// Successful status codes
	public static final HttpStatusCode OK = Create(200, "OK");
	public static final HttpStatusCode CREATED = Create(201, "Created");
	public static final HttpStatusCode NO_CONTENT = Create(204, "No Content");

	public static final HttpStatusCode NOT_MODIFIED = Create(304,
			"Not Modified");

	// 4xx indicates error on user/client side
	public static final HttpStatusCode BAD_REQUEST = Create(400, "Bad Request");
	public static final HttpStatusCode NOT_FOUND = Create(404, "Not Found");
	public static final HttpStatusCode METHOD_NOT_ALLOWED = Create(405,
			"Method Not Allowed");
	public static final HttpStatusCode LENGTH_REQUIRED = Create(411,
			"Length Required");
	public static final HttpStatusCode USER_ERROR = Create(445,
			"The provided content was unacceptable.");
	public static final HttpStatusCode TEAPOT = Create(418, "I'm a Teapot");

	// 5xx indicates internal failure
	public static final HttpStatusCode INTERNAL_ERROR = Create(500,
			"Internal Server Error");

	private int statusCode;
	private String codeMessage;

	public HttpStatusCode(int code, String message) {
		statusCode = code;
		codeMessage = message;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public String getStatusMessage() {
		return codeMessage;
	}

	/**
	 * Not currently in use, but can be used to return a default page for
	 * certain status codes.
	 * 
	 * For example, a 404 could have a custom (fancy) page.
	 * 
	 * @return
	 */
	public String getPathToDefaultFile() {
		return null;
	}

	private static HttpStatusCode Create(int code, String message) {
		return new HttpStatusCode(code, message);
	}
}
