⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elementsaccessors.html

📁 ONGL学习的好书,介绍ONGL的相关知识
💻 HTML
字号:
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter&nbsp;4.&nbsp;Elements Accessors</title><link href="../docbook.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.65.0" name="generator"><link rel="home" href="index.html" title="OGNL Developer Guide"><link rel="up" href="index.html" title="OGNL Developer Guide"><link rel="previous" href="methodAccessors.html" title="Chapter&nbsp;3.&nbsp;Method Accessors"><link rel="next" href="classReferences.html" title="Chapter&nbsp;5.&nbsp;Class References"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">Chapter&nbsp;4.&nbsp;Elements Accessors</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="methodAccessors.html"><img src="../images/navigation/prev.gif" alt="Prev"></a>&nbsp;</td><th align="center" width="60%">&nbsp;</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="classReferences.html"><img src="../images/navigation/next.gif" alt="Next"></a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="elementsAccessors"></a>Chapter&nbsp;4.&nbsp;Elements Accessors</h2></div></div><div></div></div><p>Since iteration is a built-in function of OGNL and many objects support the idea of iterating over the contents of an object (i.e. the <tt class="methodname">object.{ ... }</tt> syntax) OGNL provides a hook into how iteration is done. The
        <tt class="classname">ElementsAccessor</tt> interface defines how iteration is done based on a source object. Simple examples could be a <tt class="classname">Collection</tt> elements accessor, which would simply</p><pre class="programlisting">public interface ElementsAccessor
{
    public Enumeration getElements( Object target ) throws OgnlException;
}</pre><p>You can set a method accessor on a class-by-class basis using <tt class="methodname">OgnlRuntime.setElementsAccessor()</tt>. There are default elements accessors for <tt class="classname">Object</tt> (which returns an <tt class="classname">Enumeration</tt>
        of itself as the only object), <tt class="classname">Map</tt> (which iterates over the values in the <tt class="classname">Map</tt>), and Collection (which uses the collection's <tt class="methodname">iterator()</tt>). One clever use of
        <tt class="classname">ElementsAccessor</tt>s is the <tt class="classname">NumberElementsAccessor</tt> class which allows for generating numeric sequences from 0 to the target value. For example the expression <tt class="literal">(100).{ #this }</tt> will
        generate a list of 100 integers ranged 0..99.</p></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="methodAccessors.html"><img src="../images/navigation/prev.gif" alt="Prev"></a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="index.html"><img src="../images/navigation/up.gif" alt="Up"></a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="classReferences.html"><img src="../images/navigation/next.gif" alt="Next"></a></td></tr><tr><td valign="top" align="left" width="40%">Chapter&nbsp;3.&nbsp;Method Accessors&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html"><img src="../images/navigation/home.gif" alt="Home"></a></td><td valign="top" align="right" width="40%">&nbsp;Chapter&nbsp;5.&nbsp;Class References</td></tr></table></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -