sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-scripting-sightly-compiler-java] 35/50: SLING-6633 - [HTL] NumberFormat should support String-properties with number value
Date Wed, 18 Oct 2017 23:22:51 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit f6d17f4f36a9ab440cc80409f4f004ad3f5482b4
Author: Radu Cotescu <radu@apache.org>
AuthorDate: Mon Mar 13 13:45:20 2017 +0000

    SLING-6633 - [HTL] NumberFormat should support String-properties with number value
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1786688 13f79535-47bb-0310-9956-ffa450edef68
---
 .../scripting/sightly/render/AbstractRuntimeObjectModel.java     | 9 +++++++++
 1 file changed, 9 insertions(+)

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 aae53e4..514ca48 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
@@ -79,6 +79,9 @@ public abstract class AbstractRuntimeObjectModel implements RuntimeObjectModel
{
         if (target == null) {
             return false;
         }
+        if (target instanceof Number) {
+            return true;
+        }
         String value = toString(target);
         return NumberUtils.isNumber(value);
     }
@@ -107,6 +110,12 @@ public abstract class AbstractRuntimeObjectModel implements RuntimeObjectModel
{
 
     @Override
     public Number toNumber(Object object) {
+        if (object == null) {
+            return null;
+        }
+        if (object instanceof Number) {
+            return (Number) object;
+        }
         String stringValue = toString(object);
         try {
             return NumberUtils.createNumber(stringValue);

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

Mime
View raw message