Modified: 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
URL: 
http://svn.apache.org/viewvc/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java?rev=420232&r1=420231&r2=420232&view=diff
==============================================================================
--- 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
 (original)
+++ 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/ClayAmalgam.java
 Sat Jul  8 17:24:24 2006
@@ -41,29 +41,41 @@
 import org.apache.shale.util.Tags;
 
 /**
- * <p>This class is a mix of runtime utilities for the
- * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component.
- * It is loaded as a managed bean in application scope by
- * the clay component's registration.</p>
+ * <p>
+ * This class is a mix of runtime utilities for the
+ * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component. It is 
loaded as a
+ * managed bean in application scope by the clay component's registration.
+ * </p>
  */
 public class ClayAmalgam {
 
     /**
-     * <p>Message resources for this class.</p>
+     * <p>
+     * Message resources for this class.
+     * </p>
      */
-    private static Messages messages = new 
Messages("org.apache.shale.clay.Bundle",
-            ClayConfigureListener.class.getClassLoader());
+    private static Messages messages = new Messages(
+            "org.apache.shale.clay.Bundle", ClayConfigureListener.class
+                    .getClassLoader());
 
     /**
-     * <p>Shale tag helper class that contains utility methods for setting
-     * component binding and method properties.</p>
+     * <p>
+     * Shale tag helper class that contains utility methods for setting
+     * component binding and method properties.
+     * </p>
      */
     private Tags tagUtils = new Tags();
 
-
     /**
-     * <p>Replaces tokens in the <code>document</code> with
-     * matching tokens in the <code>context</code>.</p>
+     * <p>
+     * Replaces tokens in the <code>document</code> with matching tokens in
+     * the <code>context</code>.
+     * </p>
+     *
+     * @param document
+     *            containing tokens to replace
+     * @param context
+     *            tokens
      */
     protected void replace(StringBuffer document, Map context) {
 
@@ -93,7 +105,9 @@
     }
 
     /**
-     * <p>Mapping used to encode special characters.</p>
+     * <p>
+     * Mapping used to encode special characters.
+     * </p>
      */
     private static TreeMap encodeMap = null;
     static {
@@ -107,7 +121,13 @@
     }
 
     /**
-     * <p>Encodes a string value using the <code>encodeMap</code>.</p>
+     * <p>
+     * Encodes a string value using the <code>encodeMap</code>.
+     * </p>
+     *
+     * @param value
+     *            source string
+     * @return target encode string
      */
     public String encode(String value) {
         StringBuffer buff = new StringBuffer(value);
@@ -116,7 +136,9 @@
     }
 
     /**
-     * <p>Mapping used to decode special characters.</p>
+     * <p>
+     * Mapping used to decode special characters.
+     * </p>
      */
     private static TreeMap decodeMap = null;
     static {
@@ -131,7 +153,13 @@
     }
 
     /**
-     * <p>Decodes a string value using the <code>decodeMap</code>.</p>
+     * <p>
+     * Decodes a string value using the <code>decodeMap</code>.
+     * </p>
+     *
+     * @param value
+     *            source string
+     * @return decoded value
      */
     public String decode(String value) {
         StringBuffer buff = new StringBuffer(value);
@@ -139,21 +167,32 @@
         return buff.toString();
     }
 
-
     /**
-     * <p>This is a method binding "validator" signature that can be bound to 
the
-     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
-     * component.  It expects that the <code>value</code> attribute will 
contain an html string that
-     * represents an HTML node.  The value will be encode or decode depending 
on the value of the
-     * <code>escapeXml</code> optional attribute.  The default is "false". </p>
+     * <p>
+     * This is a method binding "validator" signature that can be bound to the
+     * <code>shapeValidator</code> attribute of the
+     * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component. It 
expects that
+     * the <code>value</code> attribute will contain an html string that
+     * represents an HTML node. The value will be encode or decode depending on
+     * the value of the <code>escapeXml</code> optional attribute. The default
+     * is "false".
+     * </p>
+     *
+     * @param context
+     *            faces context
+     * @param component
+     *            clay
+     * @param displayElementRoot
+     *            config bean
      */
     public void clayOut(javax.faces.context.FacesContext context,
             javax.faces.component.UIComponent component,
             java.lang.Object displayElementRoot) {
 
-        if (!(displayElementRoot instanceof ComponentBean) ||
-                !(component instanceof Clay)) {
-            throw new RuntimeException(messages.getMessage("invalid.binding", 
new Object[] {"clayOut"}));
+        if (!(displayElementRoot instanceof ComponentBean)
+                || !(component instanceof Clay)) {
+            throw new RuntimeException(messages.getMessage("invalid.binding",
+                    new Object[] { "clayOut" }));
         }
 
         ComponentBean text = (ComponentBean) displayElementRoot;
@@ -161,19 +200,21 @@
         String value = (String) clay.getAttributes().get("value");
         value = tagUtils.evalString(value);
         if (value == null) {
-            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayOut"}));
+            throw new IllegalArgumentException(messages.getMessage(
+                    "missing.attribute", new Object[] { "value", "clayOut" }));
         }
 
         boolean escapeXml = false;
         String tmp = (String) clay.getAttributes().get("escapeXml");
         if (tmp != null) {
-           escapeXml =  tagUtils.evalBoolean(tmp).booleanValue();
+            escapeXml = tagUtils.evalBoolean(tmp).booleanValue();
         }
 
-        if (!escapeXml)
+        if (!escapeXml) {
             value = decode(value);
-        else
+        } else {
             value = encode(value);
+        }
 
         text.setJsfid("outputText");
         text.setComponentType("javax.faces.HtmlOutputText");
@@ -199,90 +240,109 @@
     }
 
     /**
-     * <p>This is a method binding "validator" signature that can be bound to 
the
-     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
-     * component.  It expects that the <code>url</code> attribute will contain 
the file to import
-     * relative to the web context root. The content of the file will be 
encode or decode depending
-     * on the value of the <code>escapeXml</code> optional attribute.  The 
default doesn't apply
-     * any encoding. </p>
+     * <p>
+     * This is a method binding "validator" signature that can be bound to the
+     * <code>shapeValidator</code> attribute of the
+     * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component. It 
expects that
+     * the <code>url</code> attribute will contain the file to import relative
+     * to the web context root. The content of the file will be encode or 
decode
+     * depending on the value of the <code>escapeXml</code> optional
+     * attribute. The default doesn't apply any encoding.
+     * </p>
+     *
+     * @param context
+     *            faces context
+     * @param component
+     *            clay
+     * @param displayElementRoot
+     *            config bean
      */
     public void clayImport(javax.faces.context.FacesContext context,
             javax.faces.component.UIComponent component,
             java.lang.Object displayElementRoot) {
 
-
-        if (!(displayElementRoot instanceof ComponentBean) ||
-                !(component instanceof Clay)) {
-            throw new RuntimeException(messages.getMessage("invalid.binding", 
new Object[] {"clayImport"}));
+        if (!(displayElementRoot instanceof ComponentBean)
+                || !(component instanceof Clay)) {
+            throw new RuntimeException(messages.getMessage("invalid.binding",
+                    new Object[] { "clayImport" }));
         }
 
         ComponentBean text = (ComponentBean) displayElementRoot;
         Clay clay = (Clay) component;
         String url = (String) clay.getAttributes().get("url");
         if (url == null) {
-            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"url", "clayImport"}));
+            throw new IllegalArgumentException(messages.getMessage(
+                    "missing.attribute", new Object[] { "url", "clayImport" 
}));
         }
         url = tagUtils.evalString(url);
 
         boolean escapeXml = true;
         String escAttribute = (String) clay.getAttributes().get("escapeXml");
         if (escAttribute != null) {
-           escapeXml =  tagUtils.evalBoolean(escAttribute).booleanValue();
+            escapeXml = tagUtils.evalBoolean(escAttribute).booleanValue();
         }
 
         StringBuffer value = new StringBuffer();
         StringBuffer buff = new StringBuffer(url);
 
-        //look for a classpath prefix.
-        int i = -1;
-        if ((i = buff.indexOf(Globals.CLASSPATH_PREFIX)) > -1)
-           buff.delete(0, i + Globals.CLASSPATH_PREFIX.length());
-
+        // look for a classpath prefix.
+        int i = buff.indexOf(Globals.CLASSPATH_PREFIX);
+        if (i > -1) {
+            buff.delete(0, i + Globals.CLASSPATH_PREFIX.length());
+        }
 
         InputStream in = null;
 
         try {
-               // if classpath prefix found, use the classloader
-               if (i > -1) {           
-                       //load form the classpath
-                       ClassLoader classloader = 
Thread.currentThread().getContextClassLoader();
-                       if(classloader == null)
-                               classloader = this.getClass().getClassLoader();
-                       
-                       in = classloader.getResourceAsStream(buff.toString());
-                       
-               } else {
-                       //load from the context root
-                       in = 
context.getExternalContext().getResourceAsStream(buff.toString());
-               }
-                       
-               if (in != null) {
-                       int c = 0;
-                       done: while (true) {
-                               c = in.read();
-                               if (c > -1)
-                                       value.append((char) c);
-                               else
-                                       break done;
-                               
-                       }
-               }
+            // if classpath prefix found, use the classloader
+            if (i > -1) {
+                // load form the classpath
+                ClassLoader classloader = Thread.currentThread()
+                        .getContextClassLoader();
+                if (classloader == null) {
+                    classloader = this.getClass().getClassLoader();
+                }
+
+                in = classloader.getResourceAsStream(buff.toString());
+
+            } else {
+                // load from the context root
+                in = context.getExternalContext().getResourceAsStream(
+                        buff.toString());
+            }
+
+            if (in != null) {
+                int c = 0;
+                done: while (true) {
+                    c = in.read();
+                    if (c > -1) {
+                        value.append((char) c);
+                    } else {
+                        break done;
+                    }
+
+                }
+            }
         } catch (IOException e) {
-               throw new 
RuntimeException(messages.getMessage("invalid.attribute", new Object[] {"url", 
"clayImport"}));
+            throw new RuntimeException(messages.getMessage("invalid.attribute",
+                    new Object[] { "url", "clayImport" }));
         } finally {
-               if (in != null) {
-                       try {
-                               in.close();
-                       } catch (IOException e) {}
-               }
-               
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    in = null;
+                }
+            }
+
         }
 
         if (escAttribute != null) {
-               if (!escapeXml)
-                       replace(value, decodeMap);
-               else
-                       replace(value, encodeMap);
+            if (!escapeXml) {
+                replace(value, decodeMap);
+            } else {
+                replace(value, encodeMap);
+            }
         }
 
         text.setJsfid("outputText");
@@ -308,16 +368,27 @@
     }
 
     /**
-     * <p>This is a method binding "validator" signature that can be bound to 
the
-     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
-     * component.  It expects four attributes value, bodyJsfid, var and scope.
-     * The <code>value</code> attribute is like a dataTable.  It should be a 
value binding expression
-     * that is a Map, List or Object[].  The <code>bodyJsfid</code> attribute 
is root of the
-     * subtree that will be repeated in the for loop.  The <code>var</code> 
attribute is the
-     * tag used to cache a Map of the bound objects.  It will always be loaed 
in "session"
-     * scope.  Limitation exists because the "shapeValidator" event is only 
called when the
-     * component is created. This means that you must take care in removing 
the <code>var</code> object
-     * from session scope.</p>
+     * <p>
+     * This is a method binding "validator" signature that can be bound to the
+     * <code>shapeValidator</code> attribute of the
+     * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component. It 
expects four
+     * attributes value, bodyJsfid, var and scope. The <code>value</code>
+     * attribute is like a dataTable. It should be a value binding expression
+     * that is a Map, List or Object[]. The <code>bodyJsfid</code> attribute
+     * is root of the subtree that will be repeated in the for loop. The
+     * <code>var</code> attribute is the tag used to cache a Map of the bound
+     * objects. It will always be loaed in "session" scope. Limitation exists
+     * because the "shapeValidator" event is only called when the component is
+     * created. This means that you must take care in removing the
+     * <code>var</code> object from session scope.
+     * </p>
+     *
+     * @param context
+     *            faces
+     * @param component
+     *            clay
+     * @param displayElementRoot
+     *            config bean
      */
     public void clayForEach(javax.faces.context.FacesContext context,
             javax.faces.component.UIComponent component,
@@ -332,31 +403,39 @@
         Clay clay = (Clay) component;
         String value = (String) clay.getAttributes().get("value");
         if (value == null) {
-            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayForEach"}));
+            throw new IllegalArgumentException(messages.getMessage(
+                    "missing.attribute",
+                    new Object[] { "value", "clayForEach" }));
         }
 
         String bodyJsfid = (String) clay.getAttributes().get("bodyJsfid");
         bodyJsfid = tagUtils.evalString(bodyJsfid);
         if (bodyJsfid == null) {
-            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"bodyJsfid", "clayForEach"}));
+            throw new IllegalArgumentException(messages.getMessage(
+                    "missing.attribute", new Object[] { "bodyJsfid",
+                            "clayForEach" }));
         }
 
         String var = (String) clay.getAttributes().get("var");
         var = tagUtils.evalString(var);
         if (var == null) {
-            throw new 
IllegalArgumentException(messages.getMessage("missing.attribute", new Object[] 
{"var", "clayForEach"}));
+            throw new IllegalArgumentException(messages.getMessage(
+                    "missing.attribute", new Object[] { "var", "clayForEach" 
}));
         }
 
         // lookup the ConfigBean that handles the bodyJsfid
         ConfigBean config = ConfigBeanFactory.findConfig(bodyJsfid);
-        if (config == null)
-            throw new 
NullPointerException(messages.getMessage("clay.config.notloaded"));
+        if (config == null) {
+            throw new NullPointerException(messages
+                    .getMessage("clay.config.notloaded"));
+        }
 
-        //make sure it's parsed and cached
+        // make sure it's parsed and cached
         ComponentBean b = config.getElement(bodyJsfid);
-        if (b == null)
+        if (b == null) {
             throw new NullPointerException(messages.getMessage(
                     "clay.jsfid.notfound", new Object[] { bodyJsfid }));
+        }
 
         ValueBinding vb = context.getApplication().createValueBinding(value);
         final Object valueList = vb.getValue(context);
@@ -364,15 +443,15 @@
         Map beans = new TreeMap();
         int i = 0;
         Iterator vi = null;
-        if (valueList == null)
-           vi = Collections.EMPTY_LIST.iterator();
-        else if (valueList instanceof List)
-           vi = ((List) valueList).iterator();
-        else if (valueList instanceof Map)
-           vi = ((Map) valueList).entrySet().iterator();
-        else {
-           Object[] anArray = new Object[0];
-           if (anArray.getClass().isAssignableFrom(valueList.getClass())) {
+        if (valueList == null) {
+            vi = Collections.EMPTY_LIST.iterator();
+        } else if (valueList instanceof List) {
+            vi = ((List) valueList).iterator();
+        } else if (valueList instanceof Map) {
+            vi = ((Map) valueList).entrySet().iterator();
+        } else {
+            Object[] anArray = new Object[0];
+            if (anArray.getClass().isAssignableFrom(valueList.getClass())) {
                 vi = new Iterator() {
                     private int index = 0;
 
@@ -390,44 +469,44 @@
                     };
 
                 };
-           } else {
-              throw new IllegalArgumentException(
-                      messages.getMessage("invalid.collectiontype", new 
Object[] {value}));
-           }
+            } else {
+                throw new IllegalArgumentException(messages.getMessage(
+                        "invalid.collectiontype", new Object[] { value }));
+            }
         }
 
         if (vi != null) {
-           while (vi.hasNext()) {
-              //create a key for the beans map
-              StringBuffer id = new StringBuffer("bean" + ++i);
-              //add the subscripted bean to the beans map with the generated 
key
-              beans.put(id.toString(), vi.next());
-
-              //create a naming container to hold the row
-              ElementBean namingContainer = new ElementBean();
-              namingContainer.setRenderId(i);
-              namingContainer.setJsfid("namingContainer");
-              namingContainer.setComponentType("javax.faces.NamingContainer");
-
-              //create a new nested bean
-              ElementBean target = new ElementBean();
-              target.setJsfid(bodyJsfid);
-              target.setExtends(bodyJsfid);
-              target.setRenderId(i);
-              config.assignParent(target);
-              config.realizingInheritance(target);
-
-              //prepend the var to the generated key
-              id.insert(0, var + ".");
-              SymbolBean symbol = new SymbolBean();
-              symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
-              symbol.setValue(id.toString());
-              target.addSymbol(symbol);
-
-
-              namingContainer.addChild(target);
-              ((ComponentBean) displayElementRoot).addChild(namingContainer);
-           }
+            while (vi.hasNext()) {
+                // create a key for the beans map
+                StringBuffer id = new StringBuffer("bean" + ++i);
+                // add the subscripted bean to the beans map with the generated
+                // key
+                beans.put(id.toString(), vi.next());
+
+                // create a naming container to hold the row
+                ElementBean namingContainer = new ElementBean();
+                namingContainer.setRenderId(i);
+                namingContainer.setJsfid("namingContainer");
+                
namingContainer.setComponentType("javax.faces.NamingContainer");
+
+                // create a new nested bean
+                ElementBean target = new ElementBean();
+                target.setJsfid(bodyJsfid);
+                target.setExtends(bodyJsfid);
+                target.setRenderId(i);
+                config.assignParent(target);
+                config.realizingInheritance(target);
+
+                // prepend the var to the generated key
+                id.insert(0, var + ".");
+                SymbolBean symbol = new SymbolBean();
+                symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
+                symbol.setValue(id.toString());
+                target.addSymbol(symbol);
+
+                namingContainer.addChild(target);
+                ((ComponentBean) displayElementRoot).addChild(namingContainer);
+            }
 
         }
 

Modified: 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/FalseLookupCommand.java
URL: 
http://svn.apache.org/viewvc/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/FalseLookupCommand.java?rev=420232&r1=420231&r2=420232&view=diff
==============================================================================
--- 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/FalseLookupCommand.java
 (original)
+++ 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/FalseLookupCommand.java
 Sat Jul  8 17:24:24 2006
@@ -27,6 +27,12 @@
  * @see org.apache.commons.chain.generic.LookupCommand
  */
 public class FalseLookupCommand extends LookupCommand {
+
+    /**
+     * @param context commons chains
+     * @return always <code>false</code>
+     * @throws Exception from nested command execution
+     */
     public boolean execute(Context context) throws Exception {
         super.execute(context);
         return false;

Modified: 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
URL: 
http://svn.apache.org/viewvc/shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/PluggableLookupCommand.java?rev=420232&r1=420231&r2=420232&view=diff
==============================================================================
--- 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
 (original)
+++ 
shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
 Sat Jul  8 17:24:24 2006
@@ -35,6 +35,8 @@
 
     /**
      * <p>Checks to see if the catalog exists.</p>
+     *
+     * @return <code>true</code> if the catalog exists
      */
     private boolean catalogExists() {
         String catalogName = getCatalogName();
@@ -50,6 +52,10 @@
      * <p>Adds an additional check to determine if the catalog name is loaded.
      * If loaded, the super implementation is invoked.  Otherwise, the chain
      * continues if the command is optional.</p>
+     *
+     * @param context chains context
+     * @return <code>true</code> if the chain is done
+     * @exception Exception up the calling chain
      */
     public boolean execute(Context context) throws Exception {
 


Reply via email to