InfoCmp { public static void parseInfoCmp( String capabilities, Set<Capability> bools, Map<Capability, Integer> ints, Map<Capability, String> strings ) { Map<String, Capability> capsByName = getCapabilitiesByName(); String[] lines = capabilities.split("\n"); for (int i = 1; i < lines.length; i++) { Matcher m = Pattern.compile("\\s*(([^,]|\\\\,)+)\\s*[,$]").matcher(lines[i]); while (m.find()) { String cap = m.group(1); if (cap.contains("#")) { int index = cap.indexOf('#'); String key = cap.substring(0, index); String val = cap.substring(index + 1); int iVal; if ("0".equals(val)) { iVal = 0; } else if (val.startsWith("0x")) { iVal = Integer.parseInt(val.substring(2), 16); } else if (val.startsWith("0")) { iVal = Integer.parseInt(val.substring(1), 8); } else { iVal = Integer.parseInt(val); } Capability c = capsByName.get(key); if (c != null) { ints.put(c, iVal); } } else if (cap.contains("=")) { int index = cap.indexOf('='); String key = cap.substring(0, index); String val = cap.substring(index + 1); Capability c = capsByName.get(key); if (c != null) { strings.put(c, val); } } else { Capability c = capsByName.get(cap); if (c != null) { bools.add(c); } } } } } private  InfoCmp(); static Map<String, Capability> getCapabilitiesByName(); static void setDefaultInfoCmp(String terminal, String caps); static void setDefaultInfoCmp(String terminal, Supplier<String> caps); static String getInfoCmp(
            String terminal
    ); static String getLoadedInfoCmp(String terminal); static void parseInfoCmp(
            String capabilities,
            Set<Capability> bools,
            Map<Capability, Integer> ints,
            Map<Capability, String> strings
    );  }
@Test public void testInfoCmpWithHexa() { Set<Capability> bools = new HashSet<>(); Map<Capability, Integer> ints = new HashMap<>(); Map<Capability, String> strings = new HashMap<>(); String infocmp = "xterm-256color|xterm with 256 colors,\n" + "\tam, bce, ccc, km, mc5i, mir, msgr, npc, xenl,\n" + "\tcolors#0x100, cols#010, it#0, lines#24, pairs#0x7fff,\n" + "\tacsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,\n" + "\tbel=^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, civis=\\E[?25l\n"; InfoCmp.parseInfoCmp(infocmp, bools, ints, strings); assertEquals(8, (int) ints.get(Capability.columns)); assertEquals(0x100, (int) ints.get(Capability.max_colors)); assertEquals(0x7fff, (int) ints.get(Capability.max_pairs)); }