/** Deserializes the object from XML */ public DataItem parseItem(XMLStreamReader in) throws IOException, XMLStreamException { DataItem item = new DataItem(); ArrayList<DataField> fieldList = new ArrayList<DataField>(); int tag = in.nextTag(); while (tag > 0) { if (_isFinest) debug(in); if (XMLStreamReader.END_ELEMENT == tag) { item.setFieldList(fieldList); return item; } if (XMLStreamReader.START_ELEMENT == tag && "field".equals(in.getLocalName())) { fieldList.add(parseField(in)); } else if (XMLStreamReader.START_ELEMENT == tag) { log.finer(this + " <" + in.getLocalName() + "> is an unknown tag"); skipToEnd(in, in.getLocalName()); } tag = in.nextTag(); } skipToEnd(in, "item"); return item; }
private void toXml(XmppStreamWriter out, DataItem item) throws IOException, XMLStreamException { out.writeStartElement("item"); DataField[] fields = item.getField(); if (fields != null) { for (int i = 0; i < fields.length; i++) { toXml(out, fields[i]); } } out.writeEndElement(); // </item> }