📄 coercion.html
字号:
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 5. Coercing Objects to Types</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 Language Guide"><link rel="up" href="index.html" title="OGNL Language Guide"><link rel="previous" href="settingVersusGetting.html" title="Setting values versus getting values"><link rel="next" href="coerceNumber.html" title="Interpreting Objects as Numbers"></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 5. Coercing Objects to Types</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="settingVersusGetting.html"><img src="../images/navigation/prev.gif" alt="Prev"></a> </td><th align="center" width="60%"> </th><td align="right" width="20%"> <a accesskey="n" href="coerceNumber.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="coercion"></a>Chapter 5. Coercing Objects to Types</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="coercion.html#coerceBoolean">Interpreting Objects as Booleans</a></span></dt><dt><span class="section"><a href="coerceNumber.html">Interpreting Objects as Numbers</a></span></dt><dt><span class="section"><a href="coerceInteger.html">Interpreting Objects as Integers</a></span></dt><dt><span class="section"><a href="coerceCollection.html">Interpreting Objects as Collections</a></span></dt></dl></div><p>Here we describe how <span class="acronym">OGNL</span> interprets objects as various types. See below for how <span class="acronym">OGNL</span> coerces objects to booleans, numbers, integers, and collections.</p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="coerceBoolean"></a>Interpreting Objects as Booleans</h2></div></div><div></div></div><p>Any object can be used where a boolean is required. <span class="acronym">OGNL</span> interprets objects as booleans like this:</p><div class="itemizedlist"><ul type="disc"><li><p>If the object is a <tt class="classname">Boolean</tt>, its value is extracted and returned</p></li><li><p>If the object is a <tt class="classname">Number</tt>, its double-precision floating-point value is compared with zero; non-zero is treated as <tt class="constant">true</tt>, zero as <tt class="constant">false</tt>.</p></li><li><p>If the object is a <tt class="classname">Character</tt>, its boolean value is <tt class="constant">true</tt> if and only if its char value is non-zero.</p></li><li><p>Otherwise, its boolean value is <tt class="constant">true</tt> if and only if it is non-<tt class="constant">null</tt>.</p></li></ul></div></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="settingVersusGetting.html"><img src="../images/navigation/prev.gif" alt="Prev"></a> </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%"> <a accesskey="n" href="coerceNumber.html"><img src="../images/navigation/next.gif" alt="Next"></a></td></tr><tr><td valign="top" align="left" width="40%">Setting values versus getting values </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%"> Interpreting Objects as Numbers</td></tr></table></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -