blob: b21db1ddac0ff6a8c060def5cb727e2fd26431f8 [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 -->
<title>DataSerializable (Apache Geode 1.15.1)</title>
<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="DataSerializable (Apache Geode 1.15.1)";
}
}
catch(err) {
}
//-->
var methods = {"i0":6,"i1":6};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract 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-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/geode/CopyHelper.html" title="class in org.apache.geode"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../org/apache/geode/DataSerializable.Replaceable.html" title="interface in org.apache.geode"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/apache/geode/DataSerializable.html" target="_top">Frames</a></li>
<li><a href="DataSerializable.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><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&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>Field&nbsp;|&nbsp;</li>
<li>Constr&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.geode</div>
<h2 title="Interface DataSerializable" class="title">Interface DataSerializable</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Superinterfaces:</dt>
<dd><a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a></dd>
</dl>
<dl>
<dt>All Known Subinterfaces:</dt>
<dd><a href="../../../org/apache/geode/cache/query/types/CollectionType.html" title="interface in org.apache.geode.cache.query.types">CollectionType</a>, <a href="../../../org/apache/geode/cache/query/types/MapType.html" title="interface in org.apache.geode.cache.query.types">MapType</a>, <a href="../../../org/apache/geode/cache/query/types/ObjectType.html" title="interface in org.apache.geode.cache.query.types">ObjectType</a>, <a href="../../../org/apache/geode/cache/persistence/PersistentID.html" title="interface in org.apache.geode.cache.persistence">PersistentID</a>, <a href="../../../org/apache/geode/cache/query/types/StructType.html" title="interface in org.apache.geode.cache.query.types">StructType</a></dd>
</dl>
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../org/apache/geode/modules/gatewaydelta/AbstractGatewayDeltaEvent.html" title="class in org.apache.geode.modules.gatewaydelta">AbstractGatewayDeltaEvent</a>, <a href="../../../org/apache/geode/modules/util/BootstrappingFunction.html" title="class in org.apache.geode.modules.util">BootstrappingFunction</a>, <a href="../../../org/apache/geode/modules/util/CreateRegionFunction.html" title="class in org.apache.geode.modules.util">CreateRegionFunction</a>, <a href="../../../org/apache/geode/modules/session/catalina/DeltaSession.html" title="class in org.apache.geode.modules.session.catalina">DeltaSession</a>, <a href="../../../org/apache/geode/modules/session/catalina/DeltaSession7.html" title="class in org.apache.geode.modules.session.catalina">DeltaSession7</a>, <a href="../../../org/apache/geode/modules/session/catalina/DeltaSession8.html" title="class in org.apache.geode.modules.session.catalina">DeltaSession8</a>, <a href="../../../org/apache/geode/modules/session/catalina/DeltaSession9.html" title="class in org.apache.geode.modules.session.catalina">DeltaSession9</a>, <a href="../../../org/apache/geode/cache/ExpirationAttributes.html" title="class in org.apache.geode.cache">ExpirationAttributes</a>, <a href="../../../org/apache/geode/modules/gatewaydelta/GatewayDeltaCreateEvent.html" title="class in org.apache.geode.modules.gatewaydelta">GatewayDeltaCreateEvent</a>, <a href="../../../org/apache/geode/modules/gatewaydelta/GatewayDeltaDestroyEvent.html" title="class in org.apache.geode.modules.gatewaydelta">GatewayDeltaDestroyEvent</a>, <a href="../../../org/apache/geode/cache/MembershipAttributes.html" title="class in org.apache.geode.cache">MembershipAttributes</a>, <a href="../../../org/apache/geode/modules/util/RegionConfiguration.html" title="class in org.apache.geode.modules.util">RegionConfiguration</a>, <a href="../../../org/apache/geode/modules/util/RegionSizeFunction.html" title="class in org.apache.geode.modules.util">RegionSizeFunction</a>, <a href="../../../org/apache/geode/admin/RegionSubRegionSnapshot.html" title="class in org.apache.geode.admin">RegionSubRegionSnapshot</a>, <a href="../../../org/apache/geode/cache/server/ServerLoad.html" title="class in org.apache.geode.cache.server">ServerLoad</a>, <a href="../../../org/apache/geode/cache/SubscriptionAttributes.html" title="class in org.apache.geode.cache">SubscriptionAttributes</a>, <a href="../../../org/apache/geode/modules/util/TouchPartitionedRegionEntriesFunction.html" title="class in org.apache.geode.modules.util">TouchPartitionedRegionEntriesFunction</a>, <a href="../../../org/apache/geode/modules/util/TouchReplicatedRegionEntriesFunction.html" title="class in org.apache.geode.modules.util">TouchReplicatedRegionEntriesFunction</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">DataSerializable</span>
extends <a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a></pre>
<div class="block">An interface for objects whose state can be written/read as primitive types and strings ("data").
That is, instead of serializing itself to an <a href="https://docs.oracle.com/javase/8/docs/api/java/io/ObjectOutputStream.html?is-external=true" title="class or interface in java.io"><code>ObjectOutputStream</code></a>, a
<code>DataSerializable</code> can serialize itself to a <a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataOutput.html?is-external=true" title="class or interface in java.io"><code>DataOutput</code></a>. By implementing this
interface, objects can be serialized faster and in a more compact format than standard Java
serialization. The <a href="../../../org/apache/geode/DataSerializer.html" title="class in org.apache.geode"><code>DataSerializer</code></a> class contains a number of static methods that may be
helpful to implementations of <code>DataSerializable</code>.
<P>
When possible, GemFire respects the <code>DataSerializable</code> contract to provide optimal
object serialization. For instance, if a <code>DataSerializable</code> object is
<a href="../../../org/apache/geode/cache/Region.html#put-K-V-">placed</a> into a distributed cache
region, its <code>toData</code> method will be used to serialize it when it is sent to another
member of the distributed system.
<P>
To avoid the overhead of Java reflection, <code>DataSerializable</code> classes may register an
<a href="../../../org/apache/geode/Instantiator.html" title="class in org.apache.geode"><code>Instantiator</code></a> to be used during deserialization. Alternatively, classes that implement
<code>DataSerializable</code> can provide a zero-argument constructor that will be invoked when
they are read with <a href="../../../org/apache/geode/DataSerializer.html#readObject-java.io.DataInput-"><code>DataSerializer.readObject(java.io.DataInput)</code></a>.
<P>
Some classes (especially third-party classes that you may not have the source code to) cannot be
modified to implement <code>DataSerializable</code>. These classes can be data serialized by an
instance of <a href="../../../org/apache/geode/DataSerializer.html" title="class in org.apache.geode"><code>DataSerializer</code></a>.
<P>
<code>DataSerializable</code> offers improved performance over standard Java serialization, but
does not offer all of the features of standard Java serialization. In particular, data
serialization does not attempt to maintain referential integrity among the objects it is writing
or reading. As a result, data serialization should not be used with complex object graphs.
Attempting to data serialize graphs that contain object cycles will result in infinite recursion
and a <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/StackOverflowError.html?is-external=true" title="class or interface in java.lang"><code>StackOverflowError</code></a>. Attempting to deserialize an object graph that contains
multiple reference paths to the same object will result in multiple copies of the objects that
are referred to through multiple paths.
<CENTER>
<IMG src="../../../javadoc-images/data-serialization-exceptions.gif" alt="Examples of
situations in which DataSerializable behaviour differs from Java serialization" HEIGHT="219"
WIDTH="698">
</CENTER></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>GemFire 3.5</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io"><code>Serializable</code></a>,
<a href="../../../org/apache/geode/DataSerializer.html" title="class in org.apache.geode"><code>DataSerializer</code></a>,
<a href="../../../org/apache/geode/Instantiator.html" title="class in org.apache.geode"><code>Instantiator</code></a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Interface and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static interface&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../org/apache/geode/DataSerializable.Replaceable.html" title="interface in org.apache.geode">DataSerializable.Replaceable</a></span></code>
<div class="block"><code>Replaceable</code> allows an object to write an alternative version of itself to a
<code>DataOutput</code>.</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></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/geode/DataSerializable.html#fromData-java.io.DataInput-">fromData</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataInput.html?is-external=true" title="class or interface in java.io">DataInput</a>&nbsp;in)</code>
<div class="block">Reads the state of this object as primitive data from the given <code>DataInput</code>.</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/geode/DataSerializable.html#toData-java.io.DataOutput-">toData</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataOutput.html?is-external=true" title="class or interface in java.io">DataOutput</a>&nbsp;out)</code>
<div class="block">Writes the state of this object as primitive data to the given <code>DataOutput</code>.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="toData-java.io.DataOutput-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>toData</h4>
<pre>void&nbsp;toData(<a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataOutput.html?is-external=true" title="class or interface in java.io">DataOutput</a>&nbsp;out)
throws <a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
<div class="block">Writes the state of this object as primitive data to the given <code>DataOutput</code>.
<p>
Since 5.7 it is possible for any method call to the specified <code>DataOutput</code> to throw
<a href="../../../org/apache/geode/GemFireRethrowable.html" title="class in org.apache.geode"><code>GemFireRethrowable</code></a>. It should <em>not</em> be caught by user code. If it is it
<em>must</em> be rethrown.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>out</code> - the <a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataOutput.html?is-external=true" title="class or interface in java.io"><code>DataOutput</code></a> to write to</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - A problem occurs while writing to <code>out</code></dd>
</dl>
</li>
</ul>
<a name="fromData-java.io.DataInput-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>fromData</h4>
<pre>void&nbsp;fromData(<a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataInput.html?is-external=true" title="class or interface in java.io">DataInput</a>&nbsp;in)
throws <a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a>,
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a></pre>
<div class="block">Reads the state of this object as primitive data from the given <code>DataInput</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>in</code> - the <a href="https://docs.oracle.com/javase/8/docs/api/java/io/DataInput.html?is-external=true" title="class or interface in java.io"><code>DataInput</code></a> to read from</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - A problem occurs while reading from <code>in</code></dd>
<dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/ClassNotFoundException.html?is-external=true" title="class or interface in java.lang">ClassNotFoundException</a></code> - A class could not be loaded while reading from <code>in</code></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-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/geode/CopyHelper.html" title="class in org.apache.geode"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../org/apache/geode/DataSerializable.Replaceable.html" title="interface in org.apache.geode"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?org/apache/geode/DataSerializable.html" target="_top">Frames</a></li>
<li><a href="DataSerializable.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><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&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>Field&nbsp;|&nbsp;</li>
<li>Constr&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>