Package net.thauvin.erik.httpstatus
Class Reasons
java.lang.Object
net.thauvin.erik.httpstatus.Reasons
Loads HTTP status reason phrases from the resource bundle and provides
lookup utilities for individual status codes and status code classes.
The reason phrases are stored in a sorted, immutable map for predictable iteration order and thread‑safe access.
-
Method Summary
Modifier and TypeMethodDescriptiongetReasonClass(StatusCodeClass reasonClass) Returns all reason phrases belonging to the given status code class.getReasonPhrase(int statusCode) Returns the reason phrase for the given status code, or null if none exists.static StringgetReasonPhrase(int statusCode, String defaultReason) Returns the reason phrase for the given status code, or the provided default value if no phrase is defined.getReasonPhrase(String statusCode) Returns the reason phrase for the given status code, or null if none exists.static StringgetReasonPhrase(String statusCode, String defaultReason) Returns the reason phrase for the given status code, or the provided default value if no phrase is defined.static voidPrints reason phrases for the given status code(s) or status code class(es).
-
Method Details
-
getReasonClass
Returns all reason phrases belonging to the given status code class.The returned map is sorted by status code.
- Parameters:
reasonClass- the status code class to look up- Returns:
- a sorted map of status codes to reason phrases for the given class
-
getReasonPhrase
Returns the reason phrase for the given status code, or null if none exists.- Parameters:
statusCode- the HTTP status code- Returns:
- the reason phrase, or
nullif none exists
-
getReasonPhrase
Returns the reason phrase for the given status code, or null if none exists.- Parameters:
statusCode- the HTTP status code as a string- Returns:
- the reason phrase, or
nullif none exists
-
getReasonPhrase
Returns the reason phrase for the given status code, or the provided default value if no phrase is defined.- Parameters:
statusCode- the HTTP status codedefaultReason- the default reason phrase to return if none exists- Returns:
- the reason phrase, or
defaultReasonif none exists
-
getReasonPhrase
Returns the reason phrase for the given status code, or the provided default value if no phrase is defined.- Parameters:
statusCode- the HTTP status code as a stringdefaultReason- the default reason phrase to return if none exists- Returns:
- the reason phrase, or
defaultReasonif none exists
-
main
Prints reason phrases for the given status code(s) or status code class(es).If no arguments are provided, prints all reason phrases.
- Parameters:
args- the status codes or status code classes to print (e.g., "404", "2xx")
-