1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2016 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.http2.frames; 20 21 import java.util.HashMap; 22 import java.util.Map; 23 24 public enum FrameType 25 { 26 DATA(0), 27 HEADERS(1), 28 PRIORITY(2), 29 RST_STREAM(3), 30 SETTINGS(4), 31 PUSH_PROMISE(5), 32 PING(6), 33 GO_AWAY(7), 34 WINDOW_UPDATE(8), 35 CONTINUATION(9), 36 // Synthetic frames only needed by the implementation. 37 PREFACE(10), 38 DISCONNECT(11); 39 40 public static FrameType from(int type) 41 { 42 return Types.types.get(type); 43 } 44 45 private final int type; 46 47 private FrameType(int type) 48 { 49 this.type = type; 50 Types.types.put(type, this); 51 } 52 53 public int getType() 54 { 55 return type; 56 } 57 58 private static class Types 59 { 60 private static final Map<Integer, FrameType> types = new HashMap<>(); 61 } 62 }