blob: fe7d828b821485b97e9b87363a0c392d25175e65 [file] [log] [blame]
<!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_191) on Sat Mar 16 10:16:34 CET 2019 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CumulativeProtocolDecoder (Apache MINA 1.1.4 API Documentation)</title>
<meta name="date" content="2019-03-16">
<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="CumulativeProtocolDecoder (Apache MINA 1.1.4 API Documentation)";
}
}
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract 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="class-use/CumulativeProtocolDecoder.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.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="../../../../../org/apache/mina/filter/codec/ProtocolCodecException.html" title="class in org.apache.mina.filter.codec"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/mina/filter/codec/CumulativeProtocolDecoder.html" target="_top">Frames</a></li>
<li><a href="CumulativeProtocolDecoder.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">org.apache.mina.filter.codec</div>
<h2 title="Class CumulativeProtocolDecoder" class="title">Class CumulativeProtocolDecoder</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderAdapter.html" title="class in org.apache.mina.filter.codec">org.apache.mina.filter.codec.ProtocolDecoderAdapter</a></li>
<li>
<ul class="inheritance">
<li>org.apache.mina.filter.codec.CumulativeProtocolDecoder</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoder.html" title="interface in org.apache.mina.filter.codec">ProtocolDecoder</a></dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../../../org/apache/mina/filter/codec/serialization/ObjectSerializationDecoder.html" title="class in org.apache.mina.filter.codec.serialization">ObjectSerializationDecoder</a></dd>
</dl>
<hr>
<br>
<pre>public abstract class <span class="typeNameLabel">CumulativeProtocolDecoder</span>
extends <a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderAdapter.html" title="class in org.apache.mina.filter.codec">ProtocolDecoderAdapter</a></pre>
<div class="block">A <a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoder.html" title="interface in org.apache.mina.filter.codec"><code>ProtocolDecoder</code></a> that cumulates the content of received
buffers to a <em>cumulative buffer</em> to help users implement decoders.
<p>
If the received <a href="../../../../../org/apache/mina/common/ByteBuffer.html" title="class in org.apache.mina.common"><code>ByteBuffer</code></a> is only a part of a message.
decoders should cumulate received buffers to make a message complete or
to postpone decoding until more buffers arrive.
<p>
Here is an example decoder that decodes CRLF terminated lines into
<code>Command</code> objects:
<pre>
public class CRLFTerminatedCommandLineDecoder
extends CumulativeProtocolDecoder {
private Command parseCommand(ByteBuffer in) {
// Convert the bytes in the specified buffer to a
// Command object.
...
}
protected boolean doDecode(IoSession session, ByteBuffer in,
ProtocolDecoderOutput out)
throws Exception {
// Remember the initial position.
int start = in.position();
// Now find the first CRLF in the buffer.
byte previous = 0;
while (in.hasRemaining()) {
byte current = in.get();
if (previous == '\r' && current == '\n') {
// Remember the current position and limit.
int position = in.position();
int limit = in.limit();
try {
in.position(start);
in.limit(position);
// The bytes between in.position() and in.limit()
// now contain a full CRLF terminated line.
out.write(parseCommand(in.slice()));
} finally {
// Set the position to point right after the
// detected line and set the limit to the old
// one.
in.position(position);
in.limit(limit);
}
// Decoded one line; CumulativeProtocolDecoder will
// call me again until I return false. So just
// return true until there are no more lines in the
// buffer.
return true;
}
previous = current;
}
// Could not find CRLF in the buffer. Reset the initial
// position to the one we recorded above.
in.position(start);
return false;
}
}
</pre></div>
<dl>
<dt><span class="simpleTagLabel">Version:</span></dt>
<dd>$Rev: 555855 $, $Date: 2007-07-13 05:19:00 +0200 (Fri, 13 Jul 2007) $</dd>
<dt><span class="simpleTagLabel">Author:</span></dt>
<dd>The Apache Directory Project (mina-dev@directory.apache.org)</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="colFirst" scope="col">Modifier</th>
<th class="colLast" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mina/filter/codec/CumulativeProtocolDecoder.html#CumulativeProtocolDecoder--">CumulativeProtocolDecoder</a></span>()</code>
<div class="block">Creates a new instance.</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="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract 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>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mina/filter/codec/CumulativeProtocolDecoder.html#decode-org.apache.mina.common.IoSession-org.apache.mina.common.ByteBuffer-org.apache.mina.filter.codec.ProtocolDecoderOutput-">decode</a></span>(<a href="../../../../../org/apache/mina/common/IoSession.html" title="interface in org.apache.mina.common">IoSession</a>&nbsp;session,
<a href="../../../../../org/apache/mina/common/ByteBuffer.html" title="class in org.apache.mina.common">ByteBuffer</a>&nbsp;in,
<a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderOutput.html" title="interface in org.apache.mina.filter.codec">ProtocolDecoderOutput</a>&nbsp;out)</code>
<div class="block">Cumulates content of <tt>in</tt> into internal buffer and forwards
decoding request to <a href="../../../../../org/apache/mina/filter/codec/CumulativeProtocolDecoder.html#doDecode-org.apache.mina.common.IoSession-org.apache.mina.common.ByteBuffer-org.apache.mina.filter.codec.ProtocolDecoderOutput-"><code>doDecode(IoSession, ByteBuffer, ProtocolDecoderOutput)</code></a>.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mina/filter/codec/CumulativeProtocolDecoder.html#dispose-org.apache.mina.common.IoSession-">dispose</a></span>(<a href="../../../../../org/apache/mina/common/IoSession.html" title="interface in org.apache.mina.common">IoSession</a>&nbsp;session)</code>
<div class="block">Releases the cumulative buffer used by the specified <tt>session</tt>.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>protected abstract boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/mina/filter/codec/CumulativeProtocolDecoder.html#doDecode-org.apache.mina.common.IoSession-org.apache.mina.common.ByteBuffer-org.apache.mina.filter.codec.ProtocolDecoderOutput-">doDecode</a></span>(<a href="../../../../../org/apache/mina/common/IoSession.html" title="interface in org.apache.mina.common">IoSession</a>&nbsp;session,
<a href="../../../../../org/apache/mina/common/ByteBuffer.html" title="class in org.apache.mina.common">ByteBuffer</a>&nbsp;in,
<a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderOutput.html" title="interface in org.apache.mina.filter.codec">ProtocolDecoderOutput</a>&nbsp;out)</code>
<div class="block">Implement this method to consume the specified cumulative buffer and
decode its content into message(s).</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.org.apache.mina.filter.codec.ProtocolDecoderAdapter">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;org.apache.mina.filter.codec.<a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderAdapter.html" title="class in org.apache.mina.filter.codec">ProtocolDecoderAdapter</a></h3>
<code><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderAdapter.html#finishDecode-org.apache.mina.common.IoSession-org.apache.mina.filter.codec.ProtocolDecoderOutput-">finishDecode</a></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>clone, equals, finalize, 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="CumulativeProtocolDecoder--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>CumulativeProtocolDecoder</h4>
<pre>protected&nbsp;CumulativeProtocolDecoder()</pre>
<div class="block">Creates a new instance.</div>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="decode-org.apache.mina.common.IoSession-org.apache.mina.common.ByteBuffer-org.apache.mina.filter.codec.ProtocolDecoderOutput-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>decode</h4>
<pre>public&nbsp;void&nbsp;decode(<a href="../../../../../org/apache/mina/common/IoSession.html" title="interface in org.apache.mina.common">IoSession</a>&nbsp;session,
<a href="../../../../../org/apache/mina/common/ByteBuffer.html" title="class in org.apache.mina.common">ByteBuffer</a>&nbsp;in,
<a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderOutput.html" title="interface in org.apache.mina.filter.codec">ProtocolDecoderOutput</a>&nbsp;out)
throws java.lang.Exception</pre>
<div class="block">Cumulates content of <tt>in</tt> into internal buffer and forwards
decoding request to <a href="../../../../../org/apache/mina/filter/codec/CumulativeProtocolDecoder.html#doDecode-org.apache.mina.common.IoSession-org.apache.mina.common.ByteBuffer-org.apache.mina.filter.codec.ProtocolDecoderOutput-"><code>doDecode(IoSession, ByteBuffer, ProtocolDecoderOutput)</code></a>.
<tt>doDecode()</tt> is invoked repeatedly until it returns <tt>false</tt>
and the cumulative buffer is compacted after decoding ends.</div>
<dl>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if your <tt>doDecode()</tt> returned
<tt>true</tt> not consuming the cumulative buffer.</dd>
<dd><code>java.lang.Exception</code> - if the read data violated protocol specification</dd>
</dl>
</li>
</ul>
<a name="doDecode-org.apache.mina.common.IoSession-org.apache.mina.common.ByteBuffer-org.apache.mina.filter.codec.ProtocolDecoderOutput-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>doDecode</h4>
<pre>protected abstract&nbsp;boolean&nbsp;doDecode(<a href="../../../../../org/apache/mina/common/IoSession.html" title="interface in org.apache.mina.common">IoSession</a>&nbsp;session,
<a href="../../../../../org/apache/mina/common/ByteBuffer.html" title="class in org.apache.mina.common">ByteBuffer</a>&nbsp;in,
<a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderOutput.html" title="interface in org.apache.mina.filter.codec">ProtocolDecoderOutput</a>&nbsp;out)
throws java.lang.Exception</pre>
<div class="block">Implement this method to consume the specified cumulative buffer and
decode its content into message(s).</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>in</code> - the cumulative buffer</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><tt>true</tt> if and only if there's more to decode in the buffer
and you want to have <tt>doDecode</tt> method invoked again.
Return <tt>false</tt> if remaining data is not enough to decode,
then this method will be invoked again when more data is cumulated.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.Exception</code> - if cannot decode <tt>in</tt>.</dd>
</dl>
</li>
</ul>
<a name="dispose-org.apache.mina.common.IoSession-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>dispose</h4>
<pre>public&nbsp;void&nbsp;dispose(<a href="../../../../../org/apache/mina/common/IoSession.html" title="interface in org.apache.mina.common">IoSession</a>&nbsp;session)
throws java.lang.Exception</pre>
<div class="block">Releases the cumulative buffer used by the specified <tt>session</tt>.
Please don't forget to call <tt>super.dispose( session )</tt> when
you override this method.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoder.html#dispose-org.apache.mina.common.IoSession-">dispose</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoder.html" title="interface in org.apache.mina.filter.codec">ProtocolDecoder</a></code></dd>
<dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
<dd><code><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderAdapter.html#dispose-org.apache.mina.common.IoSession-">dispose</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../org/apache/mina/filter/codec/ProtocolDecoderAdapter.html" title="class in org.apache.mina.filter.codec">ProtocolDecoderAdapter</a></code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.Exception</code> - if failed to dispose all resources</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="class-use/CumulativeProtocolDecoder.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.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="../../../../../org/apache/mina/filter/codec/ProtocolCodecException.html" title="class in org.apache.mina.filter.codec"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/mina/filter/codec/CumulativeProtocolDecoder.html" target="_top">Frames</a></li>
<li><a href="CumulativeProtocolDecoder.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 ======= -->
<p class="legalCopy"><small>Copyright © 2004-2019 <a href="http://mina.apace.org/">Apache MINA Project</a>. All Rights Reserved.</small></p>
</body>
</html>