ByteCountingServletOutputStream.java
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.servlet.ServletOutputStream
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.dam.s7imaging.impl.ps.access_log;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ByteCountingServletOutputStream
extends ServletOutputStream {
private static final Logger LOGGER = LoggerFactory.getLogger(ByteCountingServletOutputStream.class);
private final ServletOutputStream delegate;
private long count = 0;
ByteCountingServletOutputStream(ServletOutputStream delegate) {
this.delegate = delegate;
}
public long count() {
return this.count;
}
public void write(int b) throws IOException {
this.delegate.write(b);
++this.count;
}
public void write(byte[] bytes) throws IOException {
this.delegate.write(bytes);
this.count += (long)bytes.length;
}
public void write(byte[] bytes, int ofs, int len) throws IOException {
this.delegate.write(bytes, ofs, len);
this.count += (long)len;
}
public void flush() throws IOException {
this.delegate.flush();
}
public void close() {
try {
this.delegate.close();
}
catch (IOException e) {
LOGGER.warn("Failed to close output stream: " + (Object)((Object)this), (Throwable)e);
}
}
}