@Override public long skip(long n) throws IOException { long nr = in.skip(n); if (nr > 0) { nread += nr; updateSeriesProgression(nr); } return nr; }
@Override public int read(byte[] b, int off, int len) throws IOException { if (isLoadingSeriesCanceled()) { InterruptedIOException exc = new InterruptedIOException(INTERUPTION_LABEL); exc.bytesTransferred = nread; series.setFileSize(series.getFileSize() - nread); nread = 0; throw exc; } int nr = in.read(b, off, len); if (nr > 0) { nread += nr; updateSeriesProgression(nr); } return nr; }
@Override public int read(byte[] b, int off, int len) throws IOException { int nr = super.read(b, off, len); if (wadoRequest) { if (nread < header.length) { System.arraycopy(b, off, header, nread - nr, nr); } else { wadoRequest = false; int length = header.length - (nread - nr); System.arraycopy(b, off, header, nread - nr, length); readMetaInfo(this, header); header = null; } } return nr; }
@Override public int read() throws IOException { if (isLoadingSeriesCanceled()) { InterruptedIOException exc = new InterruptedIOException(INTERUPTION_LABEL); exc.bytesTransferred = nread; series.setFileSize(series.getFileSize() - nread); nread = 0; throw exc; } int c = in.read(); if (c >= 0) { nread++; updateSeriesProgression(1); } return c; }
@Override public int read(byte[] b) throws IOException { int nr = super.read(b); if (wadoRequest) { /* * header.length (512) is an empirical value: 132 is the magic number position + something to be sure to get * Transfer Syntax UID (0x0002, 0x0010) */ if (nread < header.length) { System.arraycopy(b, 0, header, nread - nr, nr); } else { wadoRequest = false; int length = header.length - (nread - nr); System.arraycopy(b, 0, header, nread - nr, length); readMetaInfo(this, header); header = null; } } return nr; }
@Override public int read(byte[] b) throws IOException { if (isLoadingSeriesCanceled()) { InterruptedIOException exc = new InterruptedIOException(INTERUPTION_LABEL); exc.bytesTransferred = nread; series.setFileSize(series.getFileSize() - nread); nread = 0; throw exc; } int nr = in.read(b); if (nr > 0) { nread += nr; updateSeriesProgression(nr); } return nr; }
@Override public synchronized void reset() throws IOException { in.reset(); nread = size - in.available(); updateSeriesProgression(nread); } }