@SuppressWarnings({ "unchecked" }) @Override public ModificationStatus doModify(FieldValue fv) { for (Object newValue : newValues.getValues()) { ((CollectionFieldValue)fv).add((FieldValue) newValue); } return ModificationStatus.MODIFIED; }
public static void printArrayXml(Array array, XmlStream xml) { List<FieldValue> lst = array.getValues(); for (FieldValue value : lst) { xml.beginTag("item"); value.printXml(xml); xml.endTag(); } }
/** * Write out the value of array field * * @param field - field description (name and data type) * @param array - field value */ public <T extends FieldValue> void write(FieldBase field, Array<T> array) { buf.putInt1_2_4Bytes(array.size()); List<T> lst = array.getValues(); for (FieldValue value : lst) { value.serialize(this); } }
/** * Write out the value of array field * * @param field - field description (name and data type) * @param array - field value */ public <T extends FieldValue> void write(FieldBase field, Array<T> array) { buf.putInt1_2_4Bytes(array.size()); List<T> lst = array.getValues(); for (FieldValue value : lst) { value.serialize(this); } }
FieldUpdate readAdd(DocumentUpdate update) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { if ("field".equals(reader.getAttributeName(i).toString())) { Field f = update.getDocumentType().getField(reader.getAttributeValue(i)); FieldValue value = f.getDataType().createFieldValue(); value.deserialize(f, this); if (value instanceof Array) { List<FieldValue> l = ((Array)value).getValues(); return FieldUpdate.createAddAll(f, l); } else if (value instanceof WeightedSet) { return FieldUpdate.createAddAll(f, ((WeightedSet) value)); } else { throw newDeserializeException("Add operation only applicable to multivalue lists"); } } } throw newDeserializeException("Add update without field attribute"); }
FieldUpdate readRemove(DocumentUpdate update) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { if ("field".equals(reader.getAttributeName(i).toString())) { Field f = update.getDocumentType().getField(reader.getAttributeValue(i)); FieldValue value = f.getDataType().createFieldValue(); value.deserialize(f, this); if (value instanceof Array) { List<FieldValue> l = ((Array)value).getValues(); return FieldUpdate.createRemoveAll(f, l); } else if (value instanceof WeightedSet) { return FieldUpdate.createRemoveAll(f, ((WeightedSet)value)); } else { throw newDeserializeException("Remove operation only applicable to multivalue lists"); } } } throw newDeserializeException("Remove update without field attribute"); }