cassandra-server
Version:
A thin Javascript wrapper around Apache Cassandra to provide out of the box server support
1,079 lines (1,065 loc) • 45.6 kB
HTML
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_67) on Sun Sep 07 15:29:29 CEST 2014 -->
<title>ByteBufferUtil (apache-cassandra API)</title>
<meta name="date" content="2014-09-07">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ByteBufferUtil (apache-cassandra API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><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/ByteBufferUtil.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><a href="../../../../org/apache/cassandra/utils/BoundedStatsDeque.html" title="class in org.apache.cassandra.utils"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/cassandra/utils/BytesReadTracker.html" title="class in org.apache.cassandra.utils"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/cassandra/utils/ByteBufferUtil.html" target="_top">Frames</a></li>
<li><a href="ByteBufferUtil.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All 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: </li>
<li>Nested | </li>
<li><a href="#field_summary">Field</a> | </li>
<li><a href="#constructor_summary">Constr</a> | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li><a href="#field_detail">Field</a> | </li>
<li><a href="#constructor_detail">Constr</a> | </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.cassandra.utils</div>
<h2 title="Class ByteBufferUtil" class="title">Class ByteBufferUtil</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.cassandra.utils.ByteBufferUtil</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">ByteBufferUtil</span>
extends java.lang.Object</pre>
<div class="block">Utility methods to make ByteBuffers less painful
The following should illustrate the different ways byte buffers can be used
public void testArrayOffet()
{
byte[] b = "test_slice_array".getBytes();
ByteBuffer bb = ByteBuffer.allocate(1024);
assert bb.position() == 0;
assert bb.limit() == 1024;
assert bb.capacity() == 1024;
bb.put(b);
assert bb.position() == b.length;
assert bb.remaining() == bb.limit() - bb.position();
ByteBuffer bb2 = bb.slice();
assert bb2.position() == 0;
//slice should begin at other buffers current position
assert bb2.arrayOffset() == bb.position();
//to match the position in the underlying array one needs to
//track arrayOffset
assert bb2.limit()+bb2.arrayOffset() == bb.limit();
assert bb2.remaining() == bb.remaining();
}
}</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#EMPTY_BYTE_BUFFER">EMPTY_BYTE_BUFFER</a></strong></code> </td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#ByteBufferUtil()">ByteBufferUtil</a></strong>()</code> </td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#arrayCopy(java.nio.ByteBuffer,%20int,%20byte[],%20int,%20int)">arrayCopy</a></strong>(java.nio.ByteBuffer src,
int srcPos,
byte[] dst,
int dstPos,
int length)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#arrayCopy(java.nio.ByteBuffer,%20int,%20java.nio.ByteBuffer,%20int,%20int)">arrayCopy</a></strong>(java.nio.ByteBuffer src,
int srcPos,
java.nio.ByteBuffer dst,
int dstPos,
int length)</code>
<div class="block">Transfer bytes from one ByteBuffer to another.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(double)">bytes</a></strong>(double d)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(float)">bytes</a></strong>(float f)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(java.net.InetAddress)">bytes</a></strong>(java.net.InetAddress address)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(int)">bytes</a></strong>(int i)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(long)">bytes</a></strong>(long n)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(java.lang.String)">bytes</a></strong>(java.lang.String s)</code>
<div class="block">Encode a String in a ByteBuffer using UTF_8.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(java.lang.String,%20java.nio.charset.Charset)">bytes</a></strong>(java.lang.String s,
java.nio.charset.Charset charset)</code>
<div class="block">Encode a String in a ByteBuffer using the provided charset.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytes(java.util.UUID)">bytes</a></strong>(java.util.UUID uuid)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#bytesToHex(java.nio.ByteBuffer)">bytesToHex</a></strong>(java.nio.ByteBuffer bytes)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#clone(java.nio.ByteBuffer)">clone</a></strong>(java.nio.ByteBuffer buffer)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#compare(byte[],%20java.nio.ByteBuffer)">compare</a></strong>(byte[] o1,
java.nio.ByteBuffer o2)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#compare(java.nio.ByteBuffer,%20byte[])">compare</a></strong>(java.nio.ByteBuffer o1,
byte[] o2)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#compareSubArrays(java.nio.ByteBuffer,%20int,%20java.nio.ByteBuffer,%20int,%20int)">compareSubArrays</a></strong>(java.nio.ByteBuffer bytes1,
int offset1,
java.nio.ByteBuffer bytes2,
int offset2,
int length)</code>
<div class="block">Compare two ByteBuffer at specified offsets for length.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#compareUnsigned(java.nio.ByteBuffer,%20java.nio.ByteBuffer)">compareUnsigned</a></strong>(java.nio.ByteBuffer o1,
java.nio.ByteBuffer o2)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#getArray(java.nio.ByteBuffer)">getArray</a></strong>(java.nio.ByteBuffer buffer)</code>
<div class="block">You should almost never use this.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#getShortLength(java.nio.ByteBuffer,%20int)">getShortLength</a></strong>(java.nio.ByteBuffer bb,
int position)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#hexToBytes(java.lang.String)">hexToBytes</a></strong>(java.lang.String str)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.io.InputStream</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#inputStream(java.nio.ByteBuffer)">inputStream</a></strong>(java.nio.ByteBuffer bytes)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#isPrefix(java.nio.ByteBuffer,%20java.nio.ByteBuffer)">isPrefix</a></strong>(java.nio.ByteBuffer prefix,
java.nio.ByteBuffer value)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#lastIndexOf(java.nio.ByteBuffer,%20byte,%20int)">lastIndexOf</a></strong>(java.nio.ByteBuffer buffer,
byte valueToFind,
int startIndex)</code>
<div class="block">ByteBuffer adaptation of org.apache.commons.lang3.ArrayUtils.lastIndexOf method</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#minimalBufferFor(java.nio.ByteBuffer)">minimalBufferFor</a></strong>(java.nio.ByteBuffer buf)</code>
<div class="block">trims size of bytebuffer to exactly number of bytes in it, to do not hold too much memory</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#read(java.io.DataInput,%20int)">read</a></strong>(java.io.DataInput in,
int length)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readBytes(java.nio.ByteBuffer,%20int)">readBytes</a></strong>(java.nio.ByteBuffer bb,
int length)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readBytes(java.io.DataInput,%20int)">readBytes</a></strong>(java.io.DataInput in,
int length)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readBytesWithShortLength(java.nio.ByteBuffer)">readBytesWithShortLength</a></strong>(java.nio.ByteBuffer bb)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readShortLength(java.nio.ByteBuffer)">readShortLength</a></strong>(java.nio.ByteBuffer bb)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readShortLength(java.io.DataInput)">readShortLength</a></strong>(java.io.DataInput in)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readWithLength(java.io.DataInput)">readWithLength</a></strong>(java.io.DataInput in)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#readWithShortLength(java.io.DataInput)">readWithShortLength</a></strong>(java.io.DataInput in)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.nio.ByteBuffer</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#skipShortLength(java.io.DataInput)">skipShortLength</a></strong>(java.io.DataInput in)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#string(java.nio.ByteBuffer)">string</a></strong>(java.nio.ByteBuffer buffer)</code>
<div class="block">Decode a String representation.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#string(java.nio.ByteBuffer,%20java.nio.charset.Charset)">string</a></strong>(java.nio.ByteBuffer buffer,
java.nio.charset.Charset charset)</code>
<div class="block">Decode a String representation.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#string(java.nio.ByteBuffer,%20int,%20int)">string</a></strong>(java.nio.ByteBuffer buffer,
int position,
int length)</code>
<div class="block">Decode a String representation.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#string(java.nio.ByteBuffer,%20int,%20int,%20java.nio.charset.Charset)">string</a></strong>(java.nio.ByteBuffer buffer,
int position,
int length,
java.nio.charset.Charset charset)</code>
<div class="block">Decode a String representation.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#toDouble(java.nio.ByteBuffer)">toDouble</a></strong>(java.nio.ByteBuffer bytes)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#toFloat(java.nio.ByteBuffer)">toFloat</a></strong>(java.nio.ByteBuffer bytes)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#toInt(java.nio.ByteBuffer)">toInt</a></strong>(java.nio.ByteBuffer bytes)</code>
<div class="block">Convert a byte buffer to an integer.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#toLong(java.nio.ByteBuffer)">toLong</a></strong>(java.nio.ByteBuffer bytes)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#writeShortLength(java.nio.ByteBuffer,%20int)">writeShortLength</a></strong>(java.nio.ByteBuffer bb,
int length)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#writeWithLength(byte[],%20java.io.DataOutput)">writeWithLength</a></strong>(byte[] bytes,
java.io.DataOutput out)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#writeWithLength(java.nio.ByteBuffer,%20org.apache.cassandra.io.util.DataOutputPlus)">writeWithLength</a></strong>(java.nio.ByteBuffer bytes,
<a href="../../../../org/apache/cassandra/io/util/DataOutputPlus.html" title="interface in org.apache.cassandra.io.util">DataOutputPlus</a> out)</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#writeWithShortLength(byte[],%20java.io.DataOutput)">writeWithShortLength</a></strong>(byte[] buffer,
java.io.DataOutput out)</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/cassandra/utils/ByteBufferUtil.html#writeWithShortLength(java.nio.ByteBuffer,%20org.apache.cassandra.io.util.DataOutputPlus)">writeWithShortLength</a></strong>(java.nio.ByteBuffer buffer,
<a href="../../../../org/apache/cassandra/io/util/DataOutputPlus.html" title="interface in org.apache.cassandra.io.util">DataOutputPlus</a> out)</code> </td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class 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">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="EMPTY_BYTE_BUFFER">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>EMPTY_BYTE_BUFFER</h4>
<pre>public static final java.nio.ByteBuffer EMPTY_BYTE_BUFFER</pre>
</li>
</ul>
</li>
</ul>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="ByteBufferUtil()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>ByteBufferUtil</h4>
<pre>public ByteBufferUtil()</pre>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="compareUnsigned(java.nio.ByteBuffer, java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareUnsigned</h4>
<pre>public static int compareUnsigned(java.nio.ByteBuffer o1,
java.nio.ByteBuffer o2)</pre>
</li>
</ul>
<a name="compare(byte[], java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compare</h4>
<pre>public static int compare(byte[] o1,
java.nio.ByteBuffer o2)</pre>
</li>
</ul>
<a name="compare(java.nio.ByteBuffer, byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compare</h4>
<pre>public static int compare(java.nio.ByteBuffer o1,
byte[] o2)</pre>
</li>
</ul>
<a name="string(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>string</h4>
<pre>public static java.lang.String string(java.nio.ByteBuffer buffer)
throws java.nio.charset.CharacterCodingException</pre>
<div class="block">Decode a String representation.
This method assumes that the encoding charset is UTF_8.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - a byte buffer holding the string representation</dd>
<dt><span class="strong">Returns:</span></dt><dd>the decoded string</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.nio.charset.CharacterCodingException</code></dd></dl>
</li>
</ul>
<a name="string(java.nio.ByteBuffer, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>string</h4>
<pre>public static java.lang.String string(java.nio.ByteBuffer buffer,
int position,
int length)
throws java.nio.charset.CharacterCodingException</pre>
<div class="block">Decode a String representation.
This method assumes that the encoding charset is UTF_8.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - a byte buffer holding the string representation</dd><dd><code>position</code> - the starting position in <code>buffer</code> to start decoding from</dd><dd><code>length</code> - the number of bytes from <code>buffer</code> to use</dd>
<dt><span class="strong">Returns:</span></dt><dd>the decoded string</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.nio.charset.CharacterCodingException</code></dd></dl>
</li>
</ul>
<a name="string(java.nio.ByteBuffer, int, int, java.nio.charset.Charset)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>string</h4>
<pre>public static java.lang.String string(java.nio.ByteBuffer buffer,
int position,
int length,
java.nio.charset.Charset charset)
throws java.nio.charset.CharacterCodingException</pre>
<div class="block">Decode a String representation.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - a byte buffer holding the string representation</dd><dd><code>position</code> - the starting position in <code>buffer</code> to start decoding from</dd><dd><code>length</code> - the number of bytes from <code>buffer</code> to use</dd><dd><code>charset</code> - the String encoding charset</dd>
<dt><span class="strong">Returns:</span></dt><dd>the decoded string</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.nio.charset.CharacterCodingException</code></dd></dl>
</li>
</ul>
<a name="string(java.nio.ByteBuffer, java.nio.charset.Charset)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>string</h4>
<pre>public static java.lang.String string(java.nio.ByteBuffer buffer,
java.nio.charset.Charset charset)
throws java.nio.charset.CharacterCodingException</pre>
<div class="block">Decode a String representation.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - a byte buffer holding the string representation</dd><dd><code>charset</code> - the String encoding charset</dd>
<dt><span class="strong">Returns:</span></dt><dd>the decoded string</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.nio.charset.CharacterCodingException</code></dd></dl>
</li>
</ul>
<a name="getArray(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getArray</h4>
<pre>public static byte[] getArray(java.nio.ByteBuffer buffer)</pre>
<div class="block">You should almost never use this. Instead, use the write* methods to avoid copies.</div>
</li>
</ul>
<a name="lastIndexOf(java.nio.ByteBuffer, byte, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>lastIndexOf</h4>
<pre>public static int lastIndexOf(java.nio.ByteBuffer buffer,
byte valueToFind,
int startIndex)</pre>
<div class="block">ByteBuffer adaptation of org.apache.commons.lang3.ArrayUtils.lastIndexOf method</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>buffer</code> - the array to traverse for looking for the object, may be <code>null</code></dd><dd><code>valueToFind</code> - the value to find</dd><dd><code>startIndex</code> - the start index (i.e. BB position) to travers backwards from</dd>
<dt><span class="strong">Returns:</span></dt><dd>the last index (i.e. BB position) of the value within the array
[between buffer.position() and buffer.limit()]; <code>-1</code> if not found.</dd></dl>
</li>
</ul>
<a name="bytes(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(java.lang.String s)</pre>
<div class="block">Encode a String in a ByteBuffer using UTF_8.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>s</code> - the string to encode</dd>
<dt><span class="strong">Returns:</span></dt><dd>the encoded string</dd></dl>
</li>
</ul>
<a name="bytes(java.lang.String, java.nio.charset.Charset)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(java.lang.String s,
java.nio.charset.Charset charset)</pre>
<div class="block">Encode a String in a ByteBuffer using the provided charset.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>s</code> - the string to encode</dd><dd><code>charset</code> - the String encoding charset to use</dd>
<dt><span class="strong">Returns:</span></dt><dd>the encoded string</dd></dl>
</li>
</ul>
<a name="clone(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clone</h4>
<pre>public static java.nio.ByteBuffer clone(java.nio.ByteBuffer buffer)</pre>
<dl><dt><span class="strong">Returns:</span></dt><dd>a new copy of the data in @param buffer
USUALLY YOU SHOULD USE ByteBuffer.duplicate() INSTEAD, which creates a new Buffer
(so you can mutate its position without affecting the original) without copying the underlying array.</dd></dl>
</li>
</ul>
<a name="arrayCopy(java.nio.ByteBuffer, int, byte[], int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>arrayCopy</h4>
<pre>public static void arrayCopy(java.nio.ByteBuffer src,
int srcPos,
byte[] dst,
int dstPos,
int length)</pre>
</li>
</ul>
<a name="arrayCopy(java.nio.ByteBuffer, int, java.nio.ByteBuffer, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>arrayCopy</h4>
<pre>public static void arrayCopy(java.nio.ByteBuffer src,
int srcPos,
java.nio.ByteBuffer dst,
int dstPos,
int length)</pre>
<div class="block">Transfer bytes from one ByteBuffer to another.
This function acts as System.arrayCopy() but for ByteBuffers.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>src</code> - the source ByteBuffer</dd><dd><code>srcPos</code> - starting position in the source ByteBuffer</dd><dd><code>dst</code> - the destination ByteBuffer</dd><dd><code>dstPos</code> - starting position in the destination ByteBuffer</dd><dd><code>length</code> - the number of bytes to copy</dd></dl>
</li>
</ul>
<a name="writeWithLength(java.nio.ByteBuffer, org.apache.cassandra.io.util.DataOutputPlus)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writeWithLength</h4>
<pre>public static void writeWithLength(java.nio.ByteBuffer bytes,
<a href="../../../../org/apache/cassandra/io/util/DataOutputPlus.html" title="interface in org.apache.cassandra.io.util">DataOutputPlus</a> out)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="writeWithLength(byte[], java.io.DataOutput)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writeWithLength</h4>
<pre>public static void writeWithLength(byte[] bytes,
java.io.DataOutput out)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="writeWithShortLength(java.nio.ByteBuffer, org.apache.cassandra.io.util.DataOutputPlus)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writeWithShortLength</h4>
<pre>public static void writeWithShortLength(java.nio.ByteBuffer buffer,
<a href="../../../../org/apache/cassandra/io/util/DataOutputPlus.html" title="interface in org.apache.cassandra.io.util">DataOutputPlus</a> out)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="writeWithShortLength(byte[], java.io.DataOutput)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writeWithShortLength</h4>
<pre>public static void writeWithShortLength(byte[] buffer,
java.io.DataOutput out)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="readWithLength(java.io.DataInput)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>readWithLength</h4>
<pre>public static java.nio.ByteBuffer readWithLength(java.io.DataInput in)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="readShortLength(java.io.DataInput)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>readShortLength</h4>
<pre>public static int readShortLength(java.io.DataInput in)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="readWithShortLength(java.io.DataInput)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>readWithShortLength</h4>
<pre>public static java.nio.ByteBuffer readWithShortLength(java.io.DataInput in)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>in</code> - data input</dd>
<dt><span class="strong">Returns:</span></dt><dd>An unsigned short in an integer.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an I/O error occurs.</dd></dl>
</li>
</ul>
<a name="skipShortLength(java.io.DataInput)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>skipShortLength</h4>
<pre>public static java.nio.ByteBuffer skipShortLength(java.io.DataInput in)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>in</code> - data input</dd>
<dt><span class="strong">Returns:</span></dt><dd>null</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code> - if an I/O error occurs.</dd></dl>
</li>
</ul>
<a name="read(java.io.DataInput, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>read</h4>
<pre>public static java.nio.ByteBuffer read(java.io.DataInput in,
int length)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="readBytes(java.io.DataInput, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>readBytes</h4>
<pre>public static byte[] readBytes(java.io.DataInput in,
int length)
throws java.io.IOException</pre>
<dl><dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.IOException</code></dd></dl>
</li>
</ul>
<a name="toInt(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toInt</h4>
<pre>public static int toInt(java.nio.ByteBuffer bytes)</pre>
<div class="block">Convert a byte buffer to an integer.
Does not change the byte buffer position.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>bytes</code> - byte buffer to convert to integer</dd>
<dt><span class="strong">Returns:</span></dt><dd>int representation of the byte buffer</dd></dl>
</li>
</ul>
<a name="toLong(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toLong</h4>
<pre>public static long toLong(java.nio.ByteBuffer bytes)</pre>
</li>
</ul>
<a name="toFloat(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toFloat</h4>
<pre>public static float toFloat(java.nio.ByteBuffer bytes)</pre>
</li>
</ul>
<a name="toDouble(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toDouble</h4>
<pre>public static double toDouble(java.nio.ByteBuffer bytes)</pre>
</li>
</ul>
<a name="bytes(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(int i)</pre>
</li>
</ul>
<a name="bytes(long)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(long n)</pre>
</li>
</ul>
<a name="bytes(float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(float f)</pre>
</li>
</ul>
<a name="bytes(double)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(double d)</pre>
</li>
</ul>
<a name="inputStream(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>inputStream</h4>
<pre>public static java.io.InputStream inputStream(java.nio.ByteBuffer bytes)</pre>
</li>
</ul>
<a name="bytesToHex(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytesToHex</h4>
<pre>public static java.lang.String bytesToHex(java.nio.ByteBuffer bytes)</pre>
</li>
</ul>
<a name="hexToBytes(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hexToBytes</h4>
<pre>public static java.nio.ByteBuffer hexToBytes(java.lang.String str)</pre>
</li>
</ul>
<a name="compareSubArrays(java.nio.ByteBuffer, int, java.nio.ByteBuffer, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareSubArrays</h4>
<pre>public static int compareSubArrays(java.nio.ByteBuffer bytes1,
int offset1,
java.nio.ByteBuffer bytes2,
int offset2,
int length)</pre>
<div class="block">Compare two ByteBuffer at specified offsets for length.
Compares the non equal bytes as unsigned.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>bytes1</code> - First byte buffer to compare.</dd><dd><code>offset1</code> - Position to start the comparison at in the first array.</dd><dd><code>bytes2</code> - Second byte buffer to compare.</dd><dd><code>offset2</code> - Position to start the comparison at in the second array.</dd><dd><code>length</code> - How many bytes to compare?</dd>
<dt><span class="strong">Returns:</span></dt><dd>-1 if byte1 is less than byte2, 1 if byte2 is less than byte1 or 0 if equal.</dd></dl>
</li>
</ul>
<a name="bytes(java.net.InetAddress)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(java.net.InetAddress address)</pre>
</li>
</ul>
<a name="bytes(java.util.UUID)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>bytes</h4>
<pre>public static java.nio.ByteBuffer bytes(java.util.UUID uuid)</pre>
</li>
</ul>
<a name="isPrefix(java.nio.ByteBuffer, java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isPrefix</h4>
<pre>public static boolean isPrefix(java.nio.ByteBuffer prefix,
java.nio.ByteBuffer value)</pre>
</li>
</ul>
<a name="minimalBufferFor(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>minimalBufferFor</h4>
<pre>public static java.nio.ByteBuffer minimalBufferFor(java.nio.ByteBuffer buf)</pre>
<div class="block">trims size of bytebuffer to exactly number of bytes in it, to do not hold too much memory</div>
</li>
</ul>
<a name="getShortLength(java.nio.ByteBuffer, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getShortLength</h4>
<pre>public static int getShortLength(java.nio.ByteBuffer bb,
int position)</pre>
</li>
</ul>
<a name="readShortLength(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>readShortLength</h4>
<pre>public static int readShortLength(java.nio.ByteBuffer bb)</pre>
</li>
</ul>
<a name="writeShortLength(java.nio.ByteBuffer, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>writeShortLength</h4>
<pre>public static void writeShortLength(java.nio.ByteBuffer bb,
int length)</pre>
</li>
</ul>
<a name="readBytes(java.nio.ByteBuffer, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>readBytes</h4>
<pre>public static java.nio.ByteBuffer readBytes(java.nio.ByteBuffer bb,
int length)</pre>
</li>
</ul>
<a name="readBytesWithShortLength(java.nio.ByteBuffer)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>readBytesWithShortLength</h4>
<pre>public static java.nio.ByteBuffer readBytesWithShortLength(java.nio.ByteBuffer bb)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><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/ByteBufferUtil.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><a href="../../../../org/apache/cassandra/utils/BoundedStatsDeque.html" title="class in org.apache.cassandra.utils"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/cassandra/utils/BytesReadTracker.html" title="class in org.apache.cassandra.utils"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/cassandra/utils/ByteBufferUtil.html" target="_top">Frames</a></li>
<li><a href="ByteBufferUtil.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All 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: </li>
<li>Nested | </li>
<li><a href="#field_summary">Field</a> | </li>
<li><a href="#constructor_summary">Constr</a> | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li><a href="#field_detail">Field</a> | </li>
<li><a href="#constructor_detail">Constr</a> | </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 © 2014 The Apache Software Foundation</small></p>
</body>
</html>