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    *   https://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  package io.netty.handler.codec.stomp;
17  
18  import io.netty.handler.codec.Headers;
19  import io.netty.util.AsciiString;
20  
21  import java.util.Iterator;
22  import java.util.List;
23  import java.util.Map.Entry;
24  
25  /**
26   * The multimap data structure for the STOMP header names and values. It also provides the constants for the standard
27   * STOMP header names and values.
28   */
29  public interface StompHeaders extends Headers<CharSequence, CharSequence, StompHeaders> {
30  
31      AsciiString ACCEPT_VERSION = AsciiString.cached("accept-version");
32      AsciiString HOST = AsciiString.cached("host");
33      AsciiString LOGIN = AsciiString.cached("login");
34      AsciiString PASSCODE = AsciiString.cached("passcode");
35      AsciiString HEART_BEAT = AsciiString.cached("heart-beat");
36      AsciiString VERSION = AsciiString.cached("version");
37      AsciiString SESSION = AsciiString.cached("session");
38      AsciiString SERVER = AsciiString.cached("server");
39      AsciiString DESTINATION = AsciiString.cached("destination");
40      AsciiString ID = AsciiString.cached("id");
41      AsciiString ACK = AsciiString.cached("ack");
42      AsciiString TRANSACTION = AsciiString.cached("transaction");
43      AsciiString RECEIPT = AsciiString.cached("receipt");
44      AsciiString MESSAGE_ID = AsciiString.cached("message-id");
45      AsciiString SUBSCRIPTION = AsciiString.cached("subscription");
46      AsciiString RECEIPT_ID = AsciiString.cached("receipt-id");
47      AsciiString MESSAGE = AsciiString.cached("message");
48      AsciiString CONTENT_LENGTH = AsciiString.cached("content-length");
49      AsciiString CONTENT_TYPE = AsciiString.cached("content-type");
50  
51      /**
52       * {@link Headers#get(Object)} and convert the result to a {@link String}.
53       * @param name the name of the header to retrieve
54       * @return the first header value if the header is found. {@code null} if there's no such header.
55       */
56      String getAsString(CharSequence name);
57  
58      /**
59       * {@link Headers#getAll(Object)} and convert each element of {@link List} to a {@link String}.
60       * @param name the name of the header to retrieve
61       * @return a {@link List} of header values or an empty {@link List} if no values are found.
62       */
63      List<String> getAllAsString(CharSequence name);
64  
65      /**
66       * {@link #iterator()} that converts each {@link Entry}'s key and value to a {@link String}.
67       */
68      Iterator<Entry<String, String>> iteratorAsString();
69  
70      /**
71       * Returns {@code true} if a header with the {@code name} and {@code value} exists, {@code false} otherwise.
72       * <p>
73       * If {@code ignoreCase} is {@code true} then a case insensitive compare is done on the value.
74       * @param name the name of the header to find
75       * @param value the value of the header to find
76       * @param ignoreCase {@code true} then a case insensitive compare is run to compare values.
77       * otherwise a case sensitive compare is run to compare values.
78       */
79      boolean contains(CharSequence name, CharSequence value, boolean ignoreCase);
80  }