Minestom/docs/net/minestom/server/data/SerializableData.html
2020-11-15 23:39:49 +01:00

434 lines
22 KiB
HTML

<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>SerializableData (Minestom 1.0 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="declaration: package: net.minestom.server.data, interface: SerializableData">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../script-dir/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
<script type="text/javascript" src="../../../../script-dir/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../script-dir/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../script-dir/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../script-dir/jquery-3.4.1.js"></script>
<script type="text/javascript" src="../../../../script-dir/jquery-ui.js"></script>
</head>
<body class="class-declaration">
<script type="text/javascript">var data = {"i0":18,"i1":6,"i2":1,"i3":18,"i4":6,"i5":6,"i6":1};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"],16:["t5","Default Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flexBox">
<header role="banner" class="flexHeader">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.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-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<div class="navListSearch"><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="skipNav"><a id="skip.navbar.top">
<!-- -->
</a></div>
</nav>
</header>
<div class="flexContent">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">net.minestom.server.data</a></div>
<h1 title="Interface SerializableData" class="title">Interface SerializableData</h1>
</div>
<div class="contentContainer">
<section class="description">
<dl>
<dt>All Superinterfaces:</dt>
<dd><code><a href="Data.html" title="interface in net.minestom.server.data">Data</a></code></dd>
</dl>
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><code><a href="SerializableDataImpl.html" title="class in net.minestom.server.data">SerializableDataImpl</a></code></dd>
</dl>
<hr>
<pre>public interface <span class="typeNameLabel">SerializableData</span>
extends <a href="Data.html" title="interface in net.minestom.server.data">Data</a></pre>
<div class="block">Represents a <a href="Data.html" title="interface in net.minestom.server.data"><code>Data</code></a> object which can be serialized and read back.
<p>
See <a href="SerializableDataImpl.html" title="class in net.minestom.server.data"><code>SerializableDataImpl</code></a> for the default implementation.</div>
</section>
<section class="summary">
<ul class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<li class="blockList">
<section class="fieldSummary"><a id="field.summary">
<!-- -->
</a>
<h2>Field Summary</h2>
<div class="memberSummary">
<table>
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<thead>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Field</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>static <a href="DataManager.html" title="class in net.minestom.server.data">DataManager</a></code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#DATA_MANAGER">DATA_MANAGER</a></span></code></th>
<td class="colLast">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
<div class="inheritedList">
<h3>Fields inherited from interface&nbsp;net.minestom.server.data.<a href="Data.html" title="interface in net.minestom.server.data">Data</a></h3>
<a id="fields.inherited.from.class.net.minestom.server.data.Data">
<!-- -->
</a><code><a href="Data.html#EMPTY">EMPTY</a></code></div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li class="blockList">
<section class="methodSummary"><a id="method.summary">
<!-- -->
</a>
<h2>Method Summary</h2>
<div class="memberSummary">
<div role="tablist" aria-orientation="horizontal"><button role="tab" aria-selected="true" aria-controls="memberSummary_tabpanel" tabindex="0" onkeydown="switchTab(event)" id="t0" class="activeTableTab">All Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t1" class="tableTab" onclick="show(1);">Static Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t2" class="tableTab" onclick="show(2);">Instance Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t3" class="tableTab" onclick="show(4);">Abstract Methods</button><button role="tab" aria-selected="false" aria-controls="memberSummary_tabpanel" tabindex="-1" onkeydown="switchTab(event)" id="t5" class="tableTab" onclick="show(16);">Default Methods</button></div>
<div id="memberSummary_tabpanel" role="tabpanel">
<table aria-labelledby="t0">
<thead>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr class="altColor" id="i0">
<td class="colFirst"><code>default byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getIndexedSerializedData()">getIndexedSerializedData</a></span>()</code></th>
<td class="colLast">
<div class="block">Serializes the data into an array of bytes.</div>
</td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code>byte[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getSerializedData(it.unimi.dsi.fastutil.objects.Object2ShortMap,boolean)">getSerializedData</a></span>&#8203;(it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;&nbsp;typeToIndexMap,
boolean&nbsp;indexed)</code></th>
<td class="colLast">
<div class="block">Serializes the data into an array of bytes.</div>
</td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>static it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#readDataIndexes(net.minestom.server.utils.binary.BinaryReader)">readDataIndexes</a></span>&#8203;(<a href="../utils/binary/BinaryReader.html" title="class in net.minestom.server.utils.binary">BinaryReader</a>&nbsp;binaryReader)</code></th>
<td class="colLast">
<div class="block">Reads a data index map (type name -&gt; type index).</div>
</td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code>default void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#readIndexedSerializedData(net.minestom.server.utils.binary.BinaryReader)">readIndexedSerializedData</a></span>&#8203;(<a href="../utils/binary/BinaryReader.html" title="class in net.minestom.server.utils.binary">BinaryReader</a>&nbsp;reader)</code></th>
<td class="colLast">
<div class="block">Reads the index map and the data of a serialized <a href="SerializableData.html" title="interface in net.minestom.server.data"><code>SerializableData</code></a>.</div>
</td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#readSerializedData(net.minestom.server.utils.binary.BinaryReader,it.unimi.dsi.fastutil.objects.Object2ShortMap)">readSerializedData</a></span>&#8203;(<a href="../utils/binary/BinaryReader.html" title="class in net.minestom.server.utils.binary">BinaryReader</a>&nbsp;reader,
it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;&nbsp;typeToIndexMap)</code></th>
<td class="colLast">
<div class="block">Reads the data of a <a href="SerializableData.html" title="interface in net.minestom.server.data"><code>SerializableData</code></a> when you already have the index map.</div>
</td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code>&lt;T&gt;&nbsp;void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#set(java.lang.String,T,java.lang.Class)">set</a></span>&#8203;(java.lang.String&nbsp;key,
T&nbsp;value,
java.lang.Class&lt;T&gt;&nbsp;type)</code></th>
<td class="colLast">
<div class="block">Assigns a value to a specific key.</div>
</td>
</tr>
<tr class="altColor" id="i6">
<td class="colFirst"><code>static void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#writeDataIndexHeader(net.minestom.server.utils.binary.BinaryWriter,it.unimi.dsi.fastutil.objects.Object2ShortMap)">writeDataIndexHeader</a></span>&#8203;(<a href="../utils/binary/BinaryWriter.html" title="class in net.minestom.server.utils.binary">BinaryWriter</a>&nbsp;indexWriter,
it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;&nbsp;typeToIndexMap)</code></th>
<td class="colLast">
<div class="block">Writes the index info (class name -&gt; class index), used to write the header for indexed serialized data.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="inheritedList">
<h3>Methods inherited from interface&nbsp;net.minestom.server.data.<a href="Data.html" title="interface in net.minestom.server.data">Data</a></h3>
<a id="methods.inherited.from.class.net.minestom.server.data.Data">
<!-- -->
</a><code><a href="Data.html#copy()">copy</a>, <a href="Data.html#get(java.lang.String)">get</a>, <a href="Data.html#getKeys()">getKeys</a>, <a href="Data.html#getOrDefault(java.lang.String,T)">getOrDefault</a>, <a href="Data.html#hasKey(java.lang.String)">hasKey</a>, <a href="Data.html#isEmpty()">isEmpty</a>, <a href="Data.html#set(java.lang.String,T)">set</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<li class="blockList">
<section class="fieldDetails"><a id="field.detail">
<!-- -->
</a>
<h2>Field Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="DATA_MANAGER">DATA_MANAGER</a></h3>
<div class="memberSignature"><span class="modifiers">static final</span>&nbsp;<span class="returnType"><a href="DataManager.html" title="class in net.minestom.server.data">DataManager</a></span>&nbsp;<span class="memberName">DATA_MANAGER</span></div>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li class="blockList">
<section class="methodDetails"><a id="method.detail">
<!-- -->
</a>
<h2>Method Details</h2>
<ul class="blockList">
<li class="blockList">
<section class="detail">
<h3><a id="set(java.lang.String,java.lang.Object,java.lang.Class)">
<!-- -->
</a><a id="set(java.lang.String,T,java.lang.Class)">set</a></h3>
<div class="memberSignature"><span class="typeParameters">&lt;T&gt;</span>&nbsp;<span class="returnType">void</span>&nbsp;<span class="memberName">set</span>&#8203;(<span class="arguments">@NotNull
java.lang.String&nbsp;key,
@Nullable
T&nbsp;value,
@Nullable
java.lang.Class&lt;T&gt;&nbsp;type)</span></div>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="Data.html#set(java.lang.String,T,java.lang.Class)">Data</a></code></span></div>
<div class="block">Assigns a value to a specific key.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="Data.html#set(java.lang.String,T,java.lang.Class)">set</a></code>&nbsp;in interface&nbsp;<code><a href="Data.html" title="interface in net.minestom.server.data">Data</a></code></dd>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - the value generic</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>key</code> - the key</dd>
<dd><code>value</code> - the value object, null to remove the key</dd>
<dd><code>type</code> - the value type, <a href="Data.html#set(java.lang.String,T)"><code>Data.set(String, Object)</code></a> can be used instead.
null if <code>value</code> is also null</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getSerializedData(it.unimi.dsi.fastutil.objects.Object2ShortMap,boolean)">getSerializedData</a></h3>
<div class="memberSignature"><span class="annotations">@NotNull
</span><span class="returnType">byte[]</span>&nbsp;<span class="memberName">getSerializedData</span>&#8203;(<span class="arguments">@NotNull
it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;&nbsp;typeToIndexMap,
boolean&nbsp;indexed)</span></div>
<div class="block">Serializes the data into an array of bytes.
<p>
Use <a href="#readIndexedSerializedData(net.minestom.server.utils.binary.BinaryReader)"><code>readIndexedSerializedData(BinaryReader)</code></a> if <code>indexed</code> is true,
<a href="#readSerializedData(net.minestom.server.utils.binary.BinaryReader,it.unimi.dsi.fastutil.objects.Object2ShortMap)"><code>readSerializedData(BinaryReader, Object2ShortMap)</code></a> otherwise with the index map
to convert it back to a <a href="SerializableData.html" title="interface in net.minestom.server.data"><code>SerializableData</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>typeToIndexMap</code> - the type to index map, will create entries if new types are discovered.
The map is not thread-safe</dd>
<dd><code>indexed</code> - true to add the types index in the header</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the array representation of this data object</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="readSerializedData(net.minestom.server.utils.binary.BinaryReader,it.unimi.dsi.fastutil.objects.Object2ShortMap)">readSerializedData</a></h3>
<div class="memberSignature"><span class="returnType">void</span>&nbsp;<span class="memberName">readSerializedData</span>&#8203;(<span class="arguments">@NotNull
<a href="../utils/binary/BinaryReader.html" title="class in net.minestom.server.utils.binary">BinaryReader</a>&nbsp;reader,
@NotNull
it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;&nbsp;typeToIndexMap)</span></div>
<div class="block">Reads the data of a <a href="SerializableData.html" title="interface in net.minestom.server.data"><code>SerializableData</code></a> when you already have the index map.
<p>
WARNING: the data to read should not have any index to read and your index map should be COMPLETE.
Use <a href="#readIndexedSerializedData(net.minestom.server.utils.binary.BinaryReader)"><code>readIndexedSerializedData(BinaryReader)</code></a> if you need to read the header.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>reader</code> - the binary reader</dd>
<dd><code>typeToIndexMap</code> - the index map</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="getIndexedSerializedData()">getIndexedSerializedData</a></h3>
<div class="memberSignature"><span class="annotations">@NotNull
</span><span class="modifiers">default</span>&nbsp;<span class="returnType">byte[]</span>&nbsp;<span class="memberName">getIndexedSerializedData</span>()</div>
<div class="block">Serializes the data into an array of bytes.
<p>
Use <a href="#readIndexedSerializedData(net.minestom.server.utils.binary.BinaryReader)"><code>readIndexedSerializedData(BinaryReader)</code></a>
to convert it back to a <a href="SerializableData.html" title="interface in net.minestom.server.data"><code>SerializableData</code></a>.
<p>
This will create a type index map which will be present in the header.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the array representation of this data object</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="readIndexedSerializedData(net.minestom.server.utils.binary.BinaryReader)">readIndexedSerializedData</a></h3>
<div class="memberSignature"><span class="modifiers">default</span>&nbsp;<span class="returnType">void</span>&nbsp;<span class="memberName">readIndexedSerializedData</span>&#8203;(<span class="arguments">@NotNull
<a href="../utils/binary/BinaryReader.html" title="class in net.minestom.server.utils.binary">BinaryReader</a>&nbsp;reader)</span></div>
<div class="block">Reads the index map and the data of a serialized <a href="SerializableData.html" title="interface in net.minestom.server.data"><code>SerializableData</code></a>.
<p>
Got from <a href="#getIndexedSerializedData()"><code>getIndexedSerializedData()</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>reader</code> - the binary reader</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="writeDataIndexHeader(net.minestom.server.utils.binary.BinaryWriter,it.unimi.dsi.fastutil.objects.Object2ShortMap)">writeDataIndexHeader</a></h3>
<div class="memberSignature"><span class="modifiers">static</span>&nbsp;<span class="returnType">void</span>&nbsp;<span class="memberName">writeDataIndexHeader</span>&#8203;(<span class="arguments">@NotNull
<a href="../utils/binary/BinaryWriter.html" title="class in net.minestom.server.utils.binary">BinaryWriter</a>&nbsp;indexWriter,
@NotNull
it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;&nbsp;typeToIndexMap)</span></div>
<div class="block">Writes the index info (class name -&gt; class index), used to write the header for indexed serialized data.
<p>
Sized by a var-int.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>typeToIndexMap</code> - the filled data index map</dd>
</dl>
</section>
</li>
<li class="blockList">
<section class="detail">
<h3><a id="readDataIndexes(net.minestom.server.utils.binary.BinaryReader)">readDataIndexes</a></h3>
<div class="memberSignature"><span class="annotations">@NotNull
</span><span class="modifiers">static</span>&nbsp;<span class="returnType">it.unimi.dsi.fastutil.objects.Object2ShortMap&lt;java.lang.String&gt;</span>&nbsp;<span class="memberName">readDataIndexes</span>&#8203;(<span class="arguments">@NotNull
<a href="../utils/binary/BinaryReader.html" title="class in net.minestom.server.utils.binary">BinaryReader</a>&nbsp;binaryReader)</span></div>
<div class="block">Reads a data index map (type name -&gt; type index).
<p>
Can then be used with <a href="#readSerializedData(net.minestom.server.utils.binary.BinaryReader,it.unimi.dsi.fastutil.objects.Object2ShortMap)"><code>readSerializedData(BinaryReader, Object2ShortMap)</code></a>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>binaryReader</code> - the reader</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a map containing the indexes of your data</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
</div>
<!-- ========= END OF CLASS DATA ========= -->
</main>
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.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-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
</footer>
</div>
</div>
</body>
</html>