Home / Class/ StringUtil Class — netty Architecture

StringUtil Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  2bdecda8_5186_4936_ca05_ebee455a476a["StringUtil"]
  e34897ba_0caa_737f_4d9a_5be6d8367ebe["StringUtil.java"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|defined in| e34897ba_0caa_737f_4d9a_5be6d8367ebe
  54a883d7_5ade_192a_a1b3_3d9e614956a8["StringUtil()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 54a883d7_5ade_192a_a1b3_3d9e614956a8
  54eb46ad_3c45_9e8e_d3fb_fa88000f6bef["String()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 54eb46ad_3c45_9e8e_d3fb_fa88000f6bef
  fd66e142_89ba_079c_e13a_31e5ecb9ca4b["commonSuffixOfLength()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| fd66e142_89ba_079c_e13a_31e5ecb9ca4b
  55f68362_38fd_94e4_3460_13e7b6193e02["T()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 55f68362_38fd_94e4_3460_13e7b6193e02
  de38cb8c_b04f_de23_e1f2_9bf861958795["decodeHexNibble()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| de38cb8c_b04f_de23_e1f2_9bf861958795
  5c036a71_d01b_29b6_a0d1_7c91b6bb766e["decodeHexByte()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 5c036a71_d01b_29b6_a0d1_7c91b6bb766e
  b7517576_151e_6981_eb99_5b60ed249fb5["decodeHexDump()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| b7517576_151e_6981_eb99_5b60ed249fb5
  1601af67_9670_d4fa_3231_1425bfc5e176["CharSequence()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 1601af67_9670_d4fa_3231_1425bfc5e176
  bd846ba1_12ef_ee83_8fdc_f5983f04e319["unescapeCsvFields()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| bd846ba1_12ef_ee83_8fdc_f5983f04e319
  ae67d114_5152_cc14_46b9_e7077c89c39d["validateCsvFormat()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| ae67d114_5152_cc14_46b9_e7077c89c39d
  5a8bb340_5986_4b56_4e99_332b7ebf6401["IllegalArgumentException()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 5a8bb340_5986_4b56_4e99_332b7ebf6401
  9ae04130_cb77_ad88_9318_e6bd1d7cbcd4["length()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 9ae04130_cb77_ad88_9318_e6bd1d7cbcd4
  452b73e7_8e94_ed93_0a05_83ceab481e8b["isNullOrEmpty()"]
  2bdecda8_5186_4936_ca05_ebee455a476a -->|method| 452b73e7_8e94_ed93_0a05_83ceab481e8b

Relationship Graph

Source Code

common/src/main/java/io/netty/util/internal/StringUtil.java lines 29–730

public final class StringUtil {

    public static final String EMPTY_STRING = "";
    public static final String NEWLINE = SystemPropertyUtil.get("line.separator", "\n");

    public static final char DOUBLE_QUOTE = '\"';
    public static final char COMMA = ',';
    public static final char LINE_FEED = '\n';
    public static final char CARRIAGE_RETURN = '\r';
    public static final char TAB = '\t';
    public static final char SPACE = 0x20;

    private static final String[] BYTE2HEX_PAD = new String[256];
    private static final String[] BYTE2HEX_NOPAD = new String[256];
    private static final byte[] HEX2B;

    /**
     * 2 - Quote character at beginning and end.
     * 5 - Extra allowance for anticipated escape characters that may be added.
     */
    private static final int CSV_NUMBER_ESCAPE_CHARACTERS = 2 + 5;
    private static final char PACKAGE_SEPARATOR_CHAR = '.';

    static {
        // Generate the lookup table that converts a byte into a 2-digit hexadecimal integer.
        for (int i = 0; i < BYTE2HEX_PAD.length; i++) {
            String str = Integer.toHexString(i);
            BYTE2HEX_PAD[i] = i > 0xf ? str : ('0' + str);
            BYTE2HEX_NOPAD[i] = str;
        }
        // Generate the lookup table that converts an hex char into its decimal value:
        // the size of the table is such that the JVM is capable of save any bounds-check
        // if a char type is used as an index.
        HEX2B = new byte[Character.MAX_VALUE + 1];
        Arrays.fill(HEX2B, (byte) -1);
        HEX2B['0'] = 0;
        HEX2B['1'] = 1;
        HEX2B['2'] = 2;
        HEX2B['3'] = 3;
        HEX2B['4'] = 4;
        HEX2B['5'] = 5;
        HEX2B['6'] = 6;
        HEX2B['7'] = 7;
        HEX2B['8'] = 8;
        HEX2B['9'] = 9;
        HEX2B['A'] = 10;
        HEX2B['B'] = 11;
        HEX2B['C'] = 12;
        HEX2B['D'] = 13;
        HEX2B['E'] = 14;
        HEX2B['F'] = 15;
        HEX2B['a'] = 10;
        HEX2B['b'] = 11;
        HEX2B['c'] = 12;
        HEX2B['d'] = 13;
        HEX2B['e'] = 14;
        HEX2B['f'] = 15;
    }

    private StringUtil() {
        // Unused.
    }

    /**
     * Get the item after one char delim if the delim is found (else null).
     * This operation is a simplified and optimized
     * version of {@link String#split(String, int)}.
     */
    public static String substringAfter(String value, char delim) {
        int pos = value.indexOf(delim);
        if (pos >= 0) {
            return value.substring(pos + 1);
        }
        return null;
    }

    /**
     * Get the item before one char delim if the delim is found (else null).
     * This operation is a simplified and optimized
     * version of {@link String#split(String, int)}.
     */

Frequently Asked Questions

What is the StringUtil class?
StringUtil is a class in the netty codebase, defined in common/src/main/java/io/netty/util/internal/StringUtil.java.
Where is StringUtil defined?
StringUtil is defined in common/src/main/java/io/netty/util/internal/StringUtil.java at line 29.

Analyze Your Own Codebase

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

Try Supermodel Free