com.atlassian.jira.util
Class Base64InputStreamConsumer

java.lang.Object
  extended by com.atlassian.jira.util.Base64InputStreamConsumer
All Implemented Interfaces:
Consumer<InputStream>

public class Base64InputStreamConsumer
extends Object
implements Consumer<InputStream>

Basic slurp implementation of an InputStream Consumer which provides Base64 encoded output. Note that this reads the whole input into memory and should not be used for data that may grow big.

Since:
v4.0

Constructor Summary
Base64InputStreamConsumer(boolean chunked)
          Creates this encoder.
 
Method Summary
 void consume(InputStream element)
          Consume the product.
 String getEncoded()
          Gives the Base64 encoded String only if the consume method ran without exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64InputStreamConsumer

public Base64InputStreamConsumer(boolean chunked)
Creates this encoder. Set chunked to true if you want a 72 character formatted ("chunked") String or false if you don't need formatting.

Parameters:
chunked - whether you want a chunked Base64 encoded output.
Method Detail

consume

public void consume(@NotNull
                    InputStream element)
Description copied from interface: Consumer
Consume the product.

Specified by:
consume in interface Consumer<InputStream>
Parameters:
element - must not be null

getEncoded

public String getEncoded()
Gives the Base64 encoded String only if the consume method ran without exception. Otherwise returns the empty String.

Returns:
the empty String or the base64 encoded content of the InputStream.


Copyright © 2002-2013 Atlassian. All Rights Reserved.