• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/message/BasicStatusLine.java $
3  * $Revision: 604625 $
4  * $Date: 2007-12-16 06:11:11 -0800 (Sun, 16 Dec 2007) $
5  *
6  * ====================================================================
7  * Licensed to the Apache Software Foundation (ASF) under one
8  * or more contributor license agreements.  See the NOTICE file
9  * distributed with this work for additional information
10  * regarding copyright ownership.  The ASF licenses this file
11  * to you under the Apache License, Version 2.0 (the
12  * "License"); you may not use this file except in compliance
13  * with the License.  You may obtain a copy of the License at
14  *
15  *   http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing,
18  * software distributed under the License is distributed on an
19  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20  * KIND, either express or implied.  See the License for the
21  * specific language governing permissions and limitations
22  * under the License.
23  * ====================================================================
24  *
25  * This software consists of voluntary contributions made by many
26  * individuals on behalf of the Apache Software Foundation.  For more
27  * information on the Apache Software Foundation, please see
28  * <http://www.apache.org/>.
29  *
30  */
31 
32 package org.apache.http.message;
33 
34 import org.apache.http.HttpStatus;
35 import org.apache.http.ProtocolVersion;
36 import org.apache.http.StatusLine;
37 
38 
39 
40 /**
41  * Represents a status line as returned from a HTTP server.
42  * See <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a> section 6.1.
43  * This class is immutable and therefore inherently thread safe.
44  *
45  * @see HttpStatus
46  * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
47  * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
48  *
49  * @version $Id: BasicStatusLine.java 604625 2007-12-16 14:11:11Z olegk $
50  *
51  * @since 4.0
52  *
53  * @deprecated Please use {@link java.net.URL#openConnection} instead.
54  *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
55  *     for further details.
56  */
57 @Deprecated
58 public class BasicStatusLine implements StatusLine, Cloneable {
59 
60     // ----------------------------------------------------- Instance Variables
61 
62     /** The protocol version. */
63     private final ProtocolVersion protoVersion;
64 
65     /** The status code. */
66     private final int statusCode;
67 
68     /** The reason phrase. */
69     private final String reasonPhrase;
70 
71     // ----------------------------------------------------------- Constructors
72     /**
73      * Creates a new status line with the given version, status, and reason.
74      *
75      * @param version           the protocol version of the response
76      * @param statusCode        the status code of the response
77      * @param reasonPhrase      the reason phrase to the status code, or
78      *                          <code>null</code>
79      */
BasicStatusLine(final ProtocolVersion version, int statusCode, final String reasonPhrase)80     public BasicStatusLine(final ProtocolVersion version, int statusCode,
81                            final String reasonPhrase) {
82         super();
83         if (version == null) {
84             throw new IllegalArgumentException
85                 ("Protocol version may not be null.");
86         }
87         if (statusCode < 0) {
88             throw new IllegalArgumentException
89                 ("Status code may not be negative.");
90         }
91         this.protoVersion = version;
92         this.statusCode   = statusCode;
93         this.reasonPhrase = reasonPhrase;
94     }
95 
96     // --------------------------------------------------------- Public Methods
97 
98     /**
99      * @return the Status-Code
100      */
getStatusCode()101     public int getStatusCode() {
102         return this.statusCode;
103     }
104 
105     /**
106      * @return the HTTP-Version
107      */
getProtocolVersion()108     public ProtocolVersion getProtocolVersion() {
109         return this.protoVersion;
110     }
111 
112     /**
113      * @return the Reason-Phrase
114      */
getReasonPhrase()115     public String getReasonPhrase() {
116         return this.reasonPhrase;
117     }
118 
toString()119     public String toString() {
120         // no need for non-default formatting in toString()
121         return BasicLineFormatter.DEFAULT
122             .formatStatusLine(null, this).toString();
123     }
124 
clone()125     public Object clone() throws CloneNotSupportedException {
126         return super.clone();
127     }
128 
129 }
130