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.
(String s)
| 231 | * @return The protocol code, or -1 on error. |
| 232 | */ |
| 233 | public static int |
| 234 | value(String s) { |
| 235 | int value; |
| 236 | try { |
| 237 | value = Integer.parseInt(s); |
| 238 | if (value >= 0 && value <= 0xFFFF) { |
| 239 | return value; |
| 240 | } |
| 241 | return -1; |
| 242 | } catch (NumberFormatException e) { |
| 243 | } |
| 244 | StringTokenizer st = new StringTokenizer(s, "|"); |
| 245 | value = 0; |
| 246 | while (st.hasMoreTokens()) { |
| 247 | int val = flags.getValue(st.nextToken()); |
| 248 | if (val < 0) { |
| 249 | return -1; |
| 250 | } |
| 251 | value |= val; |
| 252 | } |
| 253 | return value; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /* flags */ |
no test coverage detected