blob: bf32f50655386856edc90eac23eba8d94ace1537 [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_281) on Sun Jan 15 15:58:35 CET 2023 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ObjectWrapperAndUnwrapper (FreeMarker 2.3.32 API)</title>
<meta name="date" content="2023-01-15">
<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="ObjectWrapperAndUnwrapper (FreeMarker 2.3.32 API)";
}
}
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="class-use/ObjectWrapperAndUnwrapper.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="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../freemarker/template/ResourceBundleLocalizedString.html" title="class in freemarker.template"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?freemarker/template/ObjectWrapperAndUnwrapper.html" target="_top">Frames</a></li>
<li><a href="ObjectWrapperAndUnwrapper.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><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>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">freemarker.template</div>
<h2 title="Interface ObjectWrapperAndUnwrapper" class="title">Interface ObjectWrapperAndUnwrapper</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Superinterfaces:</dt>
<dd><a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template">ObjectWrapper</a></dd>
</dl>
<dl>
<dt>All Known Subinterfaces:</dt>
<dd><a href="../../freemarker/template/utility/RichObjectWrapper.html" title="interface in freemarker.template.utility">RichObjectWrapper</a></dd>
</dl>
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../freemarker/ext/beans/BeansWrapper.html" title="class in freemarker.ext.beans">BeansWrapper</a>, <a href="../../freemarker/template/DefaultObjectWrapper.html" title="class in freemarker.template">DefaultObjectWrapper</a>, <a href="../../freemarker/ext/rhino/RhinoWrapper.html" title="class in freemarker.ext.rhino">RhinoWrapper</a>, <a href="../../freemarker/template/SimpleObjectWrapper.html" title="class in freemarker.template">SimpleObjectWrapper</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="typeNameLabel">ObjectWrapperAndUnwrapper</span>
extends <a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template">ObjectWrapper</a></pre>
<div class="block"><b>Experimental - subject to change:</b> Adds functionality to <a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template"><code>ObjectWrapper</code></a> that creates a plain Java object
from a <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a>. This is usually implemented by <a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template"><code>ObjectWrapper</code></a>-s and reverses
<a href="../../freemarker/template/ObjectWrapper.html#wrap-java.lang.Object-"><code>ObjectWrapper.wrap(Object)</code></a>. However, an implementation of this interface should make a reasonable effort to
"unwrap" <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a>-s that wasn't the result of object wrapping (such as those created directly in FTL),
or which was created by another <a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template"><code>ObjectWrapper</code></a>. The author of an <a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html" title="interface in freemarker.template"><code>ObjectWrapperAndUnwrapper</code></a> should be
aware of the <a href="../../freemarker/template/TemplateModelAdapter.html" title="interface in freemarker.template"><code>TemplateModelAdapter</code></a> and <a href="../../freemarker/ext/util/WrapperTemplateModel.html" title="interface in freemarker.ext.util"><code>WrapperTemplateModel</code></a> interfaces, which should be used for
unwrapping if the <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a> implements them.
<p>
<b>Experimental status warning:</b> This interface is subject to change on non-backward compatible ways, hence, it
shouldn't be implemented outside FreeMarker yet.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.3.22</dd>
</dl>
</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="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</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.lang.Object</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#CANT_UNWRAP_TO_TARGET_CLASS">CANT_UNWRAP_TO_TARGET_CLASS</a></span></code>
<div class="block">Indicates that while the unwrapping is <em>maybe</em> possible, the result surely can't be the instance of the
desired class, nor it can be <code>null</code>.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="fields.inherited.from.class.freemarker.template.ObjectWrapper">
<!-- -->
</a>
<h3>Fields inherited from interface&nbsp;freemarker.template.<a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template">ObjectWrapper</a></h3>
<code><a href="../../freemarker/template/ObjectWrapper.html#BEANS_WRAPPER">BEANS_WRAPPER</a>, <a href="../../freemarker/template/ObjectWrapper.html#DEFAULT_WRAPPER">DEFAULT_WRAPPER</a>, <a href="../../freemarker/template/ObjectWrapper.html#SIMPLE_WRAPPER">SIMPLE_WRAPPER</a></code></li>
</ul>
</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>java.lang.Object</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#tryUnwrapTo-freemarker.template.TemplateModel-java.lang.Class-">tryUnwrapTo</a></span>(<a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template">TemplateModel</a>&nbsp;tm,
java.lang.Class&lt;?&gt;&nbsp;targetClass)</code>
<div class="block">Attempts to unwrap a <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a> to a plain Java object that's the instance of the given class (or is
<code>null</code>).</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>java.lang.Object</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#unwrap-freemarker.template.TemplateModel-">unwrap</a></span>(<a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template">TemplateModel</a>&nbsp;tm)</code>
<div class="block">Unwraps a <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a> to a plain Java object.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.freemarker.template.ObjectWrapper">
<!-- -->
</a>
<h3>Methods inherited from interface&nbsp;freemarker.template.<a href="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template">ObjectWrapper</a></h3>
<code><a href="../../freemarker/template/ObjectWrapper.html#wrap-java.lang.Object-">wrap</a></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="CANT_UNWRAP_TO_TARGET_CLASS">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>CANT_UNWRAP_TO_TARGET_CLASS</h4>
<pre>static final&nbsp;java.lang.Object CANT_UNWRAP_TO_TARGET_CLASS</pre>
<div class="block">Indicates that while the unwrapping is <em>maybe</em> possible, the result surely can't be the instance of the
desired class, nor it can be <code>null</code>.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.3.22</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#tryUnwrapTo-freemarker.template.TemplateModel-java.lang.Class-"><code>tryUnwrapTo(TemplateModel, Class)</code></a></dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="unwrap-freemarker.template.TemplateModel-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>unwrap</h4>
<pre>java.lang.Object&nbsp;unwrap(<a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template">TemplateModel</a>&nbsp;tm)
throws <a href="../../freemarker/template/TemplateModelException.html" title="class in freemarker.template">TemplateModelException</a></pre>
<div class="block">Unwraps a <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a> to a plain Java object.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The plain Java object. Can be <code>null</code>, if <code>null</code> is the appropriate Java value to represent
the template model. <code>null</code> must not be used to indicate an unwrapping failure. It must NOT be
<a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#CANT_UNWRAP_TO_TARGET_CLASS"><code>CANT_UNWRAP_TO_TARGET_CLASS</code></a>.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../freemarker/template/TemplateModelException.html" title="class in freemarker.template">TemplateModelException</a></code> - If the unwrapping fails from any reason.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.3.22</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#tryUnwrapTo-freemarker.template.TemplateModel-java.lang.Class-"><code>tryUnwrapTo(TemplateModel, Class)</code></a></dd>
</dl>
</li>
</ul>
<a name="tryUnwrapTo-freemarker.template.TemplateModel-java.lang.Class-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>tryUnwrapTo</h4>
<pre>java.lang.Object&nbsp;tryUnwrapTo(<a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template">TemplateModel</a>&nbsp;tm,
java.lang.Class&lt;?&gt;&nbsp;targetClass)
throws <a href="../../freemarker/template/TemplateModelException.html" title="class in freemarker.template">TemplateModelException</a></pre>
<div class="block">Attempts to unwrap a <a href="../../freemarker/template/TemplateModel.html" title="interface in freemarker.template"><code>TemplateModel</code></a> to a plain Java object that's the instance of the given class (or is
<code>null</code>).</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>targetClass</code> - The class that the return value must be an instance of (except when the return value is <code>null</code>).
Can't be <code>null</code>; if the caller doesn't care, it should either use {#unwrap(TemplateModel)}, or
<code>Object.class</code> as the parameter value.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The unwrapped value that's either an instance of <code>targetClass</code>, or is <code>null</code> (if <code>null</code>
is the appropriate Java value to represent the template model), or is
<a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#CANT_UNWRAP_TO_TARGET_CLASS"><code>CANT_UNWRAP_TO_TARGET_CLASS</code></a> if the unwrapping can't satisfy the <code>targetClass</code> (nor the
result can be <code>null</code>). However, <a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#CANT_UNWRAP_TO_TARGET_CLASS"><code>CANT_UNWRAP_TO_TARGET_CLASS</code></a> must not be returned if the
<code>targetClass</code> parameter was <code>Object.class</code>.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code><a href="../../freemarker/template/TemplateModelException.html" title="class in freemarker.template">TemplateModelException</a></code> - If the unwrapping fails for a reason than doesn't fit the meaning of the
<a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#CANT_UNWRAP_TO_TARGET_CLASS"><code>CANT_UNWRAP_TO_TARGET_CLASS</code></a> return value.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.3.22</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../freemarker/template/ObjectWrapperAndUnwrapper.html#unwrap-freemarker.template.TemplateModel-"><code>unwrap(TemplateModel)</code></a></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/ObjectWrapperAndUnwrapper.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="../../freemarker/template/ObjectWrapper.html" title="interface in freemarker.template"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../freemarker/template/ResourceBundleLocalizedString.html" title="class in freemarker.template"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../index.html?freemarker/template/ObjectWrapperAndUnwrapper.html" target="_top">Frames</a></li>
<li><a href="ObjectWrapperAndUnwrapper.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><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>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>