Clover coverage report - Maven Clover report
Coverage timestamp: Sun Aug 20 2006 04:01:04 PDT
file stats: LOC: 75   Methods: 6
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
MimePartDataSource.java 83.3% 64.7% 50% 65.5%
coverage coverage
 1    /**
 2    *
 3    * Copyright 2003-2004 The Apache Software Foundation
 4    *
 5    * Licensed under the Apache License, Version 2.0 (the "License");
 6    * you may not use this file except in compliance with the License.
 7    * You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    */
 17   
 18    package javax.mail.internet;
 19   
 20    import java.io.IOException;
 21    import java.io.InputStream;
 22    import java.io.OutputStream;
 23    import java.net.UnknownServiceException;
 24    import javax.activation.DataSource;
 25    import javax.mail.MessageAware;
 26    import javax.mail.MessageContext;
 27    import javax.mail.MessagingException;
 28   
 29    /**
 30    * @version $Rev: 149344 $ $Date: 2005-01-31 17:07:44 -0800 (Mon, 31 Jan 2005) $
 31    */
 32    public class MimePartDataSource implements DataSource, MessageAware {
 33    private final MimePart part;
 34   
 35  3 public MimePartDataSource(MimePart part) {
 36  3 this.part = part;
 37    }
 38   
 39  3 public InputStream getInputStream() throws IOException {
 40  3 try {
 41  3 InputStream stream;
 42  3 if (part instanceof MimeMessage) {
 43  1 stream = ((MimeMessage) part).getContentStream();
 44  2 } else if (part instanceof MimeBodyPart) {
 45  2 stream = ((MimeBodyPart) part).getContentStream();
 46    } else {
 47  0 throw new MessagingException("Unknown part");
 48    }
 49  3 String encoding = part.getEncoding();
 50  3 return encoding == null ? stream : MimeUtility.decode(stream, encoding);
 51    } catch (MessagingException e) {
 52  0 throw (IOException) new IOException(e.getMessage()).initCause(e);
 53    }
 54    }
 55   
 56  0 public OutputStream getOutputStream() throws IOException {
 57  0 throw new UnknownServiceException();
 58    }
 59   
 60  6 public String getContentType() {
 61  6 try {
 62  6 return part.getContentType();
 63    } catch (MessagingException e) {
 64  0 return null;
 65    }
 66    }
 67   
 68  0 public String getName() {
 69  0 return "";
 70    }
 71   
 72  0 public synchronized MessageContext getMessageContext() {
 73  0 return new MessageContext(part);
 74    }
 75    }