001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/HttpResponse.java $
003: * $Revision: 573864 $
004: * $Date: 2007-09-08 17:53:25 +0200 (Sat, 08 Sep 2007) $
005: *
006: * ====================================================================
007: * Licensed to the Apache Software Foundation (ASF) under one
008: * or more contributor license agreements. See the NOTICE file
009: * distributed with this work for additional information
010: * regarding copyright ownership. The ASF licenses this file
011: * to you under the Apache License, Version 2.0 (the
012: * "License"); you may not use this file except in compliance
013: * with the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing,
018: * software distributed under the License is distributed on an
019: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020: * KIND, either express or implied. See the License for the
021: * specific language governing permissions and limitations
022: * under the License.
023: * ====================================================================
024: *
025: * This software consists of voluntary contributions made by many
026: * individuals on behalf of the Apache Software Foundation. For more
027: * information on the Apache Software Foundation, please see
028: * <http://www.apache.org/>.
029: *
030: */
031:
032: package org.apache.http;
033:
034: import java.util.Locale;
035:
036: /**
037: * An HTTP response.
038: *
039: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
040: *
041: * @version $Revision: 573864 $
042: *
043: * @since 4.0
044: */
045: public interface HttpResponse extends HttpMessage {
046:
047: /**
048: * Obtains the status line of this response.
049: * The status line can be set using on of the
050: * {@link #setStatusLine setStatusLine} methods,
051: * or it can be initialized in a constructor.
052: *
053: * @return the status line, or <code>null</code> if not yet set
054: */
055: StatusLine getStatusLine();
056:
057: /**
058: * Sets the status line of this response.
059: *
060: * @param statusline the status line of this response
061: */
062: void setStatusLine(StatusLine statusline);
063:
064: /**
065: * Sets the status line of this response.
066: * The reason phrase will be determined based on the current
067: * {@link #getLocale locale}.
068: *
069: * @param ver the HTTP version
070: * @param code the status code
071: */
072: void setStatusLine(ProtocolVersion ver, int code);
073:
074: /**
075: * Sets the status line of this response with a reason phrase.
076: *
077: * @param ver the HTTP version
078: * @param code the status code
079: * @param reason the reason phrase, or <code>null</code> to omit
080: */
081: void setStatusLine(ProtocolVersion ver, int code, String reason);
082:
083: /**
084: * Updates the status line of this response with a new status code.
085: * The status line can only be updated if it is available. It must
086: * have been set either explicitly or in a constructor.
087: * <br/>
088: * The reason phrase will be updated according to the new status code,
089: * based on the current {@link #getLocale locale}. It can be set
090: * explicitly using {@link #setReasonPhrase setReasonPhrase}.
091: *
092: * @param code the HTTP status code.
093: *
094: * @throws IllegalStateException
095: * if the status line has not be set
096: *
097: * @see HttpStatus
098: * @see #setStatusLine(StatusLine)
099: * @see #setStatusLine(ProtocolVersion,int)
100: */
101: void setStatusCode(int code) throws IllegalStateException;
102:
103: /**
104: * Updates the status line of this response with a new reason phrase.
105: * The status line can only be updated if it is available. It must
106: * have been set either explicitly or in a constructor.
107: *
108: * @param reason the new reason phrase as a single-line string, or
109: * <code>null</code> to unset the reason phrase
110: *
111: * @throws IllegalStateException
112: * if the status line has not be set
113: *
114: * @see #setStatusLine(StatusLine)
115: * @see #setStatusLine(ProtocolVersion,int)
116: */
117: void setReasonPhrase(String reason) throws IllegalStateException;
118:
119: /**
120: * Obtains the message entity of this response, if any.
121: * The entity is provided by calling {@link #setEntity setEntity}.
122: *
123: * @return the response entity, or
124: * <code>null</code> if there is none
125: */
126: HttpEntity getEntity();
127:
128: /**
129: * Associates a response entity with this response.
130: *
131: * @param entity the entity to associate with this response, or
132: * <code>null</code> to unset
133: */
134: void setEntity(HttpEntity entity);
135:
136: /**
137: * Obtains the locale of this response.
138: * The locale is used to determine the reason phrase
139: * for the {@link #setStatusCode status code}.
140: * It can be changed using {@link #setLocale setLocale}.
141: *
142: * @return the locale of this response, never <code>null</code>
143: */
144: Locale getLocale();
145:
146: /**
147: * Changes the locale of this response.
148: * If there is a status line, it's reason phrase will be updated
149: * according to the status code and new locale.
150: *
151: * @param loc the new locale
152: *
153: * @see #getLocale getLocale
154: * @see #setStatusCode setStatusCode
155: */
156: void setLocale(Locale loc);
157: }
|