/** * Generates a new item-based command from the given incoming SNAC packet. * * @param command the SNAC command subtype for this command * @param packet an incoming item-based command packet */ protected ItemsCmd(int command, SnacPacket packet) { super(command); DefensiveTools.checkNull(packet, "packet"); ByteBlock block = packet.getData(); List<SsiItem> itemList = new ArrayList<SsiItem>(); for (; ; ) { SsiItem item = SsiItem.readSsiItem(block); if (item == null) break; itemList.add(item); block = block.subBlock(item.getTotalSize()); } items = DefensiveTools.getUnmodifiable(itemList); }
public void writeData(OutputStream out) throws IOException { for (SsiItem item : items) item.write(out); }