cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r605958 - in /cocoon/trunk/core/cocoon-expression-language: cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/ cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/
Date Thu, 20 Dec 2007 15:13:12 GMT
Author: vgritsenko
Date: Thu Dec 20 07:13:11 2007
New Revision: 605958

URL: http://svn.apache.org/viewvc?rev=605958&view=rev
Log:
cleanup

Modified:
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/Expression.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/Expression.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/Expression.java?rev=605958&r1=605957&r2=605958&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/Expression.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/Expression.java
Thu Dec 20 07:13:11 2007
@@ -25,6 +25,10 @@
  */
 public interface Expression {
 
+    String getLanguage();
+
+    String getExpression();
+
     Object evaluate(ObjectModel objectModel)
             throws ExpressionException;
 
@@ -33,10 +37,6 @@
 
     void assign(ObjectModel objectModel, Object value)
             throws ExpressionException;
-
-    String getExpression();
-
-    String getLanguage();
 
     /*
      * This method is added to handle that JXPath have two access methods

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java?rev=605958&r1=605957&r2=605958&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
Thu Dec 20 07:13:11 2007
@@ -66,101 +66,104 @@
     // Geting the value of the expression in various forms
 
     // Hack: try to prevent JXPath from converting result to a String
-    public Object getNode(ObjectModel objectModel)
-        throws Exception {
-        Object compiled = this.getCompiledExpression();
-        if (compiled instanceof Expression)
-            return ((Expression)compiled).getNode(objectModel);
-        return this.getRaw();
+    public Object getNode(ObjectModel objectModel) throws Exception {
+        Object compiled = getCompiledExpression();
+        if (compiled instanceof Expression) {
+            return ((Expression) compiled).getNode(objectModel);
+        }
+
+        return getRaw();
     }
 
-    public Iterator getIterator(ObjectModel objectModel)
-        throws Exception {
-        Iterator iter = null;
-        if (this.getCompiledExpression() != null || this.getRaw() != null) {
-            if (this.getCompiledExpression() instanceof Expression) {
-                iter =
-                    ((Expression)this.getCompiledExpression()).iterate(objectModel);
+    public Iterator getIterator(ObjectModel objectModel) throws Exception {
+        Iterator iter;
+        if (getCompiledExpression() != null || getRaw() != null) {
+            if (getCompiledExpression() instanceof Expression) {
+                iter = ((Expression) this.getCompiledExpression()).iterate(objectModel);
             } else {
                 // literal value
                 iter = new Iterator() {
-                        Object val = this;
+                    Object val = this;
 
-                        public boolean hasNext() {
-                            return val != null;
+                    public boolean hasNext() {
+                        return val != null;
+                    }
+
+                    public Object next() {
+                        Object res = val;
+                        if (res != null ) {
+                            val = null;
+                            return res;
                         }
+                        throw new NoSuchElementException();
+                    }
 
-                        public Object next() {
-                            Object res = val;
-                            if (res != null ) {
-                                val = null;
-                                return res;
-                            }
-                            throw new NoSuchElementException();
-                        }
-
-                        public void remove() {
-                            // EMPTY
-                        }
-                    };
+                    public void remove() {
+                        // EMPTY
+                    }
+                };
             }
         } else {
             iter = NULL_ITER;
         }
+
         return iter;
     }
 
+    public Object getValue(ObjectModel objectModel) throws Exception {
+        Object compiled = getCompiledExpression();
+        if (compiled != null) {
+            if (compiled instanceof Expression) {
+                return ((Expression) compiled).evaluate(objectModel);
+            }
+
+            return compiled;
+        }
+
+        return getRaw();
+    }
+
     public Boolean getBooleanValue(ObjectModel objectModel)
         throws Exception {
         Object res = getValue(objectModel);
         return res instanceof Boolean ? (Boolean)res : null;
     }
 
-    public String getStringValue(ObjectModel objectModel)
-        throws Exception {
+    public String getStringValue(ObjectModel objectModel) throws Exception {
         Object res = getValue(objectModel);
         if (res != null) {
             return res.toString();
         }
-        if (this.getCompiledExpression() == null) {
-            return this.getRaw();
+
+        if (getCompiledExpression() == null) {
+            return getRaw();
         }
+
         return null;
     }
 
-    public Number getNumberValue(ObjectModel objectModel)
-        throws Exception {
+    public Number getNumberValue(ObjectModel objectModel) throws Exception {
         Object res = getValue(objectModel);
         if (res instanceof Number) {
-            return (Number)res;
+            return (Number) res;
         }
+
         if (res != null) {
             return Double.valueOf(res.toString());
         }
+
         return null;
     }
 
-    public int getIntValue(ObjectModel objectModel)
-        throws Exception {
+    public int getIntValue(ObjectModel objectModel) throws Exception {
         Object res = getValue(objectModel);
-        return res instanceof Number ? ((Number)res).intValue() : 0;
-    }
-
-    public Object getValue(ObjectModel objectModel)
-        throws Exception {
-        if (this.getCompiledExpression() != null) {
-            Object compiled = this.getCompiledExpression();
-            if (compiled instanceof Expression)
-                return ((Expression)compiled).evaluate(objectModel);
-            else
-                return compiled;
-        } else
-            return this.getRaw();
+        return res instanceof Number ? ((Number) res).intValue() : 0;
     }
 
     public void setLenient(Boolean lenient) {
-        if (this.compiledExpression instanceof Expression)
+        if (this.compiledExpression instanceof Expression) {
             //TODO: hack! bases on particular expression implementation.
-            ((Expression)this.compiledExpression).setProperty(JXPathExpression.LENIENT, lenient);
+            ((Expression) this.compiledExpression).setProperty(JXPathExpression.LENIENT,
lenient);
+        }
     }
 }



Mime
View raw message