View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.pgp;
8   
9   import java.io.OutputStream;
10  
11  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
12  
13  /**
14   * A writer of {@link OutputStream}
15   */
16  public interface StreamTransformer
17  {
18  
19      /**
20       * Initialize this writer to write in the out OutputStream
21       * 
22       * @param out the OutputStream where this writer is going to write information
23       * @throws Exception
24       */
25      void initialize(OutputStream out) throws Exception;
26  
27      /**
28       * Writes into out the number of bytes requested
29       * 
30       * @param out the OutputStream where this writer is going to write information
31       * @param bytesRequested how many bytes this writer needs to write
32       * @return whether this writer has finished writing (no more bytes need to be written)
33       * @throws Exception
34       */
35      boolean write(OutputStream out, AtomicLong bytesRequested) throws Exception;
36  }