cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r568724 - in /cocoon/trunk: blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/parsing/ core/co...
Date Wed, 22 Aug 2007 18:34:47 GMT
Author: cziegeler
Date: Wed Aug 22 11:34:47 2007
New Revision: 568724

URL: http://svn.apache.org/viewvc?rev=568724&view=rev
Log:
Clean up interfaces a little bit.

Modified:
    cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/parsing/Subst.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/ObjectModel.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/provider/ObjectModelProvider.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java

Modified: cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java?rev=568724&r1=568723&r2=568724&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
(original)
+++ cocoon/trunk/blocks/cocoon-template/cocoon-template-impl/src/main/java/org/apache/cocoon/template/instruction/ForEach.java
Wed Aug 22 11:34:47 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -57,7 +57,7 @@
 
         String items = attrs.getValue("items");
         String select = attrs.getValue("select");
-        
+
         StringTemplateParser expressionCompiler = parsingContext.getStringTemplateParser();
         this.var = expressionCompiler.compileExpr(attrs.getValue("var"), null, locator);
         this.varStatus = expressionCompiler.compileExpr(attrs.getValue("varStatus"), null,
locator);
@@ -74,21 +74,21 @@
             throw new SAXParseException("forEach: only one of \"select\" or \"items\" may
be specified",
                                         locator, null);
         }
-        
+
         this.items = expressionCompiler.compileExpr(items == null ? select : items, null,
locator);
     }
 
     public Event execute(final XMLConsumer consumer,
                          ObjectModel objectModel, ExecutionContext executionContext,
-                         MacroContext macroContext, NamespacesTable namespaces, Event startEvent,
Event endEvent) 
+                         MacroContext macroContext, NamespacesTable namespaces, Event startEvent,
Event endEvent)
         throws SAXException {
         Iterator iter = null;
         int begin, end, step;
         String var = null, varStatus = null;
         try {
-            iter = (this.items != null ) 
+            iter = (this.items != null )
                     ? this.items.getIterator(objectModel)
-                    : Subst.NULL_ITER;
+                    : null;
             begin = this.begin == null
                 ? 0
                 : this.begin.getIntValue(objectModel);
@@ -101,7 +101,7 @@
 
             if ( this.var != null )
                 var = this.var.getStringValue(objectModel);
-            
+
             if ( this.varStatus != null )
                 varStatus = this.varStatus.getStringValue(objectModel);
         } catch (Exception exc) {
@@ -114,9 +114,13 @@
         objectModel.markLocalContext();
         int i = 0;
         // Move to the begin row
-        while (i < begin && iter.hasNext()) {
-            iter.next();
+        if ( iter == null ) {
             i++;
+        } else {
+            while (i < begin && iter.hasNext()) {
+                iter.next();
+                i++;
+            }
         }
         LoopTagStatus status = null;
         if (varStatus != null) {
@@ -152,11 +156,11 @@
             // Increase index
             i += step;
             count++;
-            
+
             objectModel.cleanupLocalContext();
         }
         objectModel.cleanupLocalContext();
-            
+
         return getEndInstruction().getNext();
     }
 }

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/parsing/Subst.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/parsing/Subst.java?rev=568724&r1=568723&r2=568724&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/parsing/Subst.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/el/parsing/Subst.java
Wed Aug 22 11:34:47 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,51 +25,23 @@
  */
 public interface Subst {
 
-    public Object getCompiledExpression();
+    Object getCompiledExpression();
 
-    public Object getNode(ObjectModel objectModel) throws Exception;
+    Object getNode(ObjectModel objectModel) throws Exception;
 
-    public Iterator getIterator(ObjectModel objectModel) throws Exception;
+    Iterator getIterator(ObjectModel objectModel) throws Exception;
 
-    public Boolean getBooleanValue(ObjectModel objectModel) throws Exception;
+    Boolean getBooleanValue(ObjectModel objectModel) throws Exception;
 
-    public String getStringValue(ObjectModel objectModel) throws Exception;
-
-    public Number getNumberValue(ObjectModel objectModel) throws Exception;
-
-    public int getIntValue(ObjectModel objectModel) throws Exception;
-
-    public Object getValue(ObjectModel objectModel) throws Exception;
-
-    public void setLenient(Boolean lenient);
-
-    public String getRaw();
-
-    public static final Iterator EMPTY_ITER = new Iterator() {
-            public boolean hasNext() {
-                return false;
-            }
-    
-            public Object next() {
-                return null;
-            }
-    
-            public void remove() {
-                // EMPTY
-            }
-        };
-    public static final Iterator NULL_ITER = new Iterator() {
-            public boolean hasNext() {
-                return true;
-            }
-    
-            public Object next() {
-                return null;
-            }
-    
-            public void remove() {
-                // EMPTY
-            }
-        };
-    // VOID
+    String getStringValue(ObjectModel objectModel) throws Exception;
+
+    Number getNumberValue(ObjectModel objectModel) throws Exception;
+
+    int getIntValue(ObjectModel objectModel) throws Exception;
+
+    Object getValue(ObjectModel objectModel) throws Exception;
+
+    void setLenient(Boolean lenient);
+
+    String getRaw();
 }

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/ObjectModel.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/ObjectModel.java?rev=568724&r1=568723&r2=568724&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/ObjectModel.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/ObjectModel.java
Wed Aug 22 11:34:47 2007
@@ -26,52 +26,52 @@
  */
 public interface ObjectModel extends Map {
 
-    static public String ROLE = ObjectModel.class.getName();
+    String ROLE = ObjectModel.class.getName();
 
-    public static final String CONTEXTBEAN = "contextBean";
+    String CONTEXTBEAN = "contextBean";
 
-    public static final String NAMESPACE = "namespace";
-    
-    public static final String PARAMETERS_PATH = "cocoon/parameters";
+    String NAMESPACE = "namespace";
+
+    String PARAMETERS_PATH = "cocoon/parameters";
 
     /**
      * @return a {@link MultiMap} that contains all stored values in all context in LIFO-compliant
order.
      *         Returned {@link MultiMap} is {@link org.apache.commons.collections.Unmodifiable}.
      */
-    public MultiMap getAll();
+    MultiMap getAll();
 
     /**
      * Works exactly the same way as {@link Map#put(Object, Object)} but previous value associated
to <code>key</code>
      * is not lost in a case {@link #markLocalContext()} was called before. The previous
value is stored and can be
      * recovered by calling {@link #markLocalContext()}.
      */
-    public Object put(Object key, Object value);
+    Object put(Object key, Object value);
 
     /**
      * @see #put(Object, Object)
      */
-    public void putAll(Map mapToCopy);
+    void putAll(Map mapToCopy);
 
     /**
      * Marks new local context. Such mark is useful to do a clean up of entries.
      */
-    public void markLocalContext();
+    void markLocalContext();
 
     /**
      * Cleans up entries put to ObjectModel since last {@link #markLocalContext()} call.
      */
-    public void cleanupLocalContext();
+    void cleanupLocalContext();
 
     /**
      * Puts object at certain <code>path</code>. Each segment of path is separated
by "/" symbol. This method
      * supports only traversing through objects implementing {@link Map} interface. If certain
segment does not exist it
      * will be created automatically.
-     * 
+     *
      * @param path
      *            where the <code>value</code> should be put at
      * @param value that is going to be put
      */
-    public void putAt(String path, Object value);
+    void putAt(String path, Object value);
 
     /**
      * <p>
@@ -79,15 +79,15 @@
      * when you want, for example, to access properties of context bean in JEXL expression
and omit
      * <code>contextBean.</code> part.
      * </p>
-     * 
+     *
      * @see org.apache.commons.jxpath.JXPathBeanInfo.isDynamic() for description of static
and dynamic properties
      */
-    public void fillContext();
-    
+    void fillContext();
+
     /**
      * <p>Sets parent object model so newly created instance can inherit values from
parent but cannot modify it.</p>
-     * 
+     *
      * @param parentObjectModel
      */
-    public void setParent(ObjectModel parentObjectModel);
+    void setParent(ObjectModel parentObjectModel);
 }

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/provider/ObjectModelProvider.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/provider/ObjectModelProvider.java?rev=568724&r1=568723&r2=568724&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/provider/ObjectModelProvider.java
(original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-api/src/main/java/org/apache/cocoon/objectmodel/provider/ObjectModelProvider.java
Wed Aug 22 11:34:47 2007
@@ -18,14 +18,14 @@
 
 
 /**
- * This simple interface should be implemented by Spring beans providing initial entries
for 
+ * This simple interface should be implemented by Spring beans providing initial entries
for
  * {@link org.apache.cocoon.objectmodel.ObjectModel}.
- * 
- * @version $Id: $
+ *
+ * @version $Id$
  * @since 2.2
  */
 public interface ObjectModelProvider {
-    
-    public Object getObject();
-    
+
+    Object getObject();
+
 }

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=568724&r1=568723&r2=568724&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
Wed Aug 22 11:34:47 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,20 @@
     private String raw;
     private Object compiledExpression;
 
+    protected static final Iterator NULL_ITER = new Iterator() {
+        public boolean hasNext() {
+            return true;
+        }
+
+        public Object next() {
+            return null;
+        }
+
+        public void remove() {
+            // EMPTY
+        }
+    };
+
     public JXTExpression(String raw, Object expr) {
         this.raw = raw;
         this.compiledExpression = expr;
@@ -70,17 +84,17 @@
                 // literal value
                 iter = new Iterator() {
                         Object val = this;
-                        
+
                         public boolean hasNext() {
                             return val != null;
                         }
-                        
+
                         public Object next() {
                             Object res = val;
                             val = null;
                             return res;
                         }
-                        
+
                         public void remove() {
                             // EMPTY
                         }



Mime
View raw message