You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2007/03/15 17:52:44 UTC

svn commit: r518688 - in /tiles/framework/trunk: tiles-api/src/main/java/org/apache/tiles/ tiles-api/src/main/java/org/apache/tiles/web/ tiles-core/src/main/java/org/apache/tiles/context/ tiles-core/src/main/java/org/apache/tiles/filter/ tiles-core/src...

Author: apetrelli
Date: Thu Mar 15 09:52:43 2007
New Revision: 518688

URL: http://svn.apache.org/viewvc?view=rev&rev=518688
Log:
TILES-86
Corrected JavaDocs errors.
Added a small amount of JavaDocs comments.

Modified:
    tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java
    tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDecorationFilter.java
    tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDispatchServlet.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesRequestContext.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
    tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/ServletContextAdapter.java
    tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/DefinitionTag.java

Modified: tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java (original)
+++ tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/ComponentAttribute.java Thu Mar 15 09:52:43 2007
@@ -26,6 +26,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.tiles.context.ComponentListAttribute;
+
 /**
  * Common implementation of attribute definition.
  *
@@ -53,12 +55,26 @@
      */
     protected String role = null;
 
+    /**
+     * The value of the attribute.
+     */
     protected Object value = null;
 
+    /**
+     * The type of the attribute. It can be <code>string</code>,
+     * <code>template</code>, <code>definition</code>.
+     */
     private String type = null;
 
+    /**
+     * The name of the attribute. If it is <code>null</code>, it should be used
+     * as an element of a list attribute.
+     */
     private String name = null;
 
+    /**
+     * The composing attributes, used to render the attribute itself.
+     */
     private Map<String, ComponentAttribute> attributes;
 
     /**
@@ -80,7 +96,7 @@
     /**
      * Copy constructor.
      *
-     * @param value Object to store.
+     * @param attribute The attribute to copy from.
      */
     public ComponentAttribute(ComponentAttribute attribute) {
         this.name = attribute.name;
@@ -182,9 +198,7 @@
         this.value = value;
     }
 
-    /**
-     * Get String representation of this object.
-     */
+    /** {@inheritDoc} */
     public String toString() {
         if (value != null) {
             return value.toString();
@@ -192,31 +206,73 @@
         return null;
     }
 
+    /**
+     * Returns the type of this attribute.
+     * 
+     * @return The attribute type. It can be <code>string</code>,
+     * <code>template</code>, <code>definition</code>.
+     */
     public String getType() {
         return type;
     }
 
+    /**
+     * Sets the type of this attribute.
+     * 
+     * @param type The attribute type. It can be <code>string</code>,
+     * <code>template</code>, <code>definition</code>.
+     */
     public void setType(String type) {
         this.type = type;
     }
 
+    /**
+     * Returns the name of the attribute.
+     *
+     * @return The name of the attribute. It can be <code>null</code>, but in
+     * this case it should be used as an element of
+     * {@link ComponentListAttribute}
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Sets the name of the attribute.
+     *
+     * @param name The name of the attribute. It can be <code>null</code>,
+     * but in this case it should be used as an element of
+     * {@link ComponentListAttribute}
+     */
     public void setName(String name) {
         this.name = name;
     }
 
 
+    /**
+     * Returns the underlying attributes for this attribute.
+     *
+     * @return The attribute map.
+     */
     public Map<String, ComponentAttribute> getAttributes() {
         return attributes;
     }
 
+    /**
+     * Sets the underlying attributes for this attribute.
+     *
+     * @param attributes The attribute map.
+     */
     public void setAttributes(Map<String, ComponentAttribute> attributes) {
         this.attributes = attributes;
     }
 
+    /**
+     * Sets the body of this attribute.
+     * 
+     * @param body The attribute body.
+     */
+    // FIXME Is it necessary?
     public void setBody(String body) {
         if (body != null && body.length() != 0) {
             setValue(body);

Modified: tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDecorationFilter.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDecorationFilter.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDecorationFilter.java (original)
+++ tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDecorationFilter.java Thu Mar 15 09:52:43 2007
@@ -73,6 +73,9 @@
  */
 public class TilesDecorationFilter implements Filter {
 
+    /**
+     * The logging object.
+     */
     private static final Log LOG =
         LogFactory.getLog(TilesDecorationFilter.class);
 
@@ -87,20 +90,42 @@
      */
     private String componentAttributeName = "content";
 
+    /**
+     * The definition name to use.
+     */
     private String definitionName = "layout";
 
+    /**
+     * Stores a map of the type "mask -> definition": when a definition name
+     * mask is identified, it is substituted with the configured definition.
+     */
     private Map<String, String> alternateDefinitions;
 
+    /**
+     * The object that will mutate the component context so that it uses
+     * different attributes. 
+     */
     private ComponentContextMutator mutator = null;
 
+    /**
+     * Returns the filter configuration object.
+     * 
+     * @return The filter configuration.
+     */
     public FilterConfig getFilterConfig() {
         return filterConfig;
     }
 
+    /**
+     * Returns the servlet context.
+     * 
+     * @return The servlet context.
+     */
     public ServletContext getServletContext() {
         return filterConfig.getServletContext();
     }
 
+    /** {@inheritDoc} */
     public void init(FilterConfig config) throws ServletException {
         filterConfig = config;
         String temp = config.getInitParameter("attribute-name");
@@ -127,6 +152,12 @@
         }
     }
 
+    /**
+     * Creates the alternate definitions map, to map a mask of definition names
+     * to a configured definition.
+     *
+     * @return The alternate definitions map.
+     */
     @SuppressWarnings("unchecked")
     protected Map<String, String> parseAlternateDefinitions() {
         Map<String, String> map = new HashMap<String, String>();
@@ -144,11 +175,13 @@
         return map;
     }
 
+    /** {@inheritDoc} */
     public void destroy() {
         filterConfig = null;
     }
 
 
+    /** {@inheritDoc} */
     public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain)
         throws IOException, ServletException {
         TilesContainer container = TilesAccess.getContainer(getServletContext());
@@ -161,6 +194,12 @@
         }
     }
 
+    /**
+     * Returns the final definition to render for the given request.
+     *
+     * @param request The request object.
+     * @return The final definition name.
+     */
     private String getDefinitionForRequest(ServletRequest request) {
         if(alternateDefinitions.size() < 1) {
             return definitionName;
@@ -174,6 +213,13 @@
         return definitionName;
     }
 
+    /**
+     * Returns the request base, i.e. the the URL to calculate all the relative
+     * paths.
+     * 
+     * @param request The request object to use.
+     * @return The request base.
+     */
     private String getRequestBase(ServletRequest request) {
         // Included Path
         String include = (String) request.getAttribute("javax.servlet.include.servlet_path");
@@ -186,7 +232,12 @@
         return ((HttpServletRequest) request).getServletPath();
     }
 
+    /**
+     * The default component context mutator to use.
+     */
     class DefaultMutator implements ComponentContextMutator {
+
+        /** {@inheritDoc} */
         public void mutate(ComponentContext ctx, ServletRequest req) {
             ComponentAttribute attr = new ComponentAttribute();
             attr.setType(ComponentAttribute.TEMPLATE);

Modified: tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDispatchServlet.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDispatchServlet.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDispatchServlet.java (original)
+++ tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/TilesDispatchServlet.java Thu Mar 15 09:52:43 2007
@@ -41,12 +41,20 @@
  */
 public class TilesDispatchServlet extends HttpServlet {
 
+    /**
+     * The logging object.
+     */
     private static final Log LOG =
         LogFactory.getLog(TilesDispatchServlet.class);
 
+    /**
+     * The object that will mutate the component context so that it uses
+     * different attributes. 
+     */
     private ComponentContextMutator mutator;
 
 
+    /** {@inheritDoc} */
     public void init() throws ServletException {
         super.init();
         String temp = getInitParameter("mutator");
@@ -61,6 +69,7 @@
         }
     }
 
+    /** {@inheritDoc} */
     protected void doGet(HttpServletRequest req, HttpServletResponse res)
         throws ServletException, IOException {
 
@@ -77,6 +86,12 @@
         }
     }
 
+    /**
+     * Returns the called definition name for the given request.
+     *
+     * @param request The request to parse.
+     * @return The definition name to render.
+     */
     protected String getDefinitionName(HttpServletRequest request) {
         String path = (String) request.getAttribute("javax.servlet.include.servlet_path");
         if (path == null) {
@@ -89,13 +104,19 @@
         return path.substring(start, end);
     }
 
+    /** {@inheritDoc} */
     protected void doPost(HttpServletRequest req, HttpServletResponse res)
         throws ServletException, IOException {
         LOG.info("Tiles dispatch request received. Redirecting POST to GET.");
         doGet(req, res);
     }
 
+    /**
+     * Default no-op mutator
+     */
     class DefaultMutator implements ComponentContextMutator {
+
+        /** {@inheritDoc} */
         public void mutate(ComponentContext context, ServletRequest request) {
             // noop;
         }

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesContextFactory.java Thu Mar 15 09:52:43 2007
@@ -52,8 +52,7 @@
      * request, and response.
      *
      * @param context  the associated {@link TilesApplicationContext}
-     * @param request  the associated request.  Typically a ServletRequest or PortletRequest.
-     * @param response the associated response.  Typically a ServletResponse or PortletResponse.
+     * @param requestItems  the associated request items, typically a request and a response.
      * @return TilesRequestContext
      */
     TilesRequestContext createRequestContext(TilesApplicationContext context,

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesRequestContext.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesRequestContext.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/TilesRequestContext.java Thu Mar 15 09:52:43 2007
@@ -87,8 +87,8 @@
 
     /**
      * Determine whether or not the specified user is in the given role
-     * @param role
-     * @return
+     * @param role the role to check against.
+     * @return <code>true</code> if the user is in the given role.
      */
     boolean isUserInRole(String role);
 

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/filter/TilesFilter.java Thu Mar 15 09:52:43 2007
@@ -39,6 +39,9 @@
 
 public class TilesFilter extends TilesServlet implements Filter {
 
+    /**
+     * The logging object.
+     */
     @SuppressWarnings("unused")
     private static final Log LOG = LogFactory.getLog(TilesFilter.class);
 
@@ -73,7 +76,9 @@
     }
 
     /**
-     * Return the filter configuration object for this filter.
+     * Returns the filter configuration object for this filter.
+     * 
+     * @return The filter configuration.
      */
     public FilterConfig getFilterConfig() {
         return (this.filterConfig);
@@ -99,12 +104,8 @@
         super.destroy();
     }
 
-    /**
-     * Init method for this filter
-     */
-    public void init
-        (FilterConfig
-            filterConfig) throws ServletException {
+    /** {@inheritDoc} */
+    public void init(FilterConfig filterConfig) throws ServletException {
         this.filterConfig = filterConfig;
         super.init(createServletConfig());
 
@@ -113,41 +114,65 @@
         }
     }
 
-    public void log
-        (String
-            msg) {
+    /** {@inheritDoc} */
+    public void log(String msg) {
         filterConfig.getServletContext().log(msg);
     }
 
+    /**
+     * A debug flag.
+     */
+    // FIXME Is it really used?
     private static final boolean debug = true;
 
-    private ServletConfig createServletConfig
-        () {
+    /**
+     * Creates a servlet configuration object from the filter configuration
+     * object.
+     *
+     * @return The servlet configuration object.
+     */
+    private ServletConfig createServletConfig() {
         return new ServletConfigAdapter(filterConfig);
     }
 
 
+    /**
+     * Adapts a filter configuration object to become a servlet configuration
+     * object.
+     */
     class ServletConfigAdapter implements ServletConfig {
 
+        /**
+         * The filter configuration object to use.
+         */
         private FilterConfig config;
 
 
+        /**
+         * Constructor.
+         *
+         * @param config The filter configuration object to use.
+         */
         public ServletConfigAdapter(FilterConfig config) {
             this.config = config;
         }
 
+        /** {@inheritDoc} */
         public String getServletName() {
             return config.getFilterName();
         }
 
+        /** {@inheritDoc} */
         public ServletContext getServletContext() {
             return config.getServletContext();
         }
 
+        /** {@inheritDoc} */
         public String getInitParameter(String string) {
             return config.getInitParameter(string);
         }
 
+        /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         public Enumeration getInitParameterNames() {
             return config.getInitParameterNames();

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java Thu Mar 15 09:52:43 2007
@@ -124,9 +124,11 @@
      * template.
      * Also copy attributes setted in parent, and not set in child
      * If instance doesn't extend anything, do nothing.
+     * 
+     * @param definition The definition that needs to have its inheritances
+     * resolved.
      *
      * @throws NoSuchDefinitionException If an inheritance can not be solved.
-     * @param definition def
      */
     protected void resolveInheritance(ComponentDefinition definition,
             TilesRequestContext request)

Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/ServletContextAdapter.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/ServletContextAdapter.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/ServletContextAdapter.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/ServletContextAdapter.java Thu Mar 15 09:52:43 2007
@@ -29,93 +29,126 @@
 import java.io.InputStream;
 
 /**
+ * Adapts a servlet config and a servlet context to become a unique servlet
+ * context.
+ * 
  * @version $Rev$ $Date$
  */
 @SuppressWarnings("deprecation")
 public class ServletContextAdapter implements ServletContext {
 
+    /**
+     * The root context to use.
+     */
     private ServletContext rootContext;
+
+    /**
+     * The configuration object to use.
+     */
     private ServletConfig config;
 
 
+    /**
+     * Constructor.
+     *
+     * @param config The servlet configuration object.
+     */
     public ServletContextAdapter(ServletConfig config) {
         this.rootContext = config.getServletContext();
         this.config = config;
     }
 
+    /** {@inheritDoc} */
     public ServletContext getContext(String string) {
         return rootContext.getContext(string);
     }
 
+    /** {@inheritDoc} */
     public int getMajorVersion() {
         return rootContext.getMajorVersion();
     }
 
+    /** {@inheritDoc} */
     public int getMinorVersion() {
         return rootContext.getMinorVersion();
     }
 
+    /** {@inheritDoc} */
     public String getMimeType(String string) {
         return rootContext.getMimeType(string);
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     public Set getResourcePaths(String string) {
         return rootContext.getResourcePaths(string);
     }
 
+    /** {@inheritDoc} */
     public URL getResource(String string) throws MalformedURLException {
         return rootContext.getResource(string);
     }
 
+    /** {@inheritDoc} */
     public InputStream getResourceAsStream(String string) {
         return rootContext.getResourceAsStream(string);
     }
 
+    /** {@inheritDoc} */
     public RequestDispatcher getRequestDispatcher(String string) {
         return rootContext.getRequestDispatcher(string);
     }
 
+    /** {@inheritDoc} */
     public RequestDispatcher getNamedDispatcher(String string) {
         return rootContext.getNamedDispatcher(string);
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings("deprecation")
     public Servlet getServlet(String string) throws ServletException {
         return rootContext.getServlet(string);
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings({ "deprecation", "unchecked" })
     public Enumeration getServlets() {
         return rootContext.getServlets();  //To change body of implemented methods use File | Settings | File Templates.
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings({ "deprecation", "unchecked" })
     public Enumeration getServletNames() {
         return rootContext.getServletNames();
     }
 
+    /** {@inheritDoc} */
     public void log(String string) {
         rootContext.log(string);
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings("deprecation")
     public void log(Exception exception, String string) {
         rootContext.log(exception, string);
     }
 
+    /** {@inheritDoc} */
     public void log(String string, Throwable throwable) {
         rootContext.log(string, throwable);
     }
 
+    /** {@inheritDoc} */
     public String getRealPath(String string) {
         return rootContext.getRealPath(string);
     }
 
+    /** {@inheritDoc} */
     public String getServerInfo() {
         return rootContext.getServerInfo();
     }
 
+    /** {@inheritDoc} */
     public String getInitParameter(String string) {
         String parm = config.getInitParameter(string);
         if(parm == null) {
@@ -124,49 +157,73 @@
         return parm;
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     public Enumeration getInitParameterNames() {
         return new CompositeEnumeration(config.getInitParameterNames(),
             rootContext.getInitParameterNames());
     }
 
+    /** {@inheritDoc} */
     public Object getAttribute(String string) {
         return rootContext.getAttribute(string);
     }
 
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     public Enumeration getAttributeNames() {
         return rootContext.getAttributeNames();
     }
 
+    /** {@inheritDoc} */
     public void setAttribute(String string, Object object) {
         rootContext.setAttribute(string, object);
     }
 
+    /** {@inheritDoc} */
     public void removeAttribute(String string) {
         rootContext.removeAttribute(string);
     }
 
+    /** {@inheritDoc} */
     public String getServletContextName() {
         return rootContext.getServletContextName();
     }
 
+    /**
+     * Composes an enumeration into a single one.
+     */
     @SuppressWarnings("unchecked")
     class CompositeEnumeration implements Enumeration {
 
+        /**
+         * The first enumeration to consider.
+         */
         private Enumeration first;
+
+        /**
+         * The second enumeration to consider.
+         */
         private Enumeration second;
 
 
+        /**
+         * Constructor.
+         *
+         * @param first The first enumeration to consider.
+         * @param second The second enumeration to consider.
+         */
         public CompositeEnumeration(Enumeration first, Enumeration second) {
             this.first = first;
             this.second = second;
         }
 
+        /** {@inheritDoc} */
         public boolean hasMoreElements() {
             return first.hasMoreElements() || second.hasMoreElements();
         }
 
+        /** {@inheritDoc} */
         public Object nextElement() {
             if(first.hasMoreElements()) {
                 return first.nextElement();

Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/DefinitionTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/DefinitionTag.java?view=diff&rev=518688&r1=518687&r2=518688
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/DefinitionTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/DefinitionTag.java Thu Mar 15 09:52:43 2007
@@ -125,11 +125,6 @@
         return EVAL_BODY_INCLUDE;
     }
 
-    /**
-     *
-     *
-     * @return
-     */
     public int doEndTag() throws JspException {
         TileDefinition d = new TileDefinition();
         d.setName(name);