blob: 97fbfc68857a85d732072c0a5cb54bb70a26ea8d [file] [log] [blame]
<!doctype html>
<!-- Generated by FreeMarker/Docgen from DocBook -->
<html lang="en" class="page-type-section">
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<title>Containers - FreeMarker Manual</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="format-detection" content="telephone=no">
<meta property="og:site_name" content="FreeMarker Manual">
<meta property="og:title" content="Containers">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="http://example.com/pgui_datamodel_parent.html">
<link rel="canonical" href="http://example.com/pgui_datamodel_parent.html">
<link rel="icon" href="favicon.png" type="image/png">
<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1594338519184">
</head>
<body itemscope itemtype="https://schema.org/Code">
<meta itemprop="url" content="http://example.com/">
<meta itemprop="name" content="FreeMarker Manual">
<!--[if lte IE 9]>
<div style="background-color: #C00; color: #fff; padding: 12px 24px;">Please use a modern browser to view this website.</div>
<![endif]--><div class="header-top-bg"><div class="site-width header-top"><a class="logo" href="http://example.com" role="banner"> <img itemprop="image" src="logo.png" alt="My Logo">
</a></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">FreeMarker Manual</a><div class="navigation-header"></div></div><div class="site-width breadcrumb-row"><ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui.html"><span itemprop="name">Programmer&#39;s Guide</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_datamodel.html"><span itemprop="name">The Data Model</span></a></li><li class="step-3" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_datamodel_parent.html"><span itemprop="name">Containers</span></a></li></ul><div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul class="bookmark-list"><li><a href="alphaidx.html">Index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="ref.html">Reference</a></li><li><a href="app_faq.html">FAQ</a></li><li><a href="preface.html#test_target">Bőregér</a></li><li><a href="api/index.html">API</a></li><li><a href="../index.html">Home</a></li></ul></div></div></div> <div class="main-content site-width">
<div class="content-wrapper">
<div id="table-of-contents-wrapper" class="col-left">
<script>var breadcrumb = ["FreeMarker Manual","Programmer\'s Guide","The Data Model","Containers"];</script>
<script src="toc.js?1594338519184"></script>
<script src="docgen-resources/main.min.js?1594338519184"></script>
</div>
<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="pgui_datamodel_scalar.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_datamodel_method.html"><span>Next</span></a></div><div class="title-wrapper">
<h1 class="content-header header-section1" id="pgui_datamodel_parent" itemprop="headline">Containers</h1>
</div></div><div class="page-menu">
<div class="page-menu-title">Page Contents</div>
<ul><li><a class="page-menu-link" href="#autoid_32" data-menu-target="autoid_32">Hashes</a></li><li><a class="page-menu-link" href="#autoid_33" data-menu-target="autoid_33">Sequences</a></li><li><a class="page-menu-link" href="#autoid_34" data-menu-target="autoid_34">Collections</a></li></ul> </div><p>These are hashes, sequences, and collections.</p>
<h2 class="content-header header-section2" id="autoid_32">Hashes</h2>
<p>Hashes are java objects that implement
<code class="inline-code">TemplateHashModel</code> interface.
<code class="inline-code">TemplateHashModel</code> contains two methods:
<code class="inline-code">TemplateModel get(String key)</code>, which returns the
subvariable of the given name, and <code class="inline-code">boolean
isEmpty()</code>, which indicates if the hash has zero
subvariable or not. The <code class="inline-code">get</code> method returns null
if no subvariable with the given name exists.</p>
<p>The <code class="inline-code">TemplateHashModelEx</code> interface extends
<code class="inline-code">TemplateHashModel</code>. It adds methods by which <a href="ref_builtins_hash.html#ref_builtin_values">values</a> and <a href="ref_builtins_hash.html#ref_builtin_keys">keys</a> built-ins can enumerate the
subvariables of the hash.</p>
<p>The commonly used implementation is
<code class="inline-code">SimpleHash</code>, which implements
<code class="inline-code">TemplateHashModelEx</code>. Internally it uses a
<code class="inline-code">java.util.Hash</code> to store the subvariables.
<code class="inline-code">SimpleHash</code> has methods by which you can add and
remove subvariable. These methods should be used to initialize the
variable directly after its creation.</p>
<p>Containers are immutable within FTL. That is, you can&#39;t add,
replace or remove the subvariables they contain.</p>
<h2 class="content-header header-section2" id="autoid_33">Sequences</h2>
<p>Sequences are java objects that implement
<code class="inline-code">TemplateSequenceModel</code>. It contains two methods:
<code class="inline-code">TemplateModel get(int index)</code> and <code class="inline-code">int
size()</code>.</p>
<p>The commonly used implementation is
<code class="inline-code">SimpleSequence</code>. It uses internally a
<code class="inline-code">java.util.List</code> to store its subvariables.
<code class="inline-code">SimpleSequence</code> has methods by which you can add
subvariables. These methods should be used to populate the sequence
directly after its creation.</p>
<h2 class="content-header header-section2" id="autoid_34">Collections</h2>
<p>Collections are java objects that implement the
<code class="inline-code">TemplateCollectionModel</code> interface. That interface
has one method: <code class="inline-code">TemplateModelIterator iterator()</code>.
The <code class="inline-code">TemplateModelIterator</code> interface is similar to
<code class="inline-code">java.util.Iterator</code>, but it returns
<code class="inline-code">TemplateModels</code> instead of
<code class="inline-code">Object</code>-s, and it can throw
<code class="inline-code">TemplateModelException</code>s.</p>
<p>The commonly used implementation is
<code class="inline-code">SimpleCollection</code>.</p>
<div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="pgui_datamodel_scalar.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_datamodel_method.html"><span>Next</span></a></div></div></div></div> </div>
</div>
<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"></div><div class="col-right"><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated">
Last generated:
<time itemprop="dateModified" datetime="2020-07-09T23:48:39Z" title="Thursday, July 9, 2020 11:48:39 PM GMT">2020-07-09 23:48:39 GMT</time> </p>
<p class="copyright">
© <span itemprop="copyrightYear">1999</span>–2020
<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="https://apache.org/">The Apache Software Foundation</a> </p>
</div></div></div></body>
</html>