/** * Converts a textual representation of KEY flags into its numeric code. Integers in the range * 0..65535 are also accepted. * * @param s The textual representation of the protocol * @return The protocol code, or -1 on error. */ public static int value(String s) { int value; try { value = Integer.parseInt(s); if (value >= 0 && value <= 0xFFFF) { return value; } return -1; } catch (NumberFormatException e) { } StringTokenizer st = new StringTokenizer(s, "|"); value = 0; while (st.hasMoreTokens()) { int val = flags.getValue(st.nextToken()); if (val < 0) { return -1; } value |= val; } return value; }
/** * Converts a textual representation of a KEY protocol into its numeric code. Integers in the * range 0..255 are also accepted. * * @param s The textual representation of the protocol * @return The protocol code, or -1 on error. */ public static int value(String s) { return protocols.getValue(s); }