Clover Coverage Report - AWS S3 Wagon 1.0.33-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
19   68   8   4.75
8   40   0.42   4
4     2  
1    
 
  TransferProgressFileInputStream       Line # 29 19 0% 8 31 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.FileInputStream;
20    import java.io.FileNotFoundException;
21    import java.io.IOException;
22   
23    /**
24    * An extension to the {@link FileInputStream} that notifies a @{link TransferProgress} object as it is being read from
25    *
26    * @author Ben Hale
27    * @since 1.1
28    */
 
29    public class TransferProgressFileInputStream extends FileInputStream {
30   
31    private TransferProgress progress;
32   
 
33  0 toggle public TransferProgressFileInputStream(File file, TransferProgress progress) throws FileNotFoundException {
34  0 super(file);
35  0 this.progress = progress;
36    }
37   
 
38  0 toggle public int read() throws IOException {
39  0 int b = super.read();
40  0 if (b != -1) {
41  0 progress.notify(new byte[] { (byte) b }, 1);
42    }
43  0 return b;
44    }
45   
 
46  0 toggle public int read(byte b[]) throws IOException {
47  0 int length = super.read(b);
48  0 if (length != -1) {
49  0 progress.notify(b, length);
50    }
51  0 return length;
52    }
53   
 
54  0 toggle public int read(byte b[], int off, int len) throws IOException {
55  0 int count = super.read(b, off, len);
56  0 if (count == -1) {
57  0 return count;
58    }
59  0 if (off == 0) {
60  0 progress.notify(b, count);
61    } else {
62  0 byte[] bytes = new byte[len];
63  0 System.arraycopy(b, off, bytes, 0, count);
64  0 progress.notify(bytes, count);
65    }
66  0 return count;
67    }
68    }