1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.handler.codec.http;
18
19 import java.util.Collections;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.Map.Entry;
23 import java.util.Set;
24
25 public class EmptyHttpHeaders extends HttpHeaders {
26 static final Iterator<Entry<CharSequence, CharSequence>> EMPTY_CHARS_ITERATOR =
27 Collections.<Entry<CharSequence, CharSequence>>emptyList().iterator();
28
29 public static final EmptyHttpHeaders INSTANCE = instance();
30
31
32
33
34
35
36
37
38 @Deprecated
39 static EmptyHttpHeaders instance() {
40 return InstanceInitializer.EMPTY_HEADERS;
41 }
42
43 protected EmptyHttpHeaders() {
44 }
45
46 @Override
47 public String get(String name) {
48 return null;
49 }
50
51 @Override
52 public Integer getInt(CharSequence name) {
53 return null;
54 }
55
56 @Override
57 public int getInt(CharSequence name, int defaultValue) {
58 return defaultValue;
59 }
60
61 @Override
62 public Short getShort(CharSequence name) {
63 return null;
64 }
65
66 @Override
67 public short getShort(CharSequence name, short defaultValue) {
68 return defaultValue;
69 }
70
71 @Override
72 public Long getTimeMillis(CharSequence name) {
73 return null;
74 }
75
76 @Override
77 public long getTimeMillis(CharSequence name, long defaultValue) {
78 return defaultValue;
79 }
80
81 @Override
82 public List<String> getAll(String name) {
83 return Collections.emptyList();
84 }
85
86 @Override
87 public List<Entry<String, String>> entries() {
88 return Collections.emptyList();
89 }
90
91 @Override
92 public boolean contains(String name) {
93 return false;
94 }
95
96 @Override
97 public boolean isEmpty() {
98 return true;
99 }
100
101 @Override
102 public int size() {
103 return 0;
104 }
105
106 @Override
107 public Set<String> names() {
108 return Collections.emptySet();
109 }
110
111 @Override
112 public HttpHeaders add(String name, Object value) {
113 throw new UnsupportedOperationException("read only");
114 }
115
116 @Override
117 public HttpHeaders add(String name, Iterable<?> values) {
118 throw new UnsupportedOperationException("read only");
119 }
120
121 @Override
122 public HttpHeaders addInt(CharSequence name, int value) {
123 throw new UnsupportedOperationException("read only");
124 }
125
126 @Override
127 public HttpHeaders addShort(CharSequence name, short value) {
128 throw new UnsupportedOperationException("read only");
129 }
130
131 @Override
132 public HttpHeaders set(String name, Object value) {
133 throw new UnsupportedOperationException("read only");
134 }
135
136 @Override
137 public HttpHeaders set(String name, Iterable<?> values) {
138 throw new UnsupportedOperationException("read only");
139 }
140
141 @Override
142 public HttpHeaders setInt(CharSequence name, int value) {
143 throw new UnsupportedOperationException("read only");
144 }
145
146 @Override
147 public HttpHeaders setShort(CharSequence name, short value) {
148 throw new UnsupportedOperationException("read only");
149 }
150
151 @Override
152 public HttpHeaders remove(String name) {
153 throw new UnsupportedOperationException("read only");
154 }
155
156 @Override
157 public HttpHeaders clear() {
158 throw new UnsupportedOperationException("read only");
159 }
160
161 @Override
162 public Iterator<Entry<String, String>> iterator() {
163 return entries().iterator();
164 }
165
166 @Override
167 public Iterator<Entry<CharSequence, CharSequence>> iteratorCharSequence() {
168 return EMPTY_CHARS_ITERATOR;
169 }
170
171
172
173
174
175 @Deprecated
176 private static final class InstanceInitializer {
177
178
179
180
181
182 @Deprecated
183 private static final EmptyHttpHeaders EMPTY_HEADERS = new EmptyHttpHeaders();
184
185 private InstanceInitializer() {
186 }
187 }
188 }