Home / Class/ Http2ExampleUtil Class — netty Architecture

Http2ExampleUtil Class — netty Architecture

Architecture documentation for the Http2ExampleUtil class in Http2ExampleUtil.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  2aef81fe_7774_536a_14b2_6a5f2d13b970["Http2ExampleUtil"]
  3acde661_7eed_ef16_7780_ee601c3a01f7["Http2ExampleUtil.java"]
  2aef81fe_7774_536a_14b2_6a5f2d13b970 -->|defined in| 3acde661_7eed_ef16_7780_ee601c3a01f7
  a6d973ee_5e39_7312_766c_25767fd684e8["Http2ExampleUtil()"]
  2aef81fe_7774_536a_14b2_6a5f2d13b970 -->|method| a6d973ee_5e39_7312_766c_25767fd684e8
  9449068d_54b4_b6e4_e2f8_d29a89f851e5["toInt()"]
  2aef81fe_7774_536a_14b2_6a5f2d13b970 -->|method| 9449068d_54b4_b6e4_e2f8_d29a89f851e5
  4bf5301a_14cb_4f18_64df_9ab0102ea584["ByteBuf()"]
  2aef81fe_7774_536a_14b2_6a5f2d13b970 -->|method| 4bf5301a_14cb_4f18_64df_9ab0102ea584
  03f4b39b_a2ae_be30_c7ce_772c8469bba3["String()"]
  2aef81fe_7774_536a_14b2_6a5f2d13b970 -->|method| 03f4b39b_a2ae_be30_c7ce_772c8469bba3

Relationship Graph

Source Code

example/src/main/java/io/netty/example/http2/Http2ExampleUtil.java lines 29–83

public final class Http2ExampleUtil {

    /**
     * Response header sent in response to the http->http2 cleartext upgrade request.
     */
    public static final String UPGRADE_RESPONSE_HEADER = "http-to-http2-upgrade";

    /**
     * Size of the block to be read from the input stream.
     */
    private static final int BLOCK_SIZE = 1024;

    private Http2ExampleUtil() { }

    /**
     * @param string the string to be converted to an integer.
     * @param defaultValue the default value
     * @return the integer value of a string or the default value, if the string is either null or empty.
     */
    public static int toInt(String string, int defaultValue) {
        if (string != null && !string.isEmpty()) {
            return Integer.parseInt(string);
        }
        return defaultValue;
    }

    /**
     * Reads an InputStream into a byte array.
     * @param input the InputStream.
     * @return a byte array representation of the InputStream.
     * @throws IOException if an I/O exception of some sort happens while reading the InputStream.
     */
    public static ByteBuf toByteBuf(InputStream input) throws IOException {
        ByteBuf buf = Unpooled.buffer();
        int n = 0;
        do {
            n = buf.writeBytes(input, BLOCK_SIZE);
        } while (n > 0);
        return buf;
    }

    /**
     * @param query the decoder of query string
     * @param key the key to lookup
     * @return the first occurrence of that key in the string parameters
     */
    public static String firstValue(QueryStringDecoder query, String key) {
        checkNotNull(query, "Query can't be null!");
        List<String> values = query.parameters().get(key);
        if (values == null || values.isEmpty()) {
            return null;
        }
        return values.get(0);
    }
}

Frequently Asked Questions

What is the Http2ExampleUtil class?
Http2ExampleUtil is a class in the netty codebase, defined in example/src/main/java/io/netty/example/http2/Http2ExampleUtil.java.
Where is Http2ExampleUtil defined?
Http2ExampleUtil is defined in example/src/main/java/io/netty/example/http2/Http2ExampleUtil.java at line 29.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free