TILES-549 - Improve code quality


git-svn-id: https://svn.apache.org/repos/asf/tiles/framework/trunk@1340632 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java b/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java
index 49b3151..adabd57 100644
--- a/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java
+++ b/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/OptionsRenderer.java
@@ -40,26 +40,26 @@
 /**
  * Provides a custom "options" syntax for attributes.
  * The first option that can be rendered is.
- * Comes from http://tech.finn.no/the-ultimate-view/<p/>
+ * Comes from <a href="http://tech.finn.no/the-ultimate-view/">The Ultimate View</a> article.<p/>
  *
- * Actual rendering is delegated to the TypeDetectingRenderer that's supplied in the constructor.
+ * Actual rendering is delegated to the TypeDetectingRenderer that's supplied in the constructor.<p/>
  *
  * For example:
  * "/WEB-INF/tiles/fragments/${options[myoptions]}/content.jsp"
  * given the myptions list-attribute is defined like:
  * <pre>
-        <put-list-attribute name="myoptions">
-            <add-list-attribute>
-                <add-attribute value="car"/>
-                <add-attribute value="vechile"/>
-                <add-attribute value="advert"/>
-            </add-list-attribute>
-        </put-list-attribute>
+        &lt;put-list-attribute name="myoptions">
+            &lt;add-list-attribute>
+                &lt;add-attribute value="car"/>
+                &lt;add-attribute value="vechile"/>
+                &lt;add-attribute value="advert"/>
+            &lt;/add-list-attribute>
+        &lt;/put-list-attribute>
    </pre>
- * will look for content.jsp
- * first in "/WEB-INF/tiles/fragments/car/" then
- * second in "/WEB-INF/tiles/fragments/vechile/" and
- * last in "/WEB-INF/tiles/fragments/advert".
+ * will look for content.jsp <br/>
+ * first in "/WEB-INF/tiles/fragments/car/" then <br/>
+ * second in "/WEB-INF/tiles/fragments/vechile/" and <br/>
+ * last in "/WEB-INF/tiles/fragments/advert". 
  * <p/>
  * <p/>
  * Currently only supports one occurrance of such an "option" pattern in the attribute's value.
@@ -75,7 +75,7 @@
     private final ApplicationContext applicationContext;
     private final Renderer renderer;
 
-    public OptionsRenderer(final ApplicationContext applicationContext, final Renderer renderer){
+    public OptionsRenderer(final ApplicationContext applicationContext, final Renderer renderer) {
         this.applicationContext = applicationContext;
         this.renderer = renderer;
     }
@@ -98,16 +98,17 @@
                     .getAttributeContext(request)
                     .getAttribute(match);
 
-            if(null == fallbacks){
+            if (null == fallbacks){
                 throw new IllegalStateException("A matching list-attribute name=\"" + match + "\" must be defined.");
-            }else if(fallbacks.getValue().isEmpty()){
-                throw new IllegalStateException("list-attribute name=\"" + match + "\" must have minimum one attribute");
+            }else if (fallbacks.getValue().isEmpty()){
+                throw new IllegalStateException(
+                        "list-attribute name=\"" + match + "\" must have minimum one attribute");
             }
 
             for (Attribute option : (List<Attribute>) fallbacks.getValue()) {
-                String template = path.replaceFirst(Pattern.quote(matcher.group()), (String)option.getValue());
+                String template = path.replaceFirst(Pattern.quote(matcher.group()), (String) option.getValue());
                 done = renderAttempt(template, request);
-                if(done){ break; }
+                if (done) { break; }
             }
             if (!done) {
               throw new IOException("None of the options existed for " + path);
@@ -117,9 +118,9 @@
         }
     }
 
-    private boolean renderAttempt(final String template, final Request request) throws IOException{
+    private boolean renderAttempt(final String template, final Request request) throws IOException {
         boolean result = false;
-        if(!Cache.isTemplateMissing(template)){
+        if (!Cache.isTemplateMissing(template)) {
             try {
                 if (null != applicationContext.getResource(template)) { // can throw FileNotFoundException !
                     renderer.render(template, request); // can throw FileNotFoundException !
@@ -127,14 +128,14 @@
                     Cache.setIfAbsentTemplateFound(template, true);
                 }
             } catch (FileNotFoundException ex) {
-                if(ex.getMessage().contains(template)){
+                if (ex.getMessage().contains(template)) {
                     // expected outcome. continue loop.
                     LOG.trace(ex.getMessage());
                 }else{
                     // comes from an inner templateAttribute.render(..) so throw on
                     throw ex;
                 }
-            } catch(IOException ex){ //xxx ???
+            } catch (IOException ex) { //xxx ???
                 throw ex;
             }
             Cache.setIfAbsentTemplateFound(template, false);
@@ -142,14 +143,14 @@
         return result;
     }
 
-    private static final class Cache{
+    private static final class Cache {
 
         /** It takes CACHE_LIFE milliseconds for any hot deployments to register.
          */
         private static final ConcurrentMap<String,Boolean> TEMPLATE_EXISTS
                 = new ConcurrentHashMap<String,Boolean>();
 
-        private volatile static long cacheLastCleaned = System.currentTimeMillis();
+        private static volatile long cacheLastCleaned = System.currentTimeMillis();
 
         private static final String CACHE_LIFE_PROPERTY = Cache.class.getName() + ".ttl_ms";
 
@@ -163,8 +164,8 @@
                 ? Long.getLong(CACHE_LIFE_PROPERTY)
                 : 1000 * 60 * 5;
 
-        static boolean isTemplateMissing(final String template){
-            if(0 < CACHE_LIFE && System.currentTimeMillis() > cacheLastCleaned + CACHE_LIFE){
+        static boolean isTemplateMissing(final String template) {
+            if (0 < CACHE_LIFE && System.currentTimeMillis() > cacheLastCleaned + CACHE_LIFE){
                 cacheLastCleaned = System.currentTimeMillis();
                 TEMPLATE_EXISTS.clear();
                 return false;
@@ -173,12 +174,12 @@
             }
         }
 
-        static void setIfAbsentTemplateFound(final String template, final boolean found){
-            if(0 < CACHE_LIFE && !TEMPLATE_EXISTS.containsKey(template)){
+        static void setIfAbsentTemplateFound(final String template, final boolean found) {
+            if (0 < CACHE_LIFE && !TEMPLATE_EXISTS.containsKey(template)) {
                 TEMPLATE_EXISTS.putIfAbsent(template, found);
             }
         }
 
-        private Cache(){}
+        private Cache() {}
     }
 }
diff --git a/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java b/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java
new file mode 100644
index 0000000..f41d8f6
--- /dev/null
+++ b/tiles-extras/src/main/java/org/apache/tiles/extras/renderer/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  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.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Provides a custom "options" syntax for attributes.
+ * The first option from a list that can be rendered is.
+ *
+ * Comes from <a href="http://tech.finn.no/the-ultimate-view/">The Ultimate View</a> article.
+ */
+package org.apache.tiles.extras.renderer;