Clover Coverage Report - AWS S3 Wagon 1.0.29-SNAPSHOT
Coverage timestamp: Tue Apr 12 2011 19:06:18 EST
../../../../img/srcFileCovDistChart0.png 14% of files have more coverage
12   59   5   3
2   30   0.42   4
4     1.25  
1    
 
  TransferProgressFileOutputStream       Line # 30 12 0% 5 18 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2004-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.maven.wagon;
17   
18    import java.io.File;
19    import java.io.FileNotFoundException;
20    import java.io.FileOutputStream;
21    import java.io.IOException;
22   
23    /**
24    * An extension to the {@link FileOutputStream} that notifies
25    * a @{link TransferProgress} object as it is being written to.
26    *
27    * @author Ben Hale
28    * @since 1.1
29    */
 
30    class TransferProgressFileOutputStream extends FileOutputStream {
31   
32    private TransferProgress progress;
33   
 
34  0 toggle public TransferProgressFileOutputStream(File file, TransferProgress progress) throws FileNotFoundException {
35  0 super(file);
36  0 this.progress = progress;
37    }
38   
 
39  0 toggle public void write(int b) throws IOException {
40  0 super.write(b);
41  0 progress.notify(new byte[]{(byte) b}, 1);
42    }
43   
 
44  0 toggle public void write(byte b[]) throws IOException {
45  0 super.write(b);
46  0 progress.notify(b, b.length);
47    }
48   
 
49  0 toggle public void write(byte b[], int off, int len) throws IOException {
50  0 super.write(b, off, len);
51  0 if (off == 0) {
52  0 progress.notify(b, len);
53    } else {
54  0 byte[] bytes = new byte[len];
55  0 System.arraycopy(b, off, bytes, 0, len);
56  0 progress.notify(bytes, len);
57    }
58    }
59    }