(Protocol protocol)
| 235 | * Write out all the buffered items into the output stream. |
| 236 | */ |
| 237 | public void write(Protocol protocol) |
| 238 | throws IOException, ProtocolException { |
| 239 | int size = items != null ? items.size() : 0; |
| 240 | DataOutputStream os = (DataOutputStream)protocol.getOutputStream(); |
| 241 | |
| 242 | for (int i=0; i < size; i++) { |
| 243 | if (i > 0) // write delimiter if not the first item |
| 244 | os.write(' '); |
| 245 | |
| 246 | Object o = items.get(i); |
| 247 | if (o instanceof Atom) { |
| 248 | os.writeBytes(((Atom)o).string); |
| 249 | } else if (o instanceof Number) { |
| 250 | os.writeBytes(((Number)o).toString()); |
| 251 | } else if (o instanceof AString) { |
| 252 | astring(((AString)o).bytes, protocol); |
| 253 | } else if (o instanceof NString) { |
| 254 | nstring(((NString)o).bytes, protocol); |
| 255 | } else if (o instanceof byte[]) { |
| 256 | literal((byte[])o, protocol); |
| 257 | } else if (o instanceof ByteArrayOutputStream) { |
| 258 | literal((ByteArrayOutputStream)o, protocol); |
| 259 | } else if (o instanceof Literal) { |
| 260 | literal((Literal)o, protocol); |
| 261 | } else if (o instanceof Argument) { |
| 262 | os.write('('); // open parans |
| 263 | ((Argument)o).write(protocol); |
| 264 | os.write(')'); // close parans |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Write out given String as either an Atom, QuotedString or Literal |
no test coverage detected