View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.spdy.frames;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  public enum ControlFrameType
25  {
26      SYN_STREAM((short)1),
27      SYN_REPLY((short)2),
28      RST_STREAM((short)3),
29      SETTINGS((short)4),
30      NOOP((short)5),
31      PING((short)6),
32      GO_AWAY((short)7),
33      HEADERS((short)8),
34      WINDOW_UPDATE((short)9),
35      CREDENTIAL((short)10);
36  
37      public static ControlFrameType from(short code)
38      {
39          return Codes.codes.get(code);
40      }
41  
42      private final short code;
43  
44      private ControlFrameType(short code)
45      {
46          this.code = code;
47          Codes.codes.put(code, this);
48      }
49  
50      public short getCode()
51      {
52          return code;
53      }
54  
55      private static class Codes
56      {
57          private static final Map<Short, ControlFrameType> codes = new HashMap<>();
58      }
59  }