git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
e621: fix order for pools
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
streams
/
NextableInputStream.java
diff --git
a/src/be/nikiroo/utils/streams/NextableInputStream.java
b/src/be/nikiroo/utils/streams/NextableInputStream.java
index 550aa24f459f2fe0fc1c28fe3efa80f606a59a88..dcab472efa0569bf6763425567330a536ac3eeeb 100644
(file)
--- a/
src/be/nikiroo/utils/streams/NextableInputStream.java
+++ b/
src/be/nikiroo/utils/streams/NextableInputStream.java
@@
-81,16
+81,14
@@
public class NextableInputStream extends BufferedInputStream {
* It can only be called when the "current" stream is spent (i.e., you must
* first process the stream until it is spent).
* <p>
* It can only be called when the "current" stream is spent (i.e., you must
* first process the stream until it is spent).
* <p>
- * We consider that when the under-laying {@link InputStream} is also spent,
- * we cannot have a next sub-stream (it will thus return FALSE).
- * <p>
* {@link IOException}s can happen when we have no data available in the
* buffer; in that case, we fetch more data to know if we can have a next
* sub-stream or not.
* <p>
* This is can be a blocking call when data need to be fetched.
*
* {@link IOException}s can happen when we have no data available in the
* buffer; in that case, we fetch more data to know if we can have a next
* sub-stream or not.
* <p>
* This is can be a blocking call when data need to be fetched.
*
- * @return TRUE if we unblocked the next sub-stream, FALSE if not
+ * @return TRUE if we unblocked the next sub-stream, FALSE if not (i.e.,
+ * FALSE when there are no more sub-streams to fetch)
*
* @throws IOException
* in case of I/O error or if the stream is closed
*
* @throws IOException
* in case of I/O error or if the stream is closed
@@
-122,7
+120,7
@@
public class NextableInputStream extends BufferedInputStream {
* process).
* <p>
* Note: when the stream is divided into sub-streams, each sub-stream will
* process).
* <p>
* Note: when the stream is divided into sub-streams, each sub-stream will
- * report it
is eof when emptied
.
+ * report it
s own eof when spent
.
*
* @return TRUE if it is
*
*
* @return TRUE if it is
*
@@
-158,11
+156,6
@@
public class NextableInputStream extends BufferedInputStream {
return false;
}
return false;
}
- /**
- * We have more data available in the buffer or we can fetch more.
- *
- * @return TRUE if it is the case, FALSE if not
- */
@Override
protected boolean hasMoreData() {
return started && super.hasMoreData();
@Override
protected boolean hasMoreData() {
return started && super.hasMoreData();
@@
-205,7
+198,8
@@
public class NextableInputStream extends BufferedInputStream {
* TRUE for {@link NextableInputStream#nextAll()}, FALSE for
* {@link NextableInputStream#next()}
*
* TRUE for {@link NextableInputStream#nextAll()}, FALSE for
* {@link NextableInputStream#next()}
*
- * @return TRUE if we unblocked the next sub-stream, FALSE if not
+ * @return TRUE if we unblocked the next sub-stream, FALSE if not (i.e.,
+ * FALSE when there are no more sub-streams to fetch)
*
* @throws IOException
* in case of I/O error or if the stream is closed
*
* @throws IOException
* in case of I/O error or if the stream is closed
@@
-220,9
+214,17
@@
public class NextableInputStream extends BufferedInputStream {
if (all) {
step = null;
}
if (all) {
step = null;
}
+
+ return true;
}
}
- if (step != null && !hasMoreData() && stopped) {
+ // If started, must be stopped and no more data to continue
+ // i.e., sub-stream must be spent
+ if (!stopped || hasMoreData()) {
+ return false;
+ }
+
+ if (step != null) {
stop = step.getResumeLen();
start += step.getResumeSkip();
eof = step.getResumeEof();
stop = step.getResumeLen();
start += step.getResumeSkip();
eof = step.getResumeEof();
@@
-233,17
+235,21
@@
public class NextableInputStream extends BufferedInputStream {
}
checkBuffer(false);
}
checkBuffer(false);
- }
- // consider that if EOF, there is no next
- if (start >= stop) {
- // Make sure, block if necessary
- preRead();
-
- return hasMoreData();
+ return true;
}
}
- return true;
+ return false;
+
+ // // consider that if EOF, there is no next
+ // if (start >= stop) {
+ // // Make sure, block if necessary
+ // preRead();
+ //
+ // return hasMoreData();
+ // }
+ //
+ // return true;
}
/**
}
/**
@@
-259,8
+265,8
@@
public class NextableInputStream extends BufferedInputStream {
data = new String(Arrays.copyOfRange(buffer, 0, stop), "UTF-8");
} catch (UnsupportedEncodingException e) {
}
data = new String(Arrays.copyOfRange(buffer, 0, stop), "UTF-8");
} catch (UnsupportedEncodingException e) {
}
- if (data.length() >
5
0) {
- data = data.substring(0,
4
7) + "...";
+ if (data.length() >
20
0) {
+ data = data.substring(0,
19
7) + "...";
}
}
String rep = String.format(
}
}
String rep = String.format(