Parse the server parameter list out of the response. @param r the response @exception ProtocolException for protocol failures
(Response r)
| 39 | * @exception ProtocolException for protocol failures |
| 40 | */ |
| 41 | public ID(Response r) throws ProtocolException { |
| 42 | // id_response ::= "ID" SPACE id_params_list |
| 43 | // id_params_list ::= "(" #(string SPACE nstring) ")" / nil |
| 44 | // ;; list of field value pairs |
| 45 | |
| 46 | r.skipSpaces(); |
| 47 | int c = r.peekByte(); |
| 48 | if (c == 'N' || c == 'n') // assume NIL |
| 49 | return; |
| 50 | |
| 51 | if (c != '(') |
| 52 | throw new ProtocolException("Missing '(' at start of ID"); |
| 53 | |
| 54 | serverParams = new HashMap<>(); |
| 55 | |
| 56 | String[] v = r.readStringList(); |
| 57 | if (v != null) { |
| 58 | for (int i = 0; i < v.length; i += 2) { |
| 59 | String name = v[i]; |
| 60 | if (name == null) |
| 61 | throw new ProtocolException("ID field name null"); |
| 62 | if (i + 1 >= v.length) |
| 63 | throw new ProtocolException("ID field without value: " + |
| 64 | name); |
| 65 | String value = v[i + 1]; |
| 66 | serverParams.put(name, value); |
| 67 | } |
| 68 | } |
| 69 | serverParams = Collections.unmodifiableMap(serverParams); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Return the parsed server params. |
nothing calls this directly
no test coverage detected