calmnetlib/JavaDoc/com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html

479 lines
18 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_262) on Tue May 23 15:22:21 BST 2023 -->
<title>LengthClampedInputStream</title>
<meta name="date" content="2023-05-23">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="LengthClampedInputStream";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Class</li>
<li><a href="../../../../../com/captainalm/lib/calmnet/stream/NetworkInputStream.html" title="class in com.captainalm.lib.calmnet.stream"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html" target="_top">Frames</a></li>
<li><a href="LengthClampedInputStream.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.captainalm.lib.calmnet.stream</div>
<h2 title="Class LengthClampedInputStream" class="title">Class LengthClampedInputStream</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>java.io.InputStream</li>
<li>
<ul class="inheritance">
<li>java.io.FilterInputStream</li>
<li>
<ul class="inheritance">
<li>com.captainalm.lib.calmnet.stream.LengthClampedInputStream</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd>java.io.Closeable, java.lang.AutoCloseable</dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">LengthClampedInputStream</span>
extends java.io.FilterInputStream</pre>
<div class="block">This class provides the ability to limit the number of bytes read from the underlying stream.
When the limit is reached, this class considers that state as end of stream.</div>
<dl>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>Captain ALM</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#LengthClampedInputStream-java.io.InputStream-int-">LengthClampedInputStream</a></span>(java.io.InputStream&nbsp;inputStream,
int&nbsp;length)</code>
<div class="block">Creates a LengthClampedInputStream with the specified <code>InputStream</code>
and the maximum number of bytes that can be read from the stream.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#available--">available</a></span>()</code>
<div class="block">Returns an estimate of the number of bytes that can be read (or
skipped over) from this input stream without blocking by the next
caller of a method for this input stream.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#close--">close</a></span>()</code>
<div class="block">Closes this input stream and releases any system resources
associated with the stream.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#mark-int-">mark</a></span>(int&nbsp;readlimit)</code>
<div class="block">Marks the current position in this input stream.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#read--">read</a></span>()</code>
<div class="block">Reads the next byte of data from this input stream.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#reset--">reset</a></span>()</code>
<div class="block">Repositions this stream to the position at the time the
<code>mark</code> method was last called on this input stream.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html#setClampedLength-int-">setClampedLength</a></span>(int&nbsp;clampedLength)</code>
<div class="block">Sets a new clamped length value.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.io.FilterInputStream">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.io.FilterInputStream</h3>
<code>markSupported, read, read, skip</code></li>
</ul>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="LengthClampedInputStream-java.io.InputStream-int-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>LengthClampedInputStream</h4>
<pre>public&nbsp;LengthClampedInputStream(java.io.InputStream&nbsp;inputStream,
int&nbsp;length)</pre>
<div class="block">Creates a LengthClampedInputStream with the specified <code>InputStream</code>
and the maximum number of bytes that can be read from the stream.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>inputStream</code> - The input stream to clamp.</dd>
<dd><code>length</code> - The maximum number of bytes that can be read before end of stream is reached.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.NullPointerException</code> - inputStream is null.</dd>
<dd><code>java.lang.IllegalArgumentException</code> - length is less than 0.</dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="read--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>read</h4>
<pre>public&nbsp;int&nbsp;read()
throws java.io.IOException</pre>
<div class="block">Reads the next byte of data from this input stream. The value
byte is returned as an <code>int</code> in the range
<code>0</code> to <code>255</code>. If no byte is available
because the end of the stream has been reached, the value
<code>-1</code> is returned. This method blocks until input data
is available, the end of the stream is detected, or an exception
is thrown.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>read</code>&nbsp;in class&nbsp;<code>java.io.FilterInputStream</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the next byte of data, or <code>-1</code> if the end of the
stream is reached.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an I/O error occurs.</dd>
</dl>
</li>
</ul>
<a name="available--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>available</h4>
<pre>public&nbsp;int&nbsp;available()
throws java.io.IOException</pre>
<div class="block">Returns an estimate of the number of bytes that can be read (or
skipped over) from this input stream without blocking by the next
caller of a method for this input stream. The next caller might be
the same thread or another thread. A single read or skip of this
many bytes will not block, but may read or skip fewer bytes.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>available</code>&nbsp;in class&nbsp;<code>java.io.FilterInputStream</code></dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>an estimate of the number of bytes that can be read (or skipped
over) from this input stream without blocking.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an I/O error occurs.</dd>
</dl>
</li>
</ul>
<a name="mark-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mark</h4>
<pre>public&nbsp;void&nbsp;mark(int&nbsp;readlimit)</pre>
<div class="block">Marks the current position in this input stream. A subsequent
call to the <code>reset</code> method repositions this stream at
the last marked position so that subsequent reads re-read the same bytes.
<p>
The <code>readlimit</code> argument tells this input stream to
allow that many bytes to be read before the mark position gets
invalidated.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>mark</code>&nbsp;in class&nbsp;<code>java.io.FilterInputStream</code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>readlimit</code> - the maximum limit of bytes that can be read before
the mark position becomes invalid.</dd>
</dl>
</li>
</ul>
<a name="reset--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>reset</h4>
<pre>public&nbsp;void&nbsp;reset()
throws java.io.IOException</pre>
<div class="block">Repositions this stream to the position at the time the
<code>mark</code> method was last called on this input stream.
<p>
Stream marks are intended to be used in
situations where you need to read ahead a little to see what's in
the stream. Often this is most easily done by invoking some
general parser. If the stream is of the type handled by the
parse, it just chugs along happily. If the stream is not of
that type, the parser should toss an exception when it fails.
If this happens within readlimit bytes, it allows the outer
code to reset the stream and try another parser.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>reset</code>&nbsp;in class&nbsp;<code>java.io.FilterInputStream</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if the stream has not been marked, if the
mark has been invalidated or marking is not supported.</dd>
</dl>
</li>
</ul>
<a name="close--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>close</h4>
<pre>public&nbsp;void&nbsp;close()
throws java.io.IOException</pre>
<div class="block">Closes this input stream and releases any system resources
associated with the stream.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.io.Closeable</code></dd>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code>close</code>&nbsp;in interface&nbsp;<code>java.lang.AutoCloseable</code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code>close</code>&nbsp;in class&nbsp;<code>java.io.FilterInputStream</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an I/O error occurs.</dd>
</dl>
</li>
</ul>
<a name="setClampedLength-int-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>setClampedLength</h4>
<pre>public&nbsp;void&nbsp;setClampedLength(int&nbsp;clampedLength)</pre>
<div class="block">Sets a new clamped length value.
This is the maximum number of bytes that can be read from the stream.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>clampedLength</code> - The new clamped length value.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - clampedLength is less than 0.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev&nbsp;Class</li>
<li><a href="../../../../../com/captainalm/lib/calmnet/stream/NetworkInputStream.html" title="class in com.captainalm.lib.calmnet.stream"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?com/captainalm/lib/calmnet/stream/LengthClampedInputStream.html" target="_top">Frames</a></li>
<li><a href="LengthClampedInputStream.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>