Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/Preview.java @ 355:f2c11fe7f3e9
Newline filter shall respect whole stream when deciding whether to process line terminators, hence added stream preview functionality
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 06 Dec 2011 12:57:21 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
354:5f9073eabf06 | 355:f2c11fe7f3e9 |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.internal; | |
18 | |
19 import java.nio.ByteBuffer; | |
20 import java.nio.channels.ByteChannel; | |
21 | |
22 /** | |
23 * Filters may need to look into data stream before actual processing takes place, | |
24 * for example, to find out whether filter shall be applied at all. | |
25 * | |
26 * {@link ByteChannel ByteChannels} that may use filters shall be checked for {@link Preview} adaptable before writing to them. | |
27 * | |
28 * E.g. newline filter handles streams with mixed newline endings according to configuration option | |
29 * (either process or ignore), hence, need to check complete stream first. | |
30 * | |
31 * @author Artem Tikhomirov | |
32 * @author TMate Software Ltd. | |
33 */ | |
34 public interface Preview { | |
35 /** | |
36 * Supplied buffer may be shared between few Preview filter instances, hence implementers shall NOT consume (move position) | |
37 * of the buffer. Caller enforces this reseting buffer position between calls to previewers. | |
38 * <p> | |
39 * XXX if this approach turns out to impose a great burden on filter implementations, FilterByteChannel may be modified to keep | |
40 * record of how far each filter had read it's buffer. | |
41 */ | |
42 void preview(ByteBuffer src); | |
43 } |