2
* $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0.1/httpcore/src/main/java/org/apache/http/message/BasicStatusLine.java $
4
* $Date: 2008-12-21 18:59:05 +0100 (Sun, 21 Dec 2008) $
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
15
* http://www.apache.org/licenses/LICENSE-2.0
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
23
* ====================================================================
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/>.
32
package org.apache.http.message;
34
import org.apache.http.ProtocolVersion;
35
import org.apache.http.StatusLine;
38
* Basic implementation of {@link StatusLine}
40
* @version $Id: BasicStatusLine.java 728464 2008-12-21 17:59:05Z olegk $
44
public class BasicStatusLine implements StatusLine, Cloneable {
46
// ----------------------------------------------------- Instance Variables
48
/** The protocol version. */
49
private final ProtocolVersion protoVersion;
51
/** The status code. */
52
private final int statusCode;
54
/** The reason phrase. */
55
private final String reasonPhrase;
57
// ----------------------------------------------------------- Constructors
59
* Creates a new status line with the given version, status, and reason.
61
* @param version the protocol version of the response
62
* @param statusCode the status code of the response
63
* @param reasonPhrase the reason phrase to the status code, or
66
public BasicStatusLine(final ProtocolVersion version, int statusCode,
67
final String reasonPhrase) {
69
if (version == null) {
70
throw new IllegalArgumentException
71
("Protocol version may not be null.");
74
throw new IllegalArgumentException
75
("Status code may not be negative.");
77
this.protoVersion = version;
78
this.statusCode = statusCode;
79
this.reasonPhrase = reasonPhrase;
82
// --------------------------------------------------------- Public Methods
84
public int getStatusCode() {
85
return this.statusCode;
88
public ProtocolVersion getProtocolVersion() {
89
return this.protoVersion;
92
public String getReasonPhrase() {
93
return this.reasonPhrase;
96
public String toString() {
97
// no need for non-default formatting in toString()
98
return BasicLineFormatter.DEFAULT
99
.formatStatusLine(null, this).toString();
102
public Object clone() throws CloneNotSupportedException {
103
return super.clone();