Type Coercion"

From Documentation
m (Created page with '{{ZUMLReferencePageHeader}} EL expressions will coerce the type automatically. Here is the summary of the coercion rules. {| border='1px' | width="100%" ! !! Boolean !! Charac…')
 
m
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
EL expressions will coerce the type automatically. Here is the summary of the coercion rules.
 
EL expressions will coerce the type automatically. Here is the summary of the coercion rules.
 +
 +
<blockquote>
 +
----
 +
'''Note:''' The coercion is also applied to function arguments. For example, <code>{c:doSomething(null)}</code> will cause <code>doSomething("")</code> being called if it expects a  String object.
 +
</blockquote>
  
 
{| border='1px' | width="100%"
 
{| border='1px' | width="100%"
Line 28: Line 33:
 
| obj.charAt(0)
 
| obj.charAt(0)
 
| Number<ref>The real class is determined at run time, such as Integer and Float.</ref>.valueOf(x)
 
| Number<ref>The real class is determined at run time, such as Integer and Float.</ref>.valueOf(x)
| --
+
| obj
 
|-
 
|-
 
| String (empty)
 
| String (empty)
Line 34: Line 39:
 
| (char)0
 
| (char)0
 
| 0
 
| 0
| obj
+
| "" (obj)
 
|-
 
|-
 
| null
 
| null
Line 52: Line 57:
 
<references/>
 
<references/>
 
</blockquote>
 
</blockquote>
 +
 +
* The handling of an empty string and null is the same
  
 
=Version History=
 
=Version History=

Latest revision as of 11:04, 27 May 2011



EL expressions will coerce the type automatically. Here is the summary of the coercion rules.


Note: The coercion is also applied to function arguments. For example, {c:doSomething(null)} will cause doSomething("") being called if it expects a String object.

Boolean Character Number String
Boolean obj[1] ERROR ERROR obj.toString()
Character ERROR obj (short)obj obj.toString()
Number obj ERROR (char)obj obj.toString()
String (not empty) Boolean.valueOf(obj) obj.charAt(0) Number[2].valueOf(x) obj
String (empty) false (char)0 0 "" (obj)
null false (char)0 0 ""
Other ERROR ERROR ERROR obj.toString()

  1. obj represents the object being corerced
  2. The real class is determined at run time, such as Integer and Float.
  • The handling of an empty string and null is the same

Version History

Last Update : 2011/05/27


Version Date Content
     



Last Update : 2011/05/27

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.