comparison src/org/tmatesoft/hg/internal/FilterByteChannel.java @ 148:1a7a9a20e1f9

Exceptions, javadoc. Initial cancel and progress support
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 23 Feb 2011 22:36:28 +0100
parents 7567f4a42fe5
children d5268ca7715b
comparison
equal deleted inserted replaced
147:a05145db4d0c 148:1a7a9a20e1f9
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.internal; 17 package org.tmatesoft.hg.internal;
18 18
19 import java.io.IOException;
19 import java.nio.ByteBuffer; 20 import java.nio.ByteBuffer;
20 import java.util.Collection; 21 import java.util.Collection;
21 22
22 import org.tmatesoft.hg.util.ByteChannel; 23 import org.tmatesoft.hg.util.ByteChannel;
24 import org.tmatesoft.hg.util.CancelledException;
23 25
24 /** 26 /**
25 * 27 *
26 * @author Artem Tikhomirov 28 * @author Artem Tikhomirov
27 * @author TMate Software Ltd. 29 * @author TMate Software Ltd.
36 } 38 }
37 delegate = delegateChannel; 39 delegate = delegateChannel;
38 filters = filtersToApply.toArray(new Filter[filtersToApply.size()]); 40 filters = filtersToApply.toArray(new Filter[filtersToApply.size()]);
39 } 41 }
40 42
41 public int write(ByteBuffer buffer) throws Exception { 43 public int write(ByteBuffer buffer) throws IOException, CancelledException {
42 final int srcPos = buffer.position(); 44 final int srcPos = buffer.position();
43 ByteBuffer processed = buffer; 45 ByteBuffer processed = buffer;
44 for (Filter f : filters) { 46 for (Filter f : filters) {
45 // each next filter consumes not more than previous 47 // each next filter consumes not more than previous
46 // hence total consumed equals position shift in the original buffer 48 // hence total consumed equals position shift in the original buffer