1 /* 2 * ==================================================================== 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * ==================================================================== 20 * 21 * This software consists of voluntary contributions made by many 22 * individuals on behalf of the Apache Software Foundation. For more 23 * information on the Apache Software Foundation, please see 24 * <http://www.apache.org/>. 25 * 26 */ 27 package org.apache.hc.core5.http2.config; 28 29 /** 30 * HTTP/2 protocol parameters. 31 * 32 * @since 5.0 33 */ 34 public enum H2Param { 35 36 HEADER_TABLE_SIZE (0x1), 37 ENABLE_PUSH (0x2), 38 MAX_CONCURRENT_STREAMS (0x3), 39 INITIAL_WINDOW_SIZE (0x4), 40 MAX_FRAME_SIZE (0x5), 41 MAX_HEADER_LIST_SIZE (0x6); 42 43 int code; 44 45 H2Param(final int code) { 46 this.code = code; 47 } 48 49 public int getCode() { 50 return code; 51 } 52 53 private static final H2Paramg/H2Param.html#H2Param">H2Param[] LOOKUP_TABLE = new H2Param[6]; 54 static { 55 for (final H2Param param: H2Param.values()) { 56 LOOKUP_TABLE[param.code - 1] = param; 57 } 58 } 59 60 public static H2Param valueOf(final int code) { 61 if (code < 1 || code > LOOKUP_TABLE.length) { 62 return null; 63 } 64 return LOOKUP_TABLE[code - 1]; 65 } 66 67 public static String toString(final int code) { 68 if (code < 1 || code > LOOKUP_TABLE.length) { 69 return Integer.toString(code); 70 } 71 return LOOKUP_TABLE[code - 1].name(); 72 } 73 74 }