HttpStatus.java
/***************************************************************************
Copyright 2009 Emily Estes
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***************************************************************************/
package net.metanotion.web;
/** Enumeration of commonly used HTTP status codes.
All provide the "codeNumber" method to return the numerical status code.
This is a utility enumeration and not required by the framework.
*/
public enum HttpStatus {
OK { @Override public int codeNumber() { return 200; } },
CREATED { @Override public int codeNumber() { return 201; } },
ACCEPTED { @Override public int codeNumber() { return 202; } },
NO_CONTENT { @Override public int codeNumber() { return 204; } },
REDIRECT_PERMANENT { @Override public int codeNumber() { return 301; } },
REDIRECT_FOUND { @Override public int codeNumber() { return 302; } },
REDIRECT_SEE_OTHER { @Override public int codeNumber() { return 303; } },
NOT_MODIFIED { @Override public int codeNumber() { return 304; } },
REDIRECT_TEMPORARY { @Override public int codeNumber() { return 307; } },
BAD_REQUEST { @Override public int codeNumber() { return 400; } },
UNAUTHORIZED { @Override public int codeNumber() { return 401; } },
FORBIDDEN { @Override public int codeNumber() { return 403; } },
NOT_FOUND { @Override public int codeNumber() { return 404; } },
METHOD_NOT_ALLOWED { @Override public int codeNumber() { return 405; } },
REQUEST_TIMEOUT { @Override public int codeNumber() { return 408; } },
CONFLICT { @Override public int codeNumber() { return 409; } },
GONE { @Override public int codeNumber() { return 410; } },
REQUEST_TOO_LARGE { @Override public int codeNumber() { return 413; } },
URI_TOO_LONG { @Override public int codeNumber() { return 414; } },
UNSUPPORTED_MEDIA_TYPE { @Override public int codeNumber() { return 415; } },
TEAPOT { @Override public int codeNumber() { return 418; } },
ENHANCE_YOUR_CALM { @Override public int codeNumber() { return 420; } },
SEMANTIC_ERROR { @Override public int codeNumber() { return 422; } },
TOO_MANY_REQUESTS { @Override public int codeNumber() { return 429; } },
SERVER_ERROR { @Override public int codeNumber() { return 500; } },
NOT_IMPLEMENTED { @Override public int codeNumber() { return 501; } },
INSUFFICIENT_STORAGE { @Override public int codeNumber() { return 507; } };
/** Return an integer representation of the HTTP status.
@return The integer represetation.
*/
public abstract int codeNumber();
}