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.stomp;
18  
19  import java.util.Iterator;
20  import java.util.List;
21  import java.util.Map.Entry;
22  
23  import io.netty.handler.codec.CharSequenceValueConverter;
24  import io.netty.handler.codec.DefaultHeaders;
25  import io.netty.handler.codec.HeadersUtils;
26  
27  import static io.netty.util.AsciiString.CASE_INSENSITIVE_HASHER;
28  import static io.netty.util.AsciiString.CASE_SENSITIVE_HASHER;
29  
30  public class DefaultStompHeaders
31          extends DefaultHeaders<CharSequence, CharSequence, StompHeaders> implements StompHeaders {
32      public DefaultStompHeaders() {
33          super(CASE_SENSITIVE_HASHER, CharSequenceValueConverter.INSTANCE);
34      }
35  
36      @Override
37      public String getAsString(CharSequence name) {
38          return HeadersUtils.getAsString(this, name);
39      }
40  
41      @Override
42      public List<String> getAllAsString(CharSequence name) {
43          return HeadersUtils.getAllAsString(this, name);
44      }
45  
46      @Override
47      public Iterator<Entry<String, String>> iteratorAsString() {
48          return HeadersUtils.iteratorAsString(this);
49      }
50  
51      @Override
52      public boolean contains(CharSequence name, CharSequence value) {
53          return contains(name, value, false);
54      }
55  
56      @Override
57      public boolean contains(CharSequence name, CharSequence value, boolean ignoreCase) {
58          return contains(name, value,
59                  ignoreCase ? CASE_INSENSITIVE_HASHER : CASE_SENSITIVE_HASHER);
60      }
61  
62      @Override
63      public DefaultStompHeaders copy() {
64          DefaultStompHeaders copyHeaders = new DefaultStompHeaders();
65          copyHeaders.addImpl(this);
66          return copyHeaders;
67      }
68  }