You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by gv...@apache.org on 2005/12/03 18:31:08 UTC

svn commit: r351991 - in /struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain: AbstractCommand.java AssignChildrenCommand.java CreateComponentCommand.java

Author: gvanmatre
Date: Sat Dec  3 09:30:55 2005
New Revision: 351991

URL: http://svn.apache.org/viewcvs?rev=351991&view=rev
Log:
Minor refactoring to make the Clay symbol replacement case insensitive.

Modified:
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AssignChildrenCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java?rev=351991&r1=351990&r2=351991&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java Sat Dec  3 09:30:55 2005
@@ -109,7 +109,20 @@
               break replace;
             
             next: while (i > -1 && i <= (buff.length() - key.length())) {
-                int n = buff.indexOf(key, i);
+				
+				int n = -1;
+				indexOf: for (int s = i; s <= (buff.length() - key.length()); s++) {
+				   for (int c = 0; c < key.length(); c++) {
+				      char skey = Character.toLowerCase(key.charAt(c));
+					  char tkey = Character.toLowerCase(buff.charAt(s + c));
+					  if (skey != tkey)
+					    continue indexOf;
+				   }
+				   //match found
+				   n = s;
+				   break indexOf;
+				}
+				
                 if (n > -1) {
                     buff.delete(n, n + key.length());
                     buff.insert(n, value);

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AssignChildrenCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AssignChildrenCommand.java?rev=351991&r1=351990&r2=351991&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AssignChildrenCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AssignChildrenCommand.java Sat Dec  3 09:30:55 2005
@@ -19,8 +19,6 @@
 package org.apache.shale.clay.component.chain;
 
 import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
 
 import javax.faces.component.UIComponent;
 
@@ -29,7 +27,6 @@
 import org.apache.commons.chain.Context;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.component.Clay;
 import org.apache.shale.clay.config.Globals;
 import org.apache.shale.clay.config.beans.ComponentBean;
 
@@ -85,16 +82,7 @@
             subContext.setParent(parent);
             subContext.setChild(null);
             subContext.setChildIndex(childIndex);
-           
-            Map symbolTable = new TreeMap();
-            symbolTable.putAll(clayContext.getSymbols());
-            symbolTable.putAll(childDisplayElement.getSymbols());
-            if (parent instanceof Clay) {
-                symbolTable.putAll(((Clay) parent).getSymbols());
-            }
-
-            subContext.setSymbols(symbolTable);
-            
+                       
             Catalog catalog = getCatalog();
             Command command = catalog
                     .getCommand(Globals.ADD_COMPONENT_COMMAND_NAME);

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java?rev=351991&r1=351990&r2=351991&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java Sat Dec  3 09:30:55 2005
@@ -18,6 +18,9 @@
 
 package org.apache.shale.clay.component.chain;
 
+import java.util.Map;
+import java.util.TreeMap;
+
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
@@ -122,8 +125,21 @@
                     new Object[] { id, displayElement.getJsfid(), new Integer(clayContext.getChildIndex()) }));
         }
         
-		if (child instanceof Clay)
-		   ((Clay) child).getSymbols().putAll(clayContext.getSymbols());	
+		// create a new scoped symbol table
+        Map symbolTable = new TreeMap();
+		// inherit the parents symbols
+        symbolTable.putAll(clayContext.getSymbols());
+		// override config (XML, HTML) symbols
+        symbolTable.putAll(displayElement.getSymbols());
+		//if target is a Clay component it might contain symbols
+        if (child instanceof Clay) {
+			//override symbols from nested clay component
+            symbolTable.putAll(((Clay) child).getSymbols());
+			//capture current symbols for the root of the nested component
+			((Clay) child).getSymbols().putAll(symbolTable);
+        }
+		//push to context
+        clayContext.setSymbols(symbolTable);
 		
         // reassign the child to the converter for the
         // AssignPropertiesCommand



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org