FileDocCategorySizeDatePackage
EnglishReasonPhraseCatalog.javaAPI DocAndroid 1.5 API8590Wed May 06 22:41:10 BST 2009org.apache.http.impl

EnglishReasonPhraseCatalog

public class EnglishReasonPhraseCatalog extends Object implements ReasonPhraseCatalog
English reason phrases for HTTP status codes. All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and RFC2518 (WebDAV) are supported.
author
Unascribed
author
Mike Bowler
author
Jeff Dever
version
$Revision: 505744 $

Fields Summary
public static final EnglishReasonPhraseCatalog
INSTANCE
The default instance of this catalog. This catalog is thread safe, so there typically is no need to create other instances.
private static final String[]
REASON_PHRASES
Reason phrases lookup table.
Constructors Summary
protected EnglishReasonPhraseCatalog()
Restricted default constructor, for derived classes. If you need an instance of this class, use {@link #INSTANCE INSTANCE}.



                           
      
        // no body
    
Methods Summary
public java.lang.StringgetReason(int status, java.util.Locale loc)
Obtains the reason phrase for a status code.

param
status the status code, in the range 100-599
param
loc ignored
return
the reason phrase, or null

        if ((status < 100) || (status >= 600)) {
            throw new IllegalArgumentException
                ("Unknown category for status code " + status + ".");
        }

        final int category = status / 100;
        final int subcode  = status - 100*category;

        String reason = null;
        if (REASON_PHRASES[category].length > subcode)
            reason = REASON_PHRASES[category][subcode];

        return reason;
    
private static voidsetReason(int status, java.lang.String reason)
Stores the given reason phrase, by status code. Helper method to initialize the static lookup table.

param
status the status code for which to define the phrase
param
reason the reason phrase for this status code




                                                   
           
        final int category = status / 100;
        final int subcode  = status - 100*category;
        REASON_PHRASES[category][subcode] = reason;