Parse the capabilities from a CAPA response.
(InputStream in)
| 211 | * Parse the capabilities from a CAPA response. |
| 212 | */ |
| 213 | synchronized void setCapabilities(InputStream in) { |
| 214 | if (in == null) { |
| 215 | capabilities = null; |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | capabilities = new HashMap<>(10); |
| 220 | BufferedReader r = null; |
| 221 | try { |
| 222 | r = new BufferedReader(new InputStreamReader(in, "us-ascii")); |
| 223 | } catch (UnsupportedEncodingException ex) { |
| 224 | // should never happen |
| 225 | assert false; |
| 226 | } |
| 227 | String s; |
| 228 | try { |
| 229 | while ((s = r.readLine()) != null) { |
| 230 | String cap = s; |
| 231 | int i = cap.indexOf(' '); |
| 232 | if (i > 0) |
| 233 | cap = cap.substring(0, i); |
| 234 | capabilities.put(cap.toUpperCase(Locale.ENGLISH), s); |
| 235 | } |
| 236 | } catch (IOException ex) { |
| 237 | // should never happen |
| 238 | } finally { |
| 239 | try { |
| 240 | in.close(); |
| 241 | } catch (IOException ex) { } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Check whether the given capability is supported by |