View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package io.netty.handler.codec;
18  
19  /**
20   * A typical string multimap used by text protocols such as HTTP for the representation of arbitrary key-value data. One
21   * thing to note is that it uses {@link CharSequence} as its primary key and value type rather than {@link String}. When
22   * you invoke the operations that produce {@link String}s such as {@link #get(Object)}, a {@link CharSequence} is
23   * implicitly converted to a {@link String}. This is particularly useful for speed optimization because this multimap
24   * can hold a special {@link CharSequence} implementation that a codec can treat specially, such as {@link CharSequence}
25   * .
26   */
27  public interface TextHeaders extends ConvertibleHeaders<CharSequence, String> {
28      /**
29       * A visitor that helps reduce GC pressure while iterating over a collection of {@link Headers}.
30       */
31      interface EntryVisitor extends Headers.EntryVisitor<CharSequence> {
32      }
33  
34      /**
35       * A visitor that helps reduce GC pressure while iterating over a collection of {@link Headers}.
36       */
37      interface NameVisitor extends Headers.NameVisitor<CharSequence> {
38      }
39  
40      /**
41       * Returns {@code true} if a header with the name and value exists.
42       * @param name the header name
43       * @param value the header value
44       * @return {@code true} if it contains it {@code false} otherwise
45       */
46      boolean contains(CharSequence name, CharSequence value, boolean ignoreCase);
47  
48      /**
49       * Returns {@code true} if a header with the name and value exists.
50       * @param name the header name
51       * @param value the header value
52       * @return {@code true} if it contains it {@code false} otherwise
53       */
54      boolean containsObject(CharSequence name, Object value, boolean ignoreCase);
55  
56      @Override
57      TextHeaders add(CharSequence name, CharSequence value);
58  
59      @Override
60      TextHeaders add(CharSequence name, Iterable<? extends CharSequence> values);
61  
62      @Override
63      TextHeaders add(CharSequence name, CharSequence... values);
64  
65      @Override
66      TextHeaders addObject(CharSequence name, Object value);
67  
68      @Override
69      TextHeaders addObject(CharSequence name, Iterable<?> values);
70  
71      @Override
72      TextHeaders addObject(CharSequence name, Object... values);
73  
74      @Override
75      TextHeaders addBoolean(CharSequence name, boolean value);
76  
77      @Override
78      TextHeaders addByte(CharSequence name, byte value);
79  
80      @Override
81      TextHeaders addChar(CharSequence name, char value);
82  
83      @Override
84      TextHeaders addShort(CharSequence name, short value);
85  
86      @Override
87      TextHeaders addInt(CharSequence name, int value);
88  
89      @Override
90      TextHeaders addLong(CharSequence name, long value);
91  
92      @Override
93      TextHeaders addFloat(CharSequence name, float value);
94  
95      @Override
96      TextHeaders addDouble(CharSequence name, double value);
97  
98      @Override
99      TextHeaders addTimeMillis(CharSequence name, long value);
100 
101     /**
102      * See {@link Headers#add(Headers)}
103      */
104     TextHeaders add(TextHeaders headers);
105 
106     @Override
107     TextHeaders set(CharSequence name, CharSequence value);
108 
109     @Override
110     TextHeaders set(CharSequence name, Iterable<? extends CharSequence> values);
111 
112     @Override
113     TextHeaders set(CharSequence name, CharSequence... values);
114 
115     @Override
116     TextHeaders setObject(CharSequence name, Object value);
117 
118     @Override
119     TextHeaders setObject(CharSequence name, Iterable<?> values);
120 
121     @Override
122     TextHeaders setObject(CharSequence name, Object... values);
123 
124     @Override
125     TextHeaders setBoolean(CharSequence name, boolean value);
126 
127     @Override
128     TextHeaders setByte(CharSequence name, byte value);
129 
130     @Override
131     TextHeaders setChar(CharSequence name, char value);
132 
133     @Override
134     TextHeaders setShort(CharSequence name, short value);
135 
136     @Override
137     TextHeaders setInt(CharSequence name, int value);
138 
139     @Override
140     TextHeaders setLong(CharSequence name, long value);
141 
142     @Override
143     TextHeaders setFloat(CharSequence name, float value);
144 
145     @Override
146     TextHeaders setDouble(CharSequence name, double value);
147 
148     @Override
149     TextHeaders setTimeMillis(CharSequence name, long value);
150 
151     /**
152      * See {@link Headers#set(Headers)}
153      */
154     TextHeaders set(TextHeaders headers);
155 
156     /**
157      * See {@link Headers#setAll(Headers)}
158      */
159     TextHeaders setAll(TextHeaders headers);
160 
161     @Override
162     TextHeaders clear();
163 }