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 java.util.List; 17 import java.util.Map; 18 import java.util.Set; 19 20 /** 21 * Icap chunk trailer. 22 * In comparison to Http this will always be the last chunk in any transmission. With or without trailing 23 * hedaers. 24 * 25 * @author Michael Mimo Moratti (mimo@mimo.ch) 26 * 27 */ 28 public interface IcapChunkTrailer extends IcapChunk { 29 30 /** 31 * Always returns {@code true}. 32 */ 33 boolean isLast(); 34 35 /** 36 * Returns the trailing header value with the specified header name. 37 * If there are more than one trailing header value for the specified 38 * header name, the first value is returned. 39 * 40 * @return the header value or {@code null} if there is no such header 41 * 42 */ 43 String getHeader(String name); 44 45 /** 46 * Returns the trailing header values with the specified header name. 47 * 48 * @return the {@link List} of header values. An empty list if there is no 49 * such header. 50 */ 51 List<String> getHeaders(String name); 52 53 /** 54 * Returns the all header names and values that this trailer contains. 55 * 56 * @return the {@link List} of the header name-value pairs. An empty list 57 * if there is no header in this trailer. 58 */ 59 List<Map.Entry<String, String>> getHeaders(); 60 61 /** 62 * Returns {@code true} if and only if there is a trailing header with 63 * the specified header name. 64 */ 65 boolean containsHeader(String name); 66 67 /** 68 * Returns the {@link Set} of all trailing header names that this trailer 69 * contains. 70 */ 71 Set<String> getHeaderNames(); 72 73 /** 74 * Adds a new trailing header with the specified name and value. 75 */ 76 void addHeader(String name, Object value); 77 78 /** 79 * Sets a new trailing header with the specified name and value. 80 * If there is an existing trailing header with the same name, the existing 81 * one is removed. 82 */ 83 void setHeader(String name, Object value); 84 85 /** 86 * Sets a new trailing header with the specified name and values. 87 * If there is an existing trailing header with the same name, the existing 88 * one is removed. 89 */ 90 void setHeader(String name, Iterable<?> values); 91 92 /** 93 * Removes the trailing header with the specified name. 94 */ 95 void removeHeader(String name); 96 97 /** 98 * Removes all trailing headers from this trailer. 99 */ 100 void clearHeaders(); 101 }