You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by gl...@apache.org on 2002/12/19 05:33:06 UTC

cvs commit: jakarta-taglibs/i18n/src/org/apache/taglibs/i18n ConditionalTagSupport.java FormatCurrencyTEI.java FormatCurrencyTag.java FormatDateTEI.java FormatDateTag.java FormatDateTagSupport.java FormatDateTimeTEI.java FormatDateTimeTag.java FormatNumberTEI.java FormatNumberTag.java FormatPercentTEI.java FormatPercentTag.java FormatStringTEI.java FormatStringTag.java FormatTagSupport.java FormatTimeTEI.java FormatTimeTag.java IfdefTag.java IfndefTag.java LocaleTag.java MessageArgumentTag.java MessageTEI.java ResourceHelper.java

glenn       2002/12/18 20:33:06

  Modified:    i18n/src/org/apache/taglibs/i18n ConditionalTagSupport.java
                        FormatCurrencyTEI.java FormatCurrencyTag.java
                        FormatDateTEI.java FormatDateTag.java
                        FormatDateTagSupport.java FormatDateTimeTEI.java
                        FormatDateTimeTag.java FormatNumberTEI.java
                        FormatNumberTag.java FormatPercentTEI.java
                        FormatPercentTag.java FormatStringTEI.java
                        FormatStringTag.java FormatTagSupport.java
                        FormatTimeTEI.java FormatTimeTag.java IfdefTag.java
                        IfndefTag.java LocaleTag.java
                        MessageArgumentTag.java MessageTEI.java
                        ResourceHelper.java
  Log:
  Final refactoring, reformatting of source, and review for compliance
  with JSP custom tag lifecycle to ensure tags work in containers
  like Tomcat 4.1 which use custom tag pooling.
  
  Revision  Changes    Path
  1.5       +105 -124  jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/ConditionalTagSupport.java
  
  Index: ConditionalTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/ConditionalTagSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConditionalTagSupport.java	23 Feb 2002 19:34:42 -0000	1.4
  +++ ConditionalTagSupport.java	19 Dec 2002 04:33:05 -0000	1.5
  @@ -66,6 +66,7 @@
   import java.util.ResourceBundle;
   
   import javax.servlet.jsp.JspException;
  +import javax.servlet.jsp.JspTagException;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.BodyTag;
   import javax.servlet.jsp.tagext.BodyTagSupport;
  @@ -79,165 +80,145 @@
    *
    */
   public abstract class ConditionalTagSupport extends BodyTagSupport
  -  {
  -  // instance variables used during processing
  -  private String               _key = null;
  -  private ResourceBundle       _bundle = null;
  +{
   
  -  /**
  -   *  sets the key to use when looking up the value in the bundle
  -   */
  -  public void setKey(String key)
  -    {
  -    _key = key;
  -    }
  +    protected static String _tagname = "i18n:";
   
  -  /**
  -   *  @return the key to use
  -   */
  -  public String getKey()
  +    // instance variables used during processing
  +    private String               _key = null;
  +    private ResourceBundle       _bundle = null;
  +    private String               _bundleRef = null;
  +
  +    /**
  +     *  sets the key to use when looking up the value in the bundle
  +     */
  +    public void setKey(String key)
       {
  -    return _key;
  +        _key = key;
       }
   
  -  /**
  -   *  sets the bundle based on a variable defined in the page<br>
  -   *  if neither bundle or bundleRef are specified, uses the first bundle
  -   *  defined on the page by the i18n:bundle tag
  -   */
  -  public void setBundleRef(String varName)
  +    /**
  +     *  sets the bundle based on a variable defined in the page<br>
  +     *  if neither bundle or bundleRef are specified, uses the first bundle
  +     *  defined on the page by the i18n:bundle tag
  +     */
  +    public void setBundleRef(String varName)
       {
  -    _bundle = (ResourceBundle)pageContext.getAttribute(varName);
  +        _bundleRef = varName;
       }
   
  -  /**
  -   *  sets the bundle to an actual ResourceBundle object<br>
  -   *  if neither bundle or bundleRef are specified, uses the bundle most recently
  -   *  defined on the page by the i18n:bundle tag
  -   */
  -  public void setBundle(ResourceBundle aBundle)
  +    /**
  +     *  sets the bundle to an actual ResourceBundle object<br>
  +     *  if neither bundle or bundleRef are specified, uses the bundle most recently
  +     *  defined on the page by the i18n:bundle tag
  +     */
  +    public void setBundle(ResourceBundle aBundle)
       {
  -    _bundle = aBundle;
  +        _bundle = aBundle;
       }
   
  -  /**
  -   *  @return the bundle to use
  -   */
  -  public ResourceBundle getBundle()
  +    /**
  +     *  @return the bundle to use
  +     */
  +    public ResourceBundle getBundle()
       {
  -    if ( _bundle == null )
  -        {
  -        BundleTag bundleTag = (BundleTag)this.findAncestorWithClass(this,BundleTag.class);
  -        if (bundleTag != null)
  -            {
  -            _bundle = bundleTag.getBundle();
  +        if ( _bundleRef != null ) {
  +            _bundle = (ResourceBundle)pageContext.getAttribute(_bundleRef);
  +        }
  +        if ( _bundle == null ) {
  +            BundleTag bundleTag = (BundleTag)this.findAncestorWithClass(this,BundleTag.class);
  +            if (bundleTag != null) {
  +                _bundle = bundleTag.getBundle();
               }
           }
  -    if ( _bundle == null )
  -        {
  -        _bundle = ResourceHelper.getBundle(pageContext);
  +        if ( _bundle == null ) {
  +            _bundle = ResourceHelper.getBundle(pageContext);
           }
  -    return _bundle;
  +        return _bundle;
       }
   
  -  /**
  -   *  clears out the key for the next usage
  -   */
  -  public void release()
  +    /**
  +     *  clears out the key for the next usage
  +     */
  +    public void release()
       {
  -    super.release();
  -    _key = null;
  -    _bundle = null;
  +        super.release();
  +        _key = null;
  +        _bundle = null;
       }
   
  -  /**
  -   *  must be overridden by a subclass to return a boolean value
  -   */
  -  public abstract boolean shouldEvaluate()
  -          throws JspException;
  +    /**
  +     *  must be overridden by a subclass to return a boolean value
  +     */
  +    public abstract boolean shouldEvaluate() throws JspException;
   
  -  /**
  -   *  returns (if any) the value specified for the key in the bundle.
  -   *
  -   *  if no value is specified, traps the MissingResourceException and returns null
  -   */
  -  protected String getValue()
  -          throws JspException
  +    /**
  +     *  returns (if any) the value specified for the key in the bundle.
  +     *
  +     *  if no value is specified, traps the MissingResourceException and returns null
  +     */
  +    protected String getValue() throws JspException
       {
  -    String name = this.getClass().getName();
  -    
  -    // ensure we have a key
  -    String key = this.getKey();
  -    if ( this.getKey() == null)
  -        {
  -        throw new JspException(name + " requires a key.");
  +        // ensure we have a key
  +        if ( _key == null) {
  +            throw new JspTagException(
  +                this._tagname + " tag, requires a key attribute.");
           }
   
  -    // ensure a bundle was defined
  -    ResourceBundle bundle = this.getBundle();
  -    if ( this.getBundle() == null)
  -        {
  -        throw new JspException("A bundle must be provided as an attribute or defined by the i18n:bundle tag prior to using a " + name + ".");
  +        // ensure a bundle was defined
  +        ResourceBundle bundle = this.getBundle();
  +        if ( this.getBundle() == null) {
  +            throw new JspTagException(
  +                this._tagname + " tag, no bundle found for use with tag");
           }
   
  -    String value = null;
  -    try
  -        {
  -        value = bundle.getString(key);
  +        String value = null;
  +        try {
  +            value = bundle.getString(_key);
  +        } catch (java.util.MissingResourceException e) {
  +            value = null;
           }
  -    catch (java.util.MissingResourceException e)
  -        {
  -        value = null;
  -        }
  -    return value;
  +        return value;
       }
   
  -  /**
  -   *  locates the bundle and tests whether the key has a value
  -   */
  -  public int doStartTag()
  -          throws JspException
  +    /**
  +     *  locates the bundle and tests whether the key has a value
  +     */
  +    public int doStartTag() throws JspException
       {
  -    int returnValue;
  +        int returnValue;
   
  -    // evaluate the body if a value was found, otherwise skip it
  -    if ( this.shouldEvaluate() )
  -        {
  -        returnValue = BodyTag.EVAL_BODY_TAG;
  -        }
  -    else
  -        {
  -        returnValue = BodyTag.SKIP_BODY;
  +        // evaluate the body if a value was found, otherwise skip it
  +        if ( this.shouldEvaluate() ) {
  +            returnValue = BodyTag.EVAL_BODY_TAG;
  +        } else {
  +            returnValue = BodyTag.SKIP_BODY;
           }
   
  -    return returnValue;
  +        return returnValue;
       }
   
  -  /**
  -   * Prints the body of the tag.
  -   * <P>
  -   * Always return the flag for processing the rest of the JSP page.
  -   *
  -   * @return the flag for processing the rest of the JSP page.
  -   * @exception JspException if the writing out of the body fails.
  -   */
  -  public int doEndTag() throws JspException
  +    /**
  +     * Prints the body of the tag.
  +     * <P>
  +     * Always return the flag for processing the rest of the JSP page.
  +     *
  +     * @return the flag for processing the rest of the JSP page.
  +     * @exception JspException if the writing out of the body fails.
  +     */
  +    public int doEndTag() throws JspException
       {
  -    try
  -        {
  -        if (bodyContent != null)
  -            {
  -            bodyContent.writeOut(bodyContent.getEnclosingWriter());
  +        try {
  +            if (bodyContent != null) {
  +                bodyContent.writeOut(bodyContent.getEnclosingWriter());
               }
  -        }
  -    catch (java.io.IOException ioe)
  -        {
  -        throw new JspException("IO Error: " + ioe.getMessage());
  +        } catch (java.io.IOException ioe) {
  +            throw new JspTagException(
  +                this._tagname + " tag, IO Error: " + ioe.getMessage());
           }
   
  -    // This is not a loop, so always process the rest of the JSP page
  -    return BodyTag.EVAL_PAGE;
  +        // This is not a loop, so always process the rest of the JSP page
  +        return BodyTag.EVAL_PAGE;
       }
   
  -
  -  } // IfdefTag
  +}
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatCurrencyTEI.java
  
  Index: FormatCurrencyTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatCurrencyTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatCurrencyTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatCurrencyTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatCurrencyTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
  -} // end of class
   
  +}
  
  
  
  1.4       +7 -7      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatCurrencyTag.java
  
  Index: FormatCurrencyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatCurrencyTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FormatCurrencyTag.java	17 Dec 2002 04:18:59 -0000	1.3
  +++ FormatCurrencyTag.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -72,9 +72,9 @@
     */
   public class FormatCurrencyTag extends FormatTagSupport {
   
  -    public FormatCurrencyTag() {
  -    }
  -    
  +    protected static final String _tagname = "i18n:formatCurrency";
  +
  +
       // Implementation methods
       //-------------------------------------------------------------------------
       protected Format getFormat() {
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTEI.java
  
  Index: FormatDateTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatDateTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatDateTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatDateTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.4       +6 -8      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTag.java
  
  Index: FormatDateTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FormatDateTag.java	17 Dec 2002 04:18:59 -0000	1.3
  +++ FormatDateTag.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -74,14 +74,12 @@
     */
   public class FormatDateTag extends FormatDateTagSupport {
       
  +    protected static final String _tagname = "i18n:formatDate";
  +
       private Format format;
       private String pattern;
       private int style = DateFormat.SHORT;
  -    
   
  -    public FormatDateTag() {
  -    }
  -    
   
       // Tag interface
       //-------------------------------------------------------------------------
  
  
  
  1.3       +5 -8      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTagSupport.java
  
  Index: FormatDateTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTagSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatDateTagSupport.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatDateTagSupport.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -75,9 +75,6 @@
   
       private boolean initialised;
       
  -    public FormatDateTagSupport() {
  -    }
  -    
       public void release() {
           super.release();
           initialised = false;
  @@ -99,4 +96,4 @@
           initialised = true;
       }
   }
  - 
  \ No newline at end of file
  + 
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTimeTEI.java
  
  Index: FormatDateTimeTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTimeTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatDateTimeTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatDateTimeTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatDateTimeTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.4       +8 -9      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTimeTag.java
  
  Index: FormatDateTimeTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatDateTimeTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FormatDateTimeTag.java	17 Dec 2002 04:18:59 -0000	1.3
  +++ FormatDateTimeTag.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -72,13 +72,12 @@
     */
   public class FormatDateTimeTag extends FormatDateTagSupport   {
       
  +    protected static final String _tagname = "i18n:formatDateTime";
  +
       private int dateStyle = DateFormat.SHORT;
       private int timeStyle = DateFormat.SHORT;
  -    
  -    
  -    public FormatDateTimeTag() {
  -    }
  -    
  +
  +
       // Properties
       //-------------------------------------------------------------------------
       public void setDateStyle( String style ) {
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatNumberTEI.java
  
  Index: FormatNumberTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatNumberTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatNumberTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatNumberTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatNumberTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.4       +7 -9      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatNumberTag.java
  
  Index: FormatNumberTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatNumberTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FormatNumberTag.java	17 Dec 2002 04:18:59 -0000	1.3
  +++ FormatNumberTag.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -77,13 +77,11 @@
     */
   public class FormatNumberTag extends FormatTagSupport {
       
  +    protected static final String _tagname = "i18n:formatNumber";
  +
       private NumberFormat format;
       private String pattern;
  -    
  -    //-------------------------------------------------------------------------
  -    public FormatNumberTag() {
  -    }
  -    
  +
   
       // Tag interface
       //-------------------------------------------------------------------------
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatPercentTEI.java
  
  Index: FormatPercentTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatPercentTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatPercentTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatPercentTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatPercentTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.4       +6 -7      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatPercentTag.java
  
  Index: FormatPercentTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatPercentTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FormatPercentTag.java	17 Dec 2002 04:18:59 -0000	1.3
  +++ FormatPercentTag.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -72,9 +72,8 @@
     */
   public class FormatPercentTag extends FormatTagSupport {
       
  -    public FormatPercentTag() {
  -    }
  -    
  +    protected static final String _tagname = "i18n:formatPercent";
  +
       // Implementation methods
       //-------------------------------------------------------------------------
       protected Format getFormat() {
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatStringTEI.java
  
  Index: FormatStringTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatStringTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatStringTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatStringTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatStringTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.3       +8 -10     jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatStringTag.java
  
  Index: FormatStringTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatStringTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatStringTag.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatStringTag.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -81,16 +81,14 @@
     */
   public class FormatStringTag extends TagSupport {
       
  +    protected static final String _tagname = "i18n:formatString";
  +
       /** the value to be formatted */
       private String value;    
       /** the text output if the value is null */
       private String defaultText = "";
   
   
  -    public FormatStringTag() {
  -    }
  -    
  -
       // Tag interface
       //-------------------------------------------------------------------------
       public int doStartTag() throws JspException {
  @@ -142,8 +140,8 @@
       // Implementation methods
       //-------------------------------------------------------------------------    
       protected void handleIOException( IOException e ) throws JspException {
  -        pageContext.getServletContext().log( "Caught: IOException: " + e );
  -        throw new JspException( "IOException: " + e );
  +        pageContext.getServletContext().log( this._tagname + " tag, IOException: " + e );
  +        throw new JspException( this._tagname + " tag, IOException: " + e );
       }
   }
   
  
  
  
  1.6       +13 -11    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java
  
  Index: FormatTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FormatTagSupport.java	17 Dec 2002 04:18:59 -0000	1.5
  +++ FormatTagSupport.java	19 Dec 2002 04:33:05 -0000	1.6
  @@ -69,6 +69,7 @@
   
   import javax.servlet.ServletRequest;
   import javax.servlet.jsp.JspException;
  +import javax.servlet.jsp.JspTagException;
   import javax.servlet.jsp.JspWriter;
   import javax.servlet.jsp.PageContext;
   import javax.servlet.jsp.tagext.Tag;
  @@ -82,6 +83,8 @@
     */
   public abstract class FormatTagSupport extends TagSupport {
       
  +    protected static String _tagname = "i18n:";
  +
       /** the value to be formatted */
       private Object value;    
       /** the locale used to format the value */
  @@ -90,10 +93,6 @@
       private String defaultText = "";
   
   
  -    public FormatTagSupport() {
  -    }
  -    
  -
       // Tag interface
       //-------------------------------------------------------------------------
       public int doStartTag() throws JspException {
  @@ -108,7 +107,9 @@
               if ( value != null ) {
                   Format formatter = getFormat();
                   if ( formatter == null ) {
  -                    throw new JspException( "Could not find valid Format instance" );
  +                    throw new JspTagException(
  +                        this._tagname +
  +                        " tag, could not find valid Format instance");
                   }
                   text = formatter.format( value );
               }
  @@ -175,7 +176,8 @@
       
       protected void handleIOException( IOException e ) throws JspException {
           pageContext.getServletContext().log( "Caught: IOException: " + e );
  -        throw new JspException( "IOException: " + e );
  +        throw new JspTagException(
  +            this._tagname + " tag, IOException: " + e );
       }
   
       /** finds the current locale from either an outer LocaleTag or the 
  @@ -183,7 +185,7 @@
         *
         * @return a Locale instance
         */
  -    protected Locale findLocale() {
  +    private Locale findLocale() {
           // lets try find a LocaleTag first
           LocaleTag localeTag = (LocaleTag) findAncestorWithClass( this, LocaleTag.class );
           if ( localeTag != null ) {
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTimeTEI.java
  
  Index: FormatTimeTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTimeTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatTimeTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ FormatTimeTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class FormatTimeTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                             "java.lang.String",
  +                             true,
  +                             VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.4       +7 -9      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTimeTag.java
  
  Index: FormatTimeTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTimeTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FormatTimeTag.java	17 Dec 2002 04:18:59 -0000	1.3
  +++ FormatTimeTag.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -72,12 +72,10 @@
     */
   public class FormatTimeTag extends FormatDateTagSupport  {
   
  +    protected static final String _tagname = "i18n:formatTime";
  +
       private int style = DateFormat.SHORT;
  -    
  -    
  -    public FormatTimeTag() {
  -    }
  -    
  +
       // Properties
       //-------------------------------------------------------------------------
       public void setStyle( String style ) {
  
  
  
  1.3       +18 -19    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/IfdefTag.java
  
  Index: IfdefTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/IfdefTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IfdefTag.java	13 Jun 2001 03:24:42 -0000	1.2
  +++ IfdefTag.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -83,7 +83,7 @@
    *  <P>
    *  <H2>Examples</H2>
    *  <PRE>
  - *  &lt;i18n:localize bundle="test"/&gt;
  + *  &lt;i18n:bundle baseName="test"/&gt;
    *  &lt;i18n:ifdef key="test"&gt;
    *  misc html and jsp
    *  &lt;/i18n:ifdef&gt;
  @@ -95,22 +95,21 @@
    *
    */
   public class IfdefTag extends ConditionalTagSupport
  -  {
  -  /**
  -   *  locates the bundle and tests whether the key has a value
  -   */
  -  public boolean shouldEvaluate()
  -          throws JspException
  +{
  +
  +    protected static final String _tagname = "i18n:ifdef";
  +
  +    /**
  +     *  locates the bundle and tests whether the key has a value
  +     */
  +    public boolean shouldEvaluate() throws JspException
       {
  -    String value = this.getValue();
  -    if ( value == null || value.length() == 0 )
  -        {
  -        return false;
  -        }
  -    else
  -        {
  -        return true;
  +        String value = this.getValue();
  +        if ( value == null || value.length() == 0 ) {
  +            return false;
  +        } else {
  +            return true;
           }
       }
   
  -  } // IfdefTag
  +}
  
  
  
  1.3       +18 -19    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/IfndefTag.java
  
  Index: IfndefTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/IfndefTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IfndefTag.java	13 Jun 2001 03:24:42 -0000	1.2
  +++ IfndefTag.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -83,7 +83,7 @@
    *  <P>
    *  <H2>Examples</H2>
    *  <PRE>
  - *  &lt;i18n:localize bundle="test"/&gt;
  + *  &lt;i18n:bundle baseName="test"/&gt;
    *  &lt;i18n:ifndef key="test"&gt;
    *  misc html and jsp
    *  &lt;/i18n:ifndef&gt;
  @@ -95,22 +95,21 @@
    *
    */
   public class IfndefTag extends ConditionalTagSupport
  -  {
  -  /**
  -   *  locates the bundle and tests whether the key has a value
  -   */
  -  public boolean shouldEvaluate()
  -          throws JspException
  +{
  +
  +    protected static final String _tagname = "i18n:ifndef";
  +
  +    /**
  +     *  locates the bundle and tests whether the key has a value
  +     */
  +    public boolean shouldEvaluate() throws JspException
       {
  -    String value = this.getValue();
  -    if ( value == null || value.length() == 0 )
  -        {
  -        return true;
  -        }
  -    else
  -        {
  -        return false;
  +        String value = this.getValue();
  +        if ( value == null || value.length() == 0 ) {
  +            return true;
  +        } else {
  +            return false;
           }
       }
   
  -  } // IfndefTag
  +}
  
  
  
  1.6       +5 -6      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java
  
  Index: LocaleTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocaleTag.java	17 Dec 2002 04:18:59 -0000	1.5
  +++ LocaleTag.java	19 Dec 2002 04:33:05 -0000	1.6
  @@ -191,8 +191,7 @@
           Locale locale = null;
           if (language == null) {
               locale = pageContext.getResponse().getLocale();
  -        } else if (country == null)
  -            {
  +        } else if (country == null) {
               locale = new Locale(language,"");
           } else if (variant == null) {
               locale = new Locale(language, country);
  
  
  
  1.2       +21 -26    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/MessageArgumentTag.java
  
  Index: MessageArgumentTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/MessageArgumentTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MessageArgumentTag.java	31 Mar 2001 16:08:48 -0000	1.1
  +++ MessageArgumentTag.java	19 Dec 2002 04:33:05 -0000	1.2
  @@ -64,6 +64,7 @@
   import java.text.MessageFormat;
   
   import javax.servlet.jsp.JspException;
  +import javax.servlet.jsp.JspTagException;
   import javax.servlet.jsp.tagext.Tag;
   import javax.servlet.jsp.tagext.TagSupport;
   
  @@ -87,34 +88,28 @@
    *
    */
   public class MessageArgumentTag extends TagSupport
  -  {
  +{
     
  -  /**
  -   *  locate the parent tag and add the argument to the Message's arg list
  -   */
  -  public void setValue(Object argumentValue)
  -          throws JspException
  +    /**
  +     *  locate the parent tag and add the argument to the Message's arg list
  +     */
  +    public void setValue(Object argumentValue) throws JspException
       {
  -    // get the parent tag, and throw an exception if there isn't one
  -    Tag parentTag = this.getParent();
  -    if ( parentTag == null )
  -        {
  -        throw new JspException("MessageArgumentTag must be nested inside a MessageTag; this one wasn't nested at all.");
  +        // Get the parent MessageTag
  +        MessageTag messageTag = null;
  +        try {
  +            messageTag = (MessageTag)this.getParent();
  +        } catch (ClassCastException e) {
  +            ;
           }
   
  -    // cast to MessageTag and throw an exception if there's a problem
  -    MessageTag messageTag;
  -    try
  -        {
  -        messageTag = (MessageTag)parentTag;
  -        }
  -    catch (ClassCastException e)
  -        {
  -        throw new JspException("MessageArgumentTag must be nested inside a MessageTag, this one was nested inside a " + parentTag.getClass().getName());
  +        if ( messageTag == null ) {
  +            throw new JspTagException(
  +                "i18n:msgArg tag must be nested inside a message tag.");
           }
   
  -    // now we know we're safe to add the argument
  -    messageTag.addArg(argumentValue);
  +        // now we know we're safe to add the argument
  +        messageTag.addArg(argumentValue);
       }
   
  -  } // MessageArgumentTag
  +}
  
  
  
  1.3       +16 -20    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/MessageTEI.java
  
  Index: MessageTEI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/MessageTEI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MessageTEI.java	17 Dec 2002 04:18:59 -0000	1.2
  +++ MessageTEI.java	19 Dec 2002 04:33:05 -0000	1.3
  @@ -65,23 +65,19 @@
   
   public class MessageTEI extends TagExtraInfo
   {
  -  public VariableInfo [] getVariableInfo (TagData data)
  -  {
  -    String varName = data.getId();
  -    if ( varName == null )
  +    public VariableInfo [] getVariableInfo (TagData data)
       {
  -        return new VariableInfo[] {};
  +        String varName = data.getId();
  +        if ( varName == null ) {
  +            return new VariableInfo[] {};
  +        } else {
  +            return new VariableInfo [] {
  +                new VariableInfo(varName,
  +                                 "java.lang.String",
  +                                 true,
  +                                 VariableInfo.AT_END)
  +            };
  +        }
       }
  -    else
  -    {
  -        return new VariableInfo []
  -        {
  -            new VariableInfo(varName,
  -                         "java.lang.String",
  -                         true,
  -                         VariableInfo.AT_END)
  -        };
  -    }
  -  }
   
  -} // end of class
  +}
  
  
  
  1.4       +23 -24    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/ResourceHelper.java
  
  Index: ResourceHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/ResourceHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResourceHelper.java	19 Jan 2002 07:35:28 -0000	1.3
  +++ ResourceHelper.java	19 Dec 2002 04:33:05 -0000	1.4
  @@ -75,38 +75,37 @@
   
   
   /**
  - *  This class is used by the localize and message tags for caching the
  + *  This class is used by the bundle and message tags for caching the
    *  ResourceBundle in the session and request.
    *
    *  @author <a href="mailto:tdawson@wamnet.com">Tim Dawson</a>
    *
    */
   public class ResourceHelper
  -  {
  -  public static final String BUNDLE_REQUEST_KEY =
  +{
  +    public static final String BUNDLE_REQUEST_KEY =
             "org.apache.taglibs.i18n.ResourceHelper.Bundle";
   
  -  /**
  -   *  Retrieves the bundle cached in the page by a previous call to
  -   *  getBundle(PageContext,String).  This is used by the MessageTag since
  -   *  the bundle name is provided once, by the BundleTag.
  -   *  @return java.util.ResourceBundle the cached bundle
  -   */
  -  static public ResourceBundle getBundle(PageContext pageContext)
  +    /**
  +     *  Retrieves the bundle cached in the page by a previous call to
  +     *  getBundle(PageContext,String).  This is used by the MessageTag since
  +     *  the bundle name is provided once, by the BundleTag.
  +     *  @return java.util.ResourceBundle the cached bundle
  +     */
  +    static public ResourceBundle getBundle(PageContext pageContext)
       {
  -    return (ResourceBundle)pageContext.findAttribute(BUNDLE_REQUEST_KEY);
  +        return (ResourceBundle)pageContext.findAttribute(BUNDLE_REQUEST_KEY);
       }
   
  -  /**
  -   *  Caches the Bundle in the request using the BUNDLE_REQUEST_KEY.
  -   */
  -  static public void setBundle(PageContext pageContext,
  -                               ResourceBundle bundle,
  -                               int scope)
  +    /**
  +     *  Caches the Bundle in the request using the BUNDLE_REQUEST_KEY.
  +     */
  +    static public void setBundle(PageContext pageContext,
  +                                 ResourceBundle bundle,
  +                                 int scope)
       {
  -    // put this in the page so that the getMessage tag can get it quickly
  -    pageContext.setAttribute(BUNDLE_REQUEST_KEY,bundle,scope);
  +        // put this in the page so that the getMessage tag can get it quickly
  +        pageContext.setAttribute(BUNDLE_REQUEST_KEY,bundle,scope);
       }
     
  -
  -  } // ResourceHelper
  +}
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>