Clover coverage report - Maven Clover report
Coverage timestamp: Sun Aug 20 2006 04:01:04 PDT
file stats: LOC: 175   Methods: 8
NCLOC: 90   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
QuotedPrintable.java - 0% 0% 0%
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 org.apache.geronimo.mail.util;
 19   
 20    import java.io.ByteArrayOutputStream;
 21    import java.io.IOException;
 22    import java.io.InputStream;
 23    import java.io.OutputStream;
 24   
 25    public class QuotedPrintable {
 26    // NOTE: the QuotedPrintableEncoder class needs to keep some active state about what's going on with
 27    // respect to line breaks and significant white spaces. This makes it difficult to keep one static
 28    // instance of the decode around for reuse.
 29   
 30   
 31    /**
 32    * encode the input data producing a Q-P encoded byte array.
 33    *
 34    * @return a byte array containing the Q-P encoded data.
 35    */
 36  0 public static byte[] encode(
 37    byte[] data)
 38    {
 39  0 return encode(data, 0, data.length);
 40    }
 41   
 42    /**
 43    * encode the input data producing a Q-P encoded byte array.
 44    *
 45    * @return a byte array containing the Q-P encoded data.
 46    */
 47  0 public static byte[] encode(
 48    byte[] data,
 49    int off,
 50    int length)
 51    {
 52  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 53   
 54  0 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
 55   
 56  0 try
 57    {
 58  0 encoder.encode(data, off, length, bOut);
 59    }
 60    catch (IOException e)
 61    {
 62  0 throw new RuntimeException("exception encoding Q-P encoded string: " + e);
 63    }
 64   
 65  0 return bOut.toByteArray();
 66    }
 67   
 68    /**
 69    * Q-P encode the byte data writing it to the given output stream.
 70    *
 71    * @return the number of bytes produced.
 72    */
 73  0 public static int encode(
 74    byte[] data,
 75    OutputStream out)
 76    throws IOException
 77    {
 78  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 79   
 80  0 return encoder.encode(data, 0, data.length, out);
 81    }
 82   
 83    /**
 84    * Q-P encode the byte data writing it to the given output stream.
 85    *
 86    * @return the number of bytes produced.
 87    */
 88  0 public static int encode(
 89    byte[] data,
 90    int off,
 91    int length,
 92    OutputStream out)
 93    throws IOException
 94    {
 95  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 96  0 return encoder.encode(data, 0, data.length, out);
 97    }
 98   
 99    /**
 100    * decode the Q-P encoded input data. It is assumed the input data is valid.
 101    *
 102    * @return a byte array representing the decoded data.
 103    */
 104  0 public static byte[] decode(
 105    byte[] data)
 106    {
 107  0 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
 108   
 109  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 110  0 try
 111    {
 112  0 encoder.decode(data, 0, data.length, bOut);
 113    }
 114    catch (IOException e)
 115    {
 116  0 throw new RuntimeException("exception decoding Q-P encoded string: " + e);
 117    }
 118   
 119  0 return bOut.toByteArray();
 120    }
 121   
 122    /**
 123    * decode the UUEncided String data.
 124    *
 125    * @return a byte array representing the decoded data.
 126    */
 127  0 public static byte[] decode(
 128    String data)
 129    {
 130  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 131  0 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
 132   
 133  0 try
 134    {
 135  0 encoder.decode(data, bOut);
 136    }
 137    catch (IOException e)
 138    {
 139  0 throw new RuntimeException("exception decoding Q-P encoded string: " + e);
 140    }
 141   
 142  0 return bOut.toByteArray();
 143    }
 144   
 145    /**
 146    * decode the Q-P encoded encoded String data writing it to the given output stream.
 147    *
 148    * @return the number of bytes produced.
 149    */
 150  0 public static int decode(
 151    String data,
 152    OutputStream out)
 153    throws IOException
 154    {
 155  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 156  0 return encoder.decode(data, out);
 157    }
 158   
 159    /**
 160    * decode the base Q-P encoded String data writing it to the given output stream,
 161    * whitespace characters will be ignored.
 162    *
 163    * @param data The array data to decode.
 164    * @param out The output stream for the data.
 165    *
 166    * @return the number of bytes produced.
 167    * @exception IOException
 168    */
 169  0 public static int decode(byte [] data, OutputStream out) throws IOException
 170    {
 171  0 QuotedPrintableEncoder encoder = new QuotedPrintableEncoder();
 172  0 return encoder.decode(data, 0, data.length, out);
 173    }
 174    }
 175