/** {@inheritDoc} */ @Override protected void writeChildren(FreeColXMLWriter xw) throws XMLStreamException { super.writeChildren(xw); if (inputs != null) { for (AbstractGoods input : inputs) { xw.writeStartElement(INPUT_TAG); xw.writeAttribute(GOODS_TYPE_TAG, input.getType()); xw.writeAttribute(VALUE_TAG, input.getAmount()); xw.writeEndElement(); } } if (outputs != null) { for (AbstractGoods output : outputs) { xw.writeStartElement(OUTPUT_TAG); xw.writeAttribute(GOODS_TYPE_TAG, output.getType()); xw.writeAttribute(VALUE_TAG, output.getAmount()); xw.writeEndElement(); } } }
/** {@inheritDoc} */ @Override public void readChildren(FreeColXMLReader xr) throws XMLStreamException { // Clear containers. if (inputs != null) inputs.clear(); if (outputs != null) outputs.clear(); super.readChildren(xr); }
/** {@inheritDoc} */ @Override public void readChild(FreeColXMLReader xr) throws XMLStreamException { final Specification spec = getSpecification(); final String tag = xr.getLocalName(); if (INPUT_TAG.equals(tag)) { GoodsType type = xr.getType(spec, GOODS_TYPE_TAG, GoodsType.class, (GoodsType) null); addInput(type, xr.getAttribute(VALUE_TAG, -1)); xr.closeTag(INPUT_TAG); } else if (OUTPUT_TAG.equals(tag)) { GoodsType type = xr.getType(spec, GOODS_TYPE_TAG, GoodsType.class, (GoodsType) null); addOutput(type, xr.getAttribute(VALUE_TAG, -1)); xr.closeTag(OUTPUT_TAG); } else { super.readChild(xr); } }