From 578ad0d6bc408edf9e6c875156054374f5fd8337 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 22 Mar 2021 18:40:26 +0100 Subject: change to EGIZ codestyle --- .../moa/spss/util/FilteredOutputStream.java | 126 +++++++++++---------- 1 file changed, 64 insertions(+), 62 deletions(-) (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/FilteredOutputStream.java') diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/FilteredOutputStream.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/FilteredOutputStream.java index 3a9fe51..4f33617 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/FilteredOutputStream.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/util/FilteredOutputStream.java @@ -6,71 +6,73 @@ import java.io.OutputStream; import java.math.BigDecimal; public class FilteredOutputStream extends BufferedOutputStream { - private BigDecimal from = null; - private BigDecimal to = null; - private BigDecimal counter = new BigDecimal("0"); - BigDecimal one = new BigDecimal("1"); - - public FilteredOutputStream(OutputStream innerStream, - int bufferSize, BigDecimal from, - BigDecimal to) { - super(innerStream, bufferSize); - this.from = from; - this.to = to; - } + private BigDecimal from = null; + private BigDecimal to = null; + private BigDecimal counter = new BigDecimal("0"); + BigDecimal one = new BigDecimal("1"); - @Override - public synchronized void write(int b) throws IOException { - if(!inRange(counter)) { - super.write(b); - } - counter = counter.add(one); - } + public FilteredOutputStream(OutputStream innerStream, + int bufferSize, BigDecimal from, + BigDecimal to) { + super(innerStream, bufferSize); + this.from = from; + this.to = to; + } - @Override - public synchronized void write(byte[] b, int off, int len) throws IOException { - this.filteredWrite(b, off, len); - } + @Override + public synchronized void write(int b) throws IOException { + if (!inRange(counter)) { + super.write(b); + } + counter = counter.add(one); + } - @Override - public synchronized void flush() throws IOException { - super.flush(); - } + @Override + public synchronized void write(byte[] b, int off, int len) throws IOException { + this.filteredWrite(b, off, len); + } - @Override - public void write(byte[] b) throws IOException { - if(b != null) { - this.filteredWrite(b, 0, b.length); - } - } + @Override + public synchronized void flush() throws IOException { + super.flush(); + } - @Override - public void close() throws IOException { - super.close(); - } - - private synchronized void filteredWrite(byte[] b, int off, int len) throws IOException { - for(int i = 0; i < len; i++) { - if(!inRange(counter)) { - super.write(b[off+i]); - } - counter = counter.add(one); - } - } - - private boolean inRange(BigDecimal counter) { - if ( (from == null) || (to == null)) - return false; - - int compare = counter.compareTo(from); - if (compare == -1) - return false; - else { - compare = counter.compareTo(to); - if (compare == 1) - return false; - else - return true; - } - } + @Override + public void write(byte[] b) throws IOException { + if (b != null) { + this.filteredWrite(b, 0, b.length); + } + } + + @Override + public void close() throws IOException { + super.close(); + } + + private synchronized void filteredWrite(byte[] b, int off, int len) throws IOException { + for (int i = 0; i < len; i++) { + if (!inRange(counter)) { + super.write(b[off + i]); + } + counter = counter.add(one); + } + } + + private boolean inRange(BigDecimal counter) { + if (from == null || to == null) { + return false; + } + + int compare = counter.compareTo(from); + if (compare == -1) { + return false; + } else { + compare = counter.compareTo(to); + if (compare == 1) { + return false; + } else { + return true; + } + } + } } -- cgit v1.2.3