View Javadoc

1   /*
2    * Copyright (c) 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * 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,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.eclipse.jetty.spdy.frames;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  public enum ControlFrameType
23  {
24      SYN_STREAM((short)1),
25      SYN_REPLY((short)2),
26      RST_STREAM((short)3),
27      SETTINGS((short)4),
28      NOOP((short)5),
29      PING((short)6),
30      GO_AWAY((short)7),
31      HEADERS((short)8),
32      WINDOW_UPDATE((short)9);
33  
34      public static ControlFrameType from(short code)
35      {
36          return Codes.codes.get(code);
37      }
38  
39      private final short code;
40  
41      private ControlFrameType(short code)
42      {
43          this.code = code;
44          Codes.codes.put(code, this);
45      }
46  
47      public short getCode()
48      {
49          return code;
50      }
51  
52      private static class Codes
53      {
54          private static final Map<Short, ControlFrameType> codes = new HashMap<>();
55      }
56  }