Author: gvanmatre
Date: Mon Jul 24 21:34:13 2006
New Revision: 425271

URL: http://svn.apache.org/viewvc?rev=425271&view=rev
Log:
A few more checkstyle fixes

Modified:
    
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
    
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/ClayTemplateParser.java
    
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
    
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/TemplateConfigBean.java
    
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ValidatorBean.java

Modified: 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java?rev=425271&r1=425270&r2=425271&view=diff
==============================================================================
--- 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
 (original)
+++ 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/component/Clay.java
 Mon Jul 24 21:34:13 2006
@@ -496,13 +496,19 @@
      */
     public void restoreState(FacesContext context, Object obj) {
 
+        final int superState = 0;
+        final int jsfidState = 1;
+        final int shapeValidatorState = 2;
+        final int displayElementState = 3;
+        final int symbolsState = 4;
+
         Object[] aobj = (Object[]) obj;
-        super.restoreState(context, aobj[0]);
+        super.restoreState(context, aobj[superState]);
 
-        jsfid = ((String) aobj[1]);
-        shapeValidator = ((String) aobj[2]);
-        displayElementRoot = ((ComponentBean) aobj[3]);
-        symbols = ((Map) aobj[4]);
+        jsfid = ((String) aobj[jsfidState]);
+        shapeValidator = ((String) aobj[shapeValidatorState]);
+        displayElementRoot = ((ComponentBean) aobj[displayElementState]);
+        symbols = ((Map) aobj[symbolsState]);
 
     }
 
@@ -516,12 +522,19 @@
      * @return subtree state
      */
     public Object saveState(FacesContext context) {
-        Object[] aobj = new Object[5];
-        aobj[0] = super.saveState(context);
-        aobj[1] = jsfid;
-        aobj[2] = shapeValidator;
-        aobj[3] = displayElementRoot;
-        aobj[4] = symbols;
+        final int superState = 0;
+        final int jsfidState = 1;
+        final int shapeValidatorState = 2;
+        final int displayElementState = 3;
+        final int symbolsState = 4;
+        final int size = 5;
+
+        Object[] aobj = new Object[size];
+        aobj[superState] = super.saveState(context);
+        aobj[jsfidState] = jsfid;
+        aobj[shapeValidatorState] = shapeValidator;
+        aobj[displayElementState] = displayElementRoot;
+        aobj[symbolsState] = symbols;
 
         return aobj;
     }

Modified: 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/ClayTemplateParser.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/ClayTemplateParser.java?rev=425271&r1=425270&r2=425271&view=diff
==============================================================================
--- 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/ClayTemplateParser.java
 (original)
+++ 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/ClayTemplateParser.java
 Mon Jul 24 21:34:13 2006
@@ -110,7 +110,7 @@
      *            jsfid
      * @exception SAXException
      *                XML parse error
-     * @exception IOException 
+     * @exception IOException
      *                XML parse error
      */
     public void loadConfigFile(URL templateURL, String templateName)

Modified: 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java?rev=425271&r1=425270&r2=425271&view=diff
==============================================================================
--- 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
 (original)
+++ 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
 Mon Jul 24 21:34:13 2006
@@ -264,7 +264,9 @@
             try {
                 if (i > -1) {
                    for (Enumeration ui = 
classloader.getResources(configFile.toString());
-                         ui.hasMoreElements(); urls.add(ui.nextElement()));
+                         ui.hasMoreElements();) {
+                       urls.add(ui.nextElement());
+                   }
                 } else {
                    URL url = context.getResource(configFile.toString());
                    if (url == null) {
@@ -311,7 +313,8 @@
      * collection.</p>
      */
     public ComponentConfigBean() {
-        displayElements = new HashMap(1000);
+        final int size = 1000;
+        displayElements = new HashMap(size);
     }
 
     /**
@@ -988,6 +991,7 @@
             try {
                 unassignParent(b);
             } catch (RuntimeException e1) {
+                // log.error(e1);
             }
 
             b = null;

Modified: 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/TemplateConfigBean.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/TemplateConfigBean.java?rev=425271&r1=425270&r2=425271&view=diff
==============================================================================
--- 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/TemplateConfigBean.java
 (original)
+++ 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/TemplateConfigBean.java
 Mon Jul 24 21:34:13 2006
@@ -44,19 +44,23 @@
      * using a HTML template fragment.  The <code>templateName</code>
      * is the name of the file relative to the context root of the
      * web application</p>
+     * @param templateName name of the markup template
+     * @return root component bean for the <code>templateName</code>
      */
     public ComponentBean getElement(String templateName) {
 
         StringBuffer jsfid = new StringBuffer(templateName);
-        if (jsfid.length() > 0 &&  jsfid.charAt(0) != '/')
+        if (jsfid.length() > 0 &&  jsfid.charAt(0) != '/') {
           jsfid.insert(0, '/');
+        }
 
         // look for a watcher identified by the template name
         WatchDog watchDog = (WatchDog) watchDogs.get(jsfid.toString());
 
         //if a watcher doesn't exist, check for a common
-        if (watchDog == null)
+        if (watchDog == null) {
             watchDog = (WatchDog) 
watchDogs.get(Globals.DEFAULT_COMPONENT_CONFIG_WATCHDOG);
+        }
 
         if (watchDog == null || super.getElement(jsfid.toString()) == null) {
            //The first time the page is created, create a watcher
@@ -69,10 +73,10 @@
            //loads the HTML template the first time and when file
            //has been modified
            watchDog.refresh(false);
-        } else {
-                  //check to see if an existing html template
-                  //needs reloaded
-              watchDog.refresh(false);
+           } else {
+           //check to see if an existing html template
+           //needs reloaded
+           watchDog.refresh(false);
         }
 
         // returns the cached element
@@ -84,6 +88,8 @@
      * <p>Returns an integer value use to order the registered [EMAIL 
PROTECTED] ConfigBean} instances
      * with the [EMAIL PROTECTED] ConfigBeanFactory}.
      * </p>
+     *
+     * @return weight value of <code>1</code>
      */
     public int getWeight() {
         return 1;
@@ -95,6 +101,9 @@
      * defined in the web deployment descriptor as a initialization parameter 
with
      * the name defined by <code>Globals.CLAY_HTML_TEMPLATE_SUFFIX</code>  Or, 
using
      * the default defined by 
<code>Globals.CLAY_DEFAULT_HTML_TEMPLATE_SUFFIX</code>
+     *
+     * @param id jsfid
+     * @return <code>true</code> if the <code>jsfid</code> can be handled here
      */
     public boolean validMoniker(String id) {
         return id.endsWith(suffixes[0]);
@@ -115,14 +124,15 @@
 
 
     /**
-     * The HTML templates are loaded on-demand.  Override this method forcing 
the auto
+     * <p>The HTML templates are loaded on-demand.  Override this method 
forcing the auto
      * load option on.  The XML configuration files are only effected by the
-     * <code>auto-reload-clay-files</code> initialization parameter.
+     * <code>auto-reload-clay-files</code> initialization parameter.</p>
+     *
+     * @param context web container servlet context
      */
     public void init(ServletContext context) {
         super.init(context);
 
-
         isWatchDogOn = true;
     }
 
@@ -131,6 +141,8 @@
      * <p>If the <code>watchDogName</code> equals
      * the [EMAIL PROTECTED] ComponentBean} that defines the selected
      * template, remove it.</p>
+     *
+     * @param watchDogName grouping of template files
      */
     protected void clear(String watchDogName) {
         if (!watchDogName.equals(Globals.DEFAULT_COMPONENT_CONFIG_WATCHDOG)) {
@@ -141,6 +153,7 @@
                 try {
                     unassignParent(b);
                 } catch (RuntimeException e1) {
+                    // log.error(e1);
                 }
             }
             b = null;
@@ -155,6 +168,9 @@
      * the <code>displayElements</code> cache is invalidated.
      * A <code>true</code> value is returned if cache has
      * been cleared.</p>
+     *
+     * @param forceReload invalidate the cache flag
+     * @return <code>true</code> if the templates were reloaded
      */
     public boolean refresh(boolean forceReload) {
         if (forceReload) {
@@ -166,8 +182,9 @@
                     Map.Entry e = (Map.Entry) wi.next();
                     WatchDog watchDog = (WatchDog) e.getValue();
                     clear(watchDog.getName());
-                    if (watchDog != null)
+                    if (watchDog != null) {
                         watchDog.destroy();
+                    }
 
                 }
                 watchDogs.clear();
@@ -183,29 +200,36 @@
      * Returns the root metadata component that is used to add to the component
      * tree. It locates the [EMAIL PROTECTED] ComponentBean} using the 
<code>jsfid</code>
      * attribute as the key. A call to the [EMAIL PROTECTED] 
ConfigBeanFactory} locates the
-     * correct [EMAIL PROTECTED] ConfigBean} used to find the [EMAIL 
PROTECTED] ComponentBean}. </b>
+     * correct [EMAIL PROTECTED] ConfigBean} used to find the [EMAIL 
PROTECTED] ComponentBean}. </p>
+     *
+     * @param jsfid parent id of a config bean
+     * @return parent config bean
      */
     protected ComponentBean getTopLevelElement(String jsfid) {
 
-        if (validMoniker(jsfid))
+        if (validMoniker(jsfid)) {
             return getElement(jsfid);
+        }
 
         //broaden the search to the other ConfigBean's
         ConfigBean config = ConfigBeanFactory.findConfig(jsfid);
 
-        if (config == null)
+        if (config == null) {
             throw new NullPointerException(messages
                     .getMessage("config.notloaded", new Object[] { jsfid }));
+        }
 
-        if (config == this)
+        if (config == this) {
             throw new NullPointerException(messages.getMessage(
                     "jsfid.notfound", new Object[] { jsfid }));
+        }
 
         // find the top-level display element associated with the subtree
         ComponentBean b = config.getElement(jsfid);
-        if (b == null)
+        if (b == null) {
             throw new NullPointerException(messages.getMessage(
                     "jsfid.notfound", new Object[] { jsfid }));
+        }
 
         return b;
     }
@@ -214,14 +238,17 @@
     /**
      * <p>Determines if the <code>node</code> is a transient
      * <code>outputText</code> (<strong>verbatim</strong>) component.</p>
+     *
+     * @param node a config bean that represents a template token
+     * @return <code>true</code> if the node is a verbatim node
      */
     private boolean isVerbatim(ComponentBean node) {
 
         AttributeBean attr = null;
         if (node.getJsfid().equals("verbatim")
              && node.getComponentType().equals("javax.faces.HtmlOutputText")) {
-
-            if ((attr = node.getAttribute("isTransient")) != null) {
+            attr = node.getAttribute("isTransient");
+            if (attr != null) {
                 if (attr.getValue() != null && attr.getValue().length() > 0) {
                     return (Character.toLowerCase(attr.getValue().charAt(0)) 
== 't');
                 }
@@ -239,6 +266,8 @@
      * definitions are merged.  If there is only one child and
      * the child and root nodes are both <code>verbatim</code>
      * definitions, the child is merged up to the root.</p>
+     *
+     * @param root top config bean that represents a markup template
      */
     public void optimizeTree(ComponentBean root) {
 
@@ -255,7 +284,6 @@
         while (ci.hasNext()) {
             children[i] = (ComponentBean) ci.next();
             if (isVerbatim(children[i])) {
-
                 verbatimSet.set(i);
             }
 
@@ -276,20 +304,23 @@
 
                     // grap the value attribute of the first one in the stack
                     // and concat to a buffer
-                    AttributeBean attrTop = null;
-                    if (((attrTop = children[s].getAttribute("value")) != 
null)) {
-                        if (attrTop.getValue() != null)
+                    AttributeBean attrTop = children[s].getAttribute("value");
+                    if (attrTop != null) {
+                        if (attrTop.getValue() != null) {
                             buff.append(attrTop.getValue());
-                    } else
+                        }
+                    } else {
                         break merge;   // a verbatim without a value should 
never happen
+                    }
 
-                    AttributeBean attrNext = null;  // the next in sequence to 
be merged
-                    if (((attrNext = children[j].getAttribute("value")) != 
null)) {
-                        if (attrNext.getValue() != null)
+                    AttributeBean attrNext = 
children[j].getAttribute("value");  // the next in sequence to be merged
+                    if (attrNext != null) {
+                        if (attrNext.getValue() != null) {
                             buff.append(attrNext.getValue());
-                    } else
+                        }
+                    } else {
                         continue merge;   // a verbatim without a value should 
never happen
-
+                    }
                     // merge node values
                     attrTop.setValue(buff.toString());
                     root.getChildren().remove(children[j]); // delete the node 
after merge from the parent
@@ -313,15 +344,17 @@
 
             // grap the value attribute of the first one in the stack
             // and concat to a buffer
-            AttributeBean attrTop = null;
-            if (((attrTop = root.getAttribute("value")) != null)) {
-                if (attrTop.getValue() != null)
+            AttributeBean attrTop = root.getAttribute("value");
+            if (attrTop != null) {
+                if (attrTop.getValue() != null) {
                     buff.append(attrTop.getValue());
+                }
 
-                AttributeBean attrNext = null;  // the next in sequence to be 
merged
-                if (((attrNext = children[0].getAttribute("value")) != null)) {
-                    if (attrNext.getValue() != null)
+                AttributeBean attrNext = children[0].getAttribute("value");  
// the next in sequence to be merged
+                if (attrNext != null) {
+                    if (attrNext.getValue() != null) {
                         buff.append(attrNext.getValue());
+                    }
                 }
                 // merge node values
                 attrTop.setValue(buff.toString());

Modified: 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ValidatorBean.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ValidatorBean.java?rev=425271&r1=425270&r2=425271&view=diff
==============================================================================
--- 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ValidatorBean.java
 (original)
+++ 
shale/framework/trunk/shale-clay/src/main/java/org/apache/shale/clay/config/beans/ValidatorBean.java
 Mon Jul 24 21:34:13 2006
@@ -58,4 +58,3 @@
     }
 
 }
-


Reply via email to