Coverage Report - org.mule.message.ds.StringDataSource
 
Classes in this File Line Coverage Branch Coverage Complexity
StringDataSource
0%
0/18
N/A
1.143
 
 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.message.ds;
 8  
 
 9  
 import java.io.ByteArrayInputStream;
 10  
 import java.io.IOException;
 11  
 import java.io.InputStream;
 12  
 import java.io.OutputStream;
 13  
 
 14  
 import javax.activation.DataSource;
 15  
 
 16  
 public class StringDataSource implements DataSource
 17  
 {
 18  
     protected String content;
 19  0
     protected String contentType = "text/plain";
 20  0
     protected String name = "StringDataSource";
 21  
 
 22  
     public StringDataSource(String payload)
 23  
     {
 24  0
         super();
 25  0
         content = payload;
 26  0
     }
 27  
 
 28  
     public StringDataSource(String payload, String name)
 29  
     {
 30  0
         super();
 31  0
         content = payload;
 32  0
         this.name = name;
 33  0
     }
 34  
 
 35  
     public StringDataSource(String content, String name, String contentType)
 36  0
     {
 37  0
         this.content = content;
 38  0
         this.contentType = contentType;
 39  0
         this.name = name;
 40  0
     }
 41  
 
 42  
     public InputStream getInputStream() throws IOException
 43  
     {
 44  0
         return new ByteArrayInputStream(content.getBytes());
 45  
     }
 46  
 
 47  
     public OutputStream getOutputStream()
 48  
     {
 49  0
         throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
 50  
     }
 51  
 
 52  
     public String getContentType()
 53  
     {
 54  0
         return contentType;
 55  
     }
 56  
 
 57  
     public String getName()
 58  
     {
 59  0
         return name;
 60  
     }
 61  
 }
 62