Clover coverage report - Maven Clover report
Coverage timestamp: Sun Aug 20 2006 04:01:44 PDT
file stats: LOC: 86   Methods: 4
NCLOC: 24   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PreencodedMimeBodyPart.java - 100% 100% 100%
coverage
 1    /**
 2    *
 3    * Copyright 2003-2006 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.OutputStream;
 22   
 23    import javax.mail.MessagingException;
 24   
 25    /**
 26    * @version $Rev: 421852 $ $Date: 2006-07-14 03:02:19 -0700 (Fri, 14 Jul 2006) $
 27    */
 28   
 29   
 30    public class PreencodedMimeBodyPart extends MimeBodyPart {
 31    // the defined transfer encoding
 32    private String transferEncoding;
 33   
 34   
 35    /**
 36    * Create a new body part with the specified MIME transfer encoding.
 37    *
 38    * @param encoding The content encoding.
 39    */
 40  3 public PreencodedMimeBodyPart(String encoding) {
 41  3 transferEncoding = encoding;
 42    }
 43   
 44   
 45    /**
 46    * Retieve the defined encoding for this body part.
 47    *
 48    * @return
 49    * @exception MessagingException
 50    */
 51  2 public String getEncoding() throws MessagingException {
 52  2 return transferEncoding;
 53    }
 54   
 55    /**
 56    * Write the body part content to the stream without applying
 57    * and additional encodings.
 58    *
 59    * @param out The target output stream.
 60    *
 61    * @exception IOException
 62    * @exception MessagingException
 63    */
 64  1 public void writeTo(OutputStream out) throws IOException, MessagingException {
 65  1 headers.writeTo(out, null);
 66    // add the separater between the headers and the data portion.
 67  1 out.write('\r');
 68  1 out.write('\n');
 69    // write this out without getting an encoding stream
 70  1 getDataHandler().writeTo(out);
 71  1 out.flush();
 72    }
 73   
 74   
 75    /**
 76    * Override of update headers to ensure the transfer encoding
 77    * is forced to the correct type.
 78    *
 79    * @exception MessagingException
 80    */
 81  1 protected void updateHeaders() throws MessagingException {
 82  1 super.updateHeaders();
 83  1 setHeader("Content-Transfer-Encoding", transferEncoding);
 84    }
 85    }
 86