Author: cbrisson
Date: Fri Apr  5 14:49:57 2019
New Revision: 1857011

URL: http://svn.apache.org/viewvc?rev=1857011&view=rev
Log:
[site/engine] #if() empty checks clarification

Modified:
    velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext
    velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext
    velocity/site/cms/trunk/content/engine/devel/configuration.mdtext
    velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext

Modified: velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext
URL: 
http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff
==============================================================================
--- velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext (original)
+++ velocity/site/cms/trunk/content/engine/2.1/configuration.mdtext Fri Apr  5 
14:49:57 2019
@@ -122,17 +122,17 @@ The following tree gathers all non depre
 
 **`directive.if.empty_check = true`**
 
-> When evaluating if a reference resolves to `true` or `false` in a boolean 
context, the engine first checks if its value is null, if it is a Boolean or if 
it has a getAsBoolean() method. Then, if none of this applies, the behavior 
depends upon this configuration flag:
+> When evaluating if a reference resolves to `true` or `false` in a boolean 
context, the engine first checks if its value is `null`, if it is a `Boolean` 
or if it has a public `getAsBoolean()` method. Then, if none of this applies, 
the behavior depends upon this configuration flag:
 >
 > - if `directive.if.empty_check` is `false`, no further check is performed 
 > and the object resolves to `true`.
 > - if `directive.if.empty_check` is `true`, the object is check for emptiness 
 > and zero value:
 >     - return whether an array is empty.
->     - return whether isEmpty() is false (covers String and all Collection 
classes).
->     - return whether length() is zero (covers CharSequence classes other 
than String).
->     - returns whether size() is zero (covers all Collections classes).
->     - return whether a Number *strictly* equals zero.
->     - return whether the result of getAsString() is empty (and false for a 
null result) if it exists.
->     - return whether the result of getAsNumber() *strictly* equals zero (and 
false for a null result) if it exists.
+>     - return whether a public `isEmpty()` method exists and evaluates to 
false (`String`, `Collection`, etc).
+>     - return whether a public `length()` method exists and evaluates to zero 
(`CharSequence`, etc).
+>     - return whether a public `size()` method exists and evaluates to zero.
+>     - return whether a `Number` *strictly* equals zero.
+>     - return whether a public `getAsString()` method exists and evaluates to 
null or an empty string.
+>     - return whether a public `getAsNumber()` method exists and evaluates to 
null or *strictly* zero.
 
 ### #include() and #parse() Directives
 

Modified: velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext
URL: 
http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff
==============================================================================
--- velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext (original)
+++ velocity/site/cms/trunk/content/engine/2.1/user-guide.mdtext Fri Apr  5 
14:49:57 2019
@@ -503,9 +503,9 @@ The variable *$foo* is evaluated to dete
 + *$foo* is a boolean (true/false) which has a true value
 + *$foo* is a string or a collection which is not null **and** not empty
 + *$foo* is a number which is not equal to zero
-+ *$foo* is an object (other than a string, a number or a collection) which is 
not null
++ *$foo* is an object (other than a string, a number or a collection) which is 
not null (and for which the standard public methods for querying the object 
size, length or boolean/string representations, if they exist, indicate a 
non-empty, non-zero, non-false object).
 
-(please note that this is the default behavior, but Velocity can be configured 
to [skip all checks beyond boolean and nullity 
ones](configuration.html#if-directive)).
+Please check the [#if directive configuration 
section](configuration.html#if-directive) for implementation details. This 
section also explains how to change this default behavior so that Velocity 
skips all checks beyond boolean and nullity ones.
 
 To test if a reference has a special values, you can use:
 
@@ -1226,9 +1226,10 @@ There is a property, meant to be used in
 
 which defaults to false.  When set to true *along with*
 
-    `resource.loader.<name>.cache = false`
 
-(where <name> is the name of the resource loader that you are using, such as 
'file') then the Velocity engine will automatically reload changes to your 
Velocimacro library files when you make them, so you do not have to dump the 
servlet engine (or application) or do other tricks to have your Velocimacros 
reloaded.
+    `resource.loader.<type>.cache = false`
+
+(where <type> is the name of the resource loader that you are using, such as 
'file') then the Velocity engine will automatically reload changes to your 
Velocimacro library files when you make them, so you do not have to dump the 
servlet engine (or application) or do other tricks to have your Velocimacros 
reloaded.
 
 Here is what a simple set of configuration properties would look like.
 

Modified: velocity/site/cms/trunk/content/engine/devel/configuration.mdtext
URL: 
http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/devel/configuration.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff
==============================================================================
--- velocity/site/cms/trunk/content/engine/devel/configuration.mdtext (original)
+++ velocity/site/cms/trunk/content/engine/devel/configuration.mdtext Fri Apr  
5 14:49:57 2019
@@ -122,17 +122,17 @@ The following tree gathers all non depre
 
 **`directive.if.empty_check = true`**
 
-> When evaluating if a reference resolves to `true` or `false` in a boolean 
context, the engine first checks if its value is null, if it is a Boolean or if 
it has a getAsBoolean() method. Then, if none of this applies, the behavior 
depends upon this configuration flag:
+> When evaluating if a reference resolves to `true` or `false` in a boolean 
context, the engine first checks if its value is `null`, if it is a `Boolean` 
or if it has a public `getAsBoolean()` method. Then, if none of this applies, 
the behavior depends upon this configuration flag:
 >
 > - if `directive.if.empty_check` is `false`, no further check is performed 
 > and the object resolves to `true`.
 > - if `directive.if.empty_check` is `true`, the object is check for emptiness 
 > and zero value:
 >     - return whether an array is empty.
->     - return whether isEmpty() is false (covers String and all Collection 
classes).
->     - return whether length() is zero (covers CharSequence classes other 
than String).
->     - returns whether size() is zero (covers all Collections classes).
->     - return whether a Number *strictly* equals zero.
->     - return whether the result of getAsString() is empty (and false for a 
null result) if it exists.
->     - return whether the result of getAsNumber() *strictly* equals zero (and 
false for a null result) if it exists.
+>     - return whether a public `isEmpty()` method exists and evaluates to 
false (`String`, `Collection`, etc).
+>     - return whether a public `length()` method exists and evaluates to zero 
(`CharSequence`, etc).
+>     - return whether a public `size()` method exists and evaluates to zero.
+>     - return whether a `Number` *strictly* equals zero.
+>     - return whether a public `getAsString()` method exists and evaluates to 
null or an empty string.
+>     - return whether a public `getAsNumber()` method exists and evaluates to 
null or *strictly* zero.
 
 ### #include() and #parse() Directives
 

Modified: velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext
URL: 
http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext?rev=1857011&r1=1857010&r2=1857011&view=diff
==============================================================================
--- velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext (original)
+++ velocity/site/cms/trunk/content/engine/devel/user-guide.mdtext Fri Apr  5 
14:49:57 2019
@@ -503,9 +503,9 @@ The variable *$foo* is evaluated to dete
 + *$foo* is a boolean (true/false) which has a true value
 + *$foo* is a string or a collection which is not null **and** not empty
 + *$foo* is a number which is not equal to zero
-+ *$foo* is an object (other than a string, a number or a collection) which is 
not null
++ *$foo* is an object (other than a string, a number or a collection) which is 
not null (and for which the standard public methods for querying the object 
size, length or boolean/string representations, if they exist, indicate a 
non-empty, non-zero, non-false object).
 
-(please note that this is the default behavior, but Velocity can be configured 
to [skip all checks beyond boolean and nullity 
ones](configuration.html#if-directive)).
+Please check the [#if directive configuration 
section](configuration.html#if-directive) for implementation details. This 
section also explains how to change this default behavior so that Velocity 
skips all checks beyond boolean and nullity ones.
 
 To test if a reference has a special values, you can use:
 


Reply via email to