View Javadoc

1   /*******************************************************************************
2    * Copyright (c) 2011 Michael Mimo Moratti.
3    *  
4    * Michael Mimo Moratti licenses this file to you under the Apache License, version 2.0
5    * (the "License"); you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at:
7    *     http://www.apache.org/licenses/LICENSE-2.0
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
11   * License for the specific language governing permissions and limitations
12   * under the License.
13   *******************************************************************************/
14  package ch.mimo.netty.handler.codec.icap;
15  
16  import org.jboss.netty.buffer.ChannelBuffer;
17  import org.jboss.netty.util.internal.StringUtil;
18  
19  /**
20   * Main Icap Response implementation. This is the starting point to create any Icap response.
21   * 
22   * @author Michael Mimo Moratti (mimo@mimo.ch)
23   *
24   */
25  public class DefaultIcapResponse extends AbstractIcapMessage implements IcapResponse {
26  
27  	private IcapResponseStatus status;
28  	private ChannelBuffer optionsContent;
29  	
30  	/**
31  	 * Will create an instance of IcapResponse.
32  	 * 
33  	 * @param version the version of the response.
34  	 * @param status the Status code that has to be reported back. (200 OK...)
35  	 */
36  	public DefaultIcapResponse(IcapVersion version, IcapResponseStatus status) {
37  		super(version);
38  		this.status = status;
39  	}
40  
41  	@Override
42  	public void setStatus(IcapResponseStatus status) {
43  		this.status = status;
44  	}
45  
46  	@Override
47  	public IcapResponseStatus getStatus() {
48  		return status;
49  	}
50  
51  	public void setContent(ChannelBuffer optionsContent) {
52  		this.optionsContent = optionsContent;
53  	}
54  
55  	public ChannelBuffer getContent() {
56  		return optionsContent;
57  	}
58  
59  	@Override
60  	public String toString() {
61  		return super.toString() + StringUtil.NEWLINE + "Response Status: " + status.name();
62  	}
63  }