You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2015/09/23 14:49:05 UTC
svn commit: r1704838 - in /sling/trunk/bundles/scripting/sightly:
engine/pom.xml
engine/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/expression/node/BinaryOperator.java
testing-content/pom.xml testing/pom.xml
Author: radu
Date: Wed Sep 23 12:49:05 2015
New Revision: 1704838
URL: http://svn.apache.org/viewvc?rev=1704838&view=rev
Log:
SLING-5053 - Add support for Enum comparison in Sightly scripts
* implemented support for Enum comparison like defined in version 1.2 draft of the Sightly specification
https://github.com/Adobe-Marketing-Cloud/sightly-spec/issues/19
https://github.com/Adobe-Marketing-Cloud/sightly-tck/issues/12
Modified:
sling/trunk/bundles/scripting/sightly/engine/pom.xml
sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/expression/node/BinaryOperator.java
sling/trunk/bundles/scripting/sightly/testing-content/pom.xml
sling/trunk/bundles/scripting/sightly/testing/pom.xml
Modified: sling/trunk/bundles/scripting/sightly/engine/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/engine/pom.xml?rev=1704838&r1=1704837&r2=1704838&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/engine/pom.xml (original)
+++ sling/trunk/bundles/scripting/sightly/engine/pom.xml Wed Sep 23 12:49:05 2015
@@ -78,7 +78,11 @@
<Embed-Dependency>antlr4-runtime,org.abego.treelayout.core</Embed-Dependency>
<ScriptEngine-Name>${project.name}</ScriptEngine-Name>
<ScriptEngine-Version>${project.version}</ScriptEngine-Version>
- <Provide-Capability>io.sightly; version:Version=1.0, io.sightly; version:Version=1.1</Provide-Capability>
+ <Provide-Capability>
+ io.sightly; version:Version=1.0,
+ io.sightly; version:Version=1.1,
+ io.sightly; version:Version=1.2
+ </Provide-Capability>
</instructions>
</configuration>
</plugin>
Modified: sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/expression/node/BinaryOperator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/expression/node/BinaryOperator.java?rev=1704838&r1=1704837&r2=1704838&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/expression/node/BinaryOperator.java (original)
+++ sling/trunk/bundles/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/compiler/expression/node/BinaryOperator.java Wed Sep 23 12:49:05 2015
@@ -198,6 +198,16 @@ public enum BinaryOperator {
if (left == null && right == null) {
return true;
}
+ if ((left instanceof Enum && right instanceof String) || (left instanceof String && right instanceof Enum)) {
+ String constantName = left instanceof String ? (String) left : (String) right;
+ Enum enumObject = left instanceof Enum ? (Enum) left : (Enum) right;
+ try {
+ Enum enumComparisonObject = Enum.valueOf(enumObject.getClass(), constantName);
+ return enumComparisonObject == enumObject;
+ } catch (Exception e) {
+ return false;
+ }
+ }
if (left == null || right == null) {
Object notNull = (left != null) ? left : right;
if (notNull instanceof String || notNull instanceof Boolean || notNull instanceof Number) {
Modified: sling/trunk/bundles/scripting/sightly/testing-content/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing-content/pom.xml?rev=1704838&r1=1704837&r2=1704838&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing-content/pom.xml (original)
+++ sling/trunk/bundles/scripting/sightly/testing-content/pom.xml Wed Sep 23 12:49:05 2015
@@ -100,7 +100,7 @@
<artifactItem>
<groupId>io.sightly</groupId>
<artifactId>io.sightly.tck</artifactId>
- <version>1.1.2</version>
+ <version>1.2.0</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/sightlytck/</outputDirectory>
<includes>**/*.html,**/*.js,**/*.java</includes>
Modified: sling/trunk/bundles/scripting/sightly/testing/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/testing/pom.xml?rev=1704838&r1=1704837&r2=1704838&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/sightly/testing/pom.xml (original)
+++ sling/trunk/bundles/scripting/sightly/testing/pom.xml Wed Sep 23 12:49:05 2015
@@ -203,7 +203,7 @@
<dependency>
<groupId>io.sightly</groupId>
<artifactId>io.sightly.tck</artifactId>
- <version>1.1.3</version>
+ <version>1.2.0</version>
<scope>test</scope>
<exclusions>
<exclusion>