You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:11:34 UTC

[sling-org-apache-sling-scripting-sightly-compiler] 21/31: SLING-6428 - DateFormat is printed when date-value is empty

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.compiler.java-1.0.10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler.git

commit 4902b93e88fddbc263be0d50a80bd377aeac9bb8
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue Jan 10 09:10:59 2017 +0000

    SLING-6428 - DateFormat is printed when date-value is empty
    
    * applied patch from Vlad Băilescu
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/scripting/sightly/java-compiler@1778098 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sightly/render/AbstractRuntimeObjectModel.java     |  4 ++--
 .../scripting/sightly/render/RuntimeObjectModel.java   | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java b/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java
index e4f84b0..357d680 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/render/AbstractRuntimeObjectModel.java
@@ -104,7 +104,7 @@ public abstract class AbstractRuntimeObjectModel implements RuntimeObjectModel {
         if (object instanceof Number) {
             return (Number) object;
         }
-        return 0;
+        return null;
     }
 
     public Date toDate(Object object) {
@@ -113,7 +113,7 @@ public abstract class AbstractRuntimeObjectModel implements RuntimeObjectModel {
         } else if (object instanceof Calendar) {
             return ((Calendar)object).getTime();
         }
-        return new Date(0);
+        return null;
     }
 
     @Override
diff --git a/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java b/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java
index 6d8f6e0..f386634 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/render/RuntimeObjectModel.java
@@ -45,8 +45,20 @@ public interface RuntimeObjectModel {
      */
     boolean isCollection(Object target);
 
+    /**
+     * Checks if the provided object represents a number or not.
+     *
+     * @param target the target object
+     * @return {@code true} if the {@code target} is a number, {@code false} otherwise
+     */
     boolean isNumber(Object target);
 
+    /**
+     * Checks if the provided object represents a date or calendar.
+     *
+     * @param target the target object
+     * @return {@code true} if the {@code target} is a date or calendar, {@code false} otherwise
+     */
     boolean isDate(Object target);
 
     /**
@@ -75,6 +87,12 @@ public interface RuntimeObjectModel {
      */
     Number toNumber(Object object);
 
+    /**
+     * Convert the given object to a {@link Date} object
+     *
+     * @param object the target object
+     * @return the date represented by the {@code object}
+     */
     Date toDate(Object object);
 
     /**

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.