jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gl...@locus.apache.org
Subject cvs commit: jakarta-taglibs/session/src/org/apache/taglibs/session AttributesTag.java
Date Sun, 29 Oct 2000 23:00:17 GMT
glenn       00/10/29 15:00:17

  Modified:    session/src/org/apache/taglibs/session AttributesTag.java
  Log:
  Cleanup for release
  
  Revision  Changes    Path
  1.2       +35 -48    jakarta-taglibs/session/src/org/apache/taglibs/session/AttributesTag.java
  
  Index: AttributesTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/session/src/org/apache/taglibs/session/AttributesTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributesTag.java	2000/09/24 03:25:38	1.1
  +++ AttributesTag.java	2000/10/29 23:00:16	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/session/src/org/apache/taglibs/session/AttributesTag.java,v
1.1 2000/09/24 03:25:38 glenn Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/09/24 03:25:38 $
  + * $Header: /home/cvs/jakarta-taglibs/session/src/org/apache/taglibs/session/AttributesTag.java,v
1.2 2000/10/29 23:00:16 glenn Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/10/29 23:00:16 $
    *
    * ====================================================================
    *
  @@ -76,24 +76,16 @@
    * <p>
    * Loops through all the attributes in the HttpSession.
    * <p>
  - * If the optional attribute <b>name</b> is present only the attribute of
  - * that name is retreived.
  - * <p>
    * JSP Tag Lib Descriptor
    * <p><pre>
    * &lt;name&gt;attributes&lt;/name&gt;
    * &lt;tagclass&gt;org.apache.taglibs.session.AttributesTag&lt;/tagclass&gt;
    * &lt;teiclass&gt;org.apache.taglibs.session.AttributesTEI&lt;/teiclass&gt;
    * &lt;bodycontent&gt;JSP&lt;/bodycontent&gt;
  - * &lt;info&gt;Used to loop through all attributes or get a single attribute.&lt;/info&gt;
  + * &lt;info&gt;Used to loop through all session attributes.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  - *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  - *   &lt;/attribute&gt;
  - *   &lt;attribute&gt;
  - *     &lt;name&gt;name&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -103,30 +95,28 @@
   
   public class AttributesTag extends BodyTagSupport
   {
  -    private String name = null;
  +    // Clients session
       private HttpSession sess = null;
  +    // All the session attributes
       private Enumeration attributes = null;
  +    // Name of the current session attribute
       private String attribute = null;
   
       /**
  -     * Gets the session attributes or attribute with <b>name</b>.
  +     * Gets the session attributes.
        *
  -     * @return SKIP_BODY if no attributes or attribute with <b>name</b> is
not found, EVAL_BODY_TAG if attribute exists
  +     * @return SKIP_BODY if there are no session attributes, EVAL_BODY_TAG if an attribute
exists
        */
  -    public int doStartTag() throws JspException
  +    public final int doStartTag() throws JspException
       {
   	// Get the session
   	sess = pageContext.getSession();
   
  -	if( name != null ) {
  -	    if( sess.getAttribute(name) != null )
  -		attribute = name;
  -	} else {
  -	    attributes = sess.getAttributeNames();
  -	    if( attributes == null || !attributes.hasMoreElements() )
  -		return SKIP_BODY;
  -	    attribute = (String)attributes.nextElement();
  -	}
  +	// Loop through all session attributes
  +	attributes = sess.getAttributeNames();
  +	if( attributes == null || !attributes.hasMoreElements() )
  +	    return SKIP_BODY;
  +	attribute = (String)attributes.nextElement();
   	if( attribute == null )
   	    return SKIP_BODY;
   
  @@ -135,27 +125,29 @@
       }
   
       /**
  -     * Method called at end of each attributes tag.
  +     * Method called at end of each iteration of the attributes tag.
        *
  -     * @return EVAL_BODY_TAG if there is another attribute, or SKIP_BODY if there are no
more attributes or this is a named attribute
  +     * @return EVAL_BODY_TAG if there is another session attribute, or SKIP_BODY if there
are no more attributes
        */
  -    public int doAfterBody() throws JspException
  +    public final int doAfterBody() throws JspException
       {
   	// See if this is the last or a named attribute
  -	if( name != null || !attributes.hasMoreElements() )
  +	if( !attributes.hasMoreElements() )
   	    return SKIP_BODY;
  -	// There is another attribute, so loop again
   	attribute = (String)attributes.nextElement();
   	if( attribute == null )
   	    return SKIP_BODY;
  +	// There is another attribute, so loop again
   	return EVAL_BODY_TAG;
       }
   
       /**
  -     * Method called at end of Tag
  +     * Method called at end of attributes tag, outputs the body
  +     * of the tag.
  +     *
        * @return EVAL_PAGE
        */
  -    public int doEndTag() throws JspException
  +    public final int doEndTag() throws JspException
       {
   	try
   	{
  @@ -168,31 +160,26 @@
   	return EVAL_PAGE;
       }
   
  -    public void setName(String str)
  -    {
  -	name = str;
  -    }
  -
       /**
  -     * Returns the name of the attribute.
  +     * Returns the name of the session attribute.
        * <p>
        * &lt;jsp:getProperty name=<i>"id"</i> property="name"/&gt;
        *
  -     * @return the attribute name as a String
  +     * @return String - the session attribute name
        */
  -    public String getName()
  +    public final String getName()
       {
   	return attribute;
       }
   
       /**
  -     * Returns the value of the attribute.
  +     * Returns the value of the session attribute.
        * <p>
  -     * &lt;jsp:getProperty name=<i>"id"</i> property="attribute"/&gt;
  +     * &lt;jsp:getProperty name=<i>"id"</i> property="value"/&gt;
        *
  -     * @return the value of the attribute as a String
  +     * @return String - the value of the session attribute
        */
  -    public String getAttribute()
  +    public final String getValue()
       {
   	Object value = sess.getAttribute(attribute);
   	if( value == null )
  @@ -201,11 +188,11 @@
       }
   
       /**
  -     * Remove the script variable after attributes tag closed out
  +     * Remove the script variable id after attributes tag closed out
        */
  -    public void release()
  +    public final void release()
       {
  -	if( id.length() > 0 )
  +	if( id != null && id.length() > 0 )
   	    pageContext.removeAttribute(id,PageContext.PAGE_SCOPE);
       }
   }
  
  
  

Mime
View raw message