final Map<String, Object> attrs = prepareAttributesForSerialization( saveDocuments, saveClusters, saveOtherAttributes);
/** * Serializes this {@link ProcessingResult} to a byte stream. Documents, clusters and * other attributes can be included or skipped in the output as requested. * <p> * This method is not thread-safe, external synchronization must be applied if needed. * </p> * * @param stream the stream to serialize this {@link ProcessingResult} to. The stream * will <strong>not</strong> be closed. * @param saveDocuments if <code>false</code>, documents will not be serialized. * Notice that when deserializing XML containing clusters but not * documents, document references in {@link Cluster#getDocuments()} will * not be restored. * @param saveClusters if <code>false</code>, clusters will not be serialized * @param saveOtherAttributes if <code>false</code>, other attributes will not be * serialized * @throws Exception in case of any problems with serialization */ public void serialize(OutputStream stream, boolean saveDocuments, boolean saveClusters, boolean saveOtherAttributes) throws Exception { final Map<String, Object> backupAttributes = attributes; attributes = prepareAttributesForSerialization(saveDocuments, saveClusters, saveOtherAttributes); new Persister().write(this, stream); attributes = backupAttributes; }