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  
  * $Id: StringDataSource.java 18945 2010-08-11 16:01:12Z rossmason $
 3  
  * -------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.message.ds;
 12  
 
 13  
 import java.io.ByteArrayInputStream;
 14  
 import java.io.IOException;
 15  
 import java.io.InputStream;
 16  
 import java.io.OutputStream;
 17  
 
 18  
 import javax.activation.DataSource;
 19  
 
 20  
 public class StringDataSource implements DataSource
 21  
 {
 22  
     protected String content;
 23  0
     protected String contentType = "text/plain";
 24  0
     protected String name = "StringDataSource";
 25  
 
 26  
     public StringDataSource(String payload)
 27  
     {
 28  0
         super();
 29  0
         content = payload;
 30  0
     }
 31  
 
 32  
     public StringDataSource(String payload, String name)
 33  
     {
 34  0
         super();
 35  0
         content = payload;
 36  0
         this.name = name;
 37  0
     }
 38  
 
 39  
     public StringDataSource(String content, String name, String contentType)
 40  0
     {
 41  0
         this.content = content;
 42  0
         this.contentType = contentType;
 43  0
         this.name = name;
 44  0
     }
 45  
 
 46  
     public InputStream getInputStream() throws IOException
 47  
     {
 48  0
         return new ByteArrayInputStream(content.getBytes());
 49  
     }
 50  
 
 51  
     public OutputStream getOutputStream()
 52  
     {
 53  0
         throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
 54  
     }
 55  
 
 56  
     public String getContentType()
 57  
     {
 58  0
         return contentType;
 59  
     }
 60  
 
 61  
     public String getName()
 62  
     {
 63  0
         return name;
 64  
     }
 65  
 }
 66