jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From felip...@apache.org
Subject cvs commit: jakarta-taglibs/string/xml string.xml
Date Fri, 12 Mar 2004 01:45:51 GMT
felipeal    2004/03/11 17:45:51

  Modified:    string/src/org/apache/taglibs/string DecodeUrlTag.java
                        EncodeUrlTag.java
               string/xml string.xml
  Added:       string/src/org/apache/taglibs/string
                        BaseEncodeDecodeTagSupport.java
  Log:
  added 'encoding' attribute to <string:decodeUrl> (for consistency's sake :-)
  
  Revision  Changes    Path
  1.5       +11 -12    jakarta-taglibs/string/src/org/apache/taglibs/string/DecodeUrlTag.java
  
  Index: DecodeUrlTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/DecodeUrlTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DecodeUrlTag.java	6 Mar 2004 06:58:48 -0000	1.4
  +++ DecodeUrlTag.java	12 Mar 2004 01:45:51 -0000	1.5
  @@ -16,27 +16,26 @@
   package org.apache.taglibs.string;
   
   import java.net.URLDecoder;
  -import javax.servlet.jsp.JspException;
  +import java.io.UnsupportedEncodingException;
   
   /**
    * Decode a URL so it may be nicely printed.
    * 
    * @author bayard@generationjava.com
    */
  -public class DecodeUrlTag extends StringTagSupport {
  +public class DecodeUrlTag extends BaseEncodeDecodeTagSupport {
   
       public DecodeUrlTag() {
  -        super();
  -    }
  -
  -
  -    public String changeString(String text) throws JspException {
  -        return URLDecoder.decode(text);
  -    }
  -
  -    public void initAttributes() {
  -
  +        super( "decodeUrl" );
       }
   
  +  public String actionWithEncoding( String text, String encoding )
  +    throws UnsupportedEncodingException {
  +    return URLDecoder.decode( text, encoding );
  +  }
  +  
  +  public String actionWithoutEncoding( String text ) {
  +    return URLDecoder.decode( text );
  +  }
   
   }
  
  
  
  1.7       +10 -36    jakarta-taglibs/string/src/org/apache/taglibs/string/EncodeUrlTag.java
  
  Index: EncodeUrlTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/EncodeUrlTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EncodeUrlTag.java	11 Mar 2004 12:25:40 -0000	1.6
  +++ EncodeUrlTag.java	12 Mar 2004 01:45:51 -0000	1.7
  @@ -16,52 +16,26 @@
   package org.apache.taglibs.string;
   
   import java.net.URLEncoder;
  -import javax.servlet.jsp.JspException;
   import java.io.UnsupportedEncodingException;
   
   /**
  - * Encode a String to that it may be used as a URL.
  + * Encode a URL so it may be nicely printed.
    * 
    * @author bayard@generationjava.com
    */
  -public class EncodeUrlTag extends StringTagSupport {
  -
  -  private String encoding = null;
  +public class EncodeUrlTag extends BaseEncodeDecodeTagSupport {
   
       public EncodeUrlTag() {
  -        super();
  +        super( "encodeUrl" );
       }
   
  -  public void setEncoding( String encoding ) {
  -    this.encoding = encoding;
  +  public String actionWithEncoding( String text, String encoding )
  +    throws UnsupportedEncodingException  {
  +    return URLEncoder.encode( text, encoding );
  +  }
  +  
  +  public String actionWithoutEncoding( String text ) {
  +    return URLEncoder.encode( text );
     }
  -
  -
  -    public String changeString(String text) throws JspException {
  -
  -      String result = null;
  -      if ( this.encoding != null ) {
  -        try {
  -          //          System.out.println( "++++ TEXT: "+ text + " ENCODING: "+ this.encoding
);
  -          result = URLEncoder.encode( text, this.encoding );
  -          //          System.out.println( "RESULT: "+ result );
  -        } catch( NoSuchMethodError exc ) {
  -          System.err.println( "WARNING: attribute encoding on tag encodeUrl should be used
in a " +
  -                            "J2SE 1.4 compatible web container. Using default container.");
  -        } catch( UnsupportedEncodingException exc2 ) {
  -          System.err.println( "WARNING: unsupported encoding used on tag encodeUrl: " +
this.encoding );
  -        }
  -      }
  -      if ( result == null ) {
  -        result = URLEncoder.encode(text);
  -      }
  -      return result;
  -      
  -    }
  -
  -    public void initAttributes() {
  -      this.encoding = null;
  -    }
  -
   
   }
  
  
  
  1.1                  jakarta-taglibs/string/src/org/apache/taglibs/string/BaseEncodeDecodeTagSupport.java
  
  Index: BaseEncodeDecodeTagSupport.java
  ===================================================================
  /*
   * Copyright 1999,2004 The Apache Software Foundation.
   * 
   * Licensed 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.
   */
  package org.apache.taglibs.string;
  
  import java.net.URLEncoder;
  import javax.servlet.jsp.JspException;
  import java.io.UnsupportedEncodingException;
  
  /**
   * Base class for encodeUrlTag and decodeUrlTag.
   *
   * This class will handle the JDK 1.4/1.3 compatibility issues
   * 
   * @author Felipe Leme (felipeal at apache dot org)
   */
  abstract class BaseEncodeDecodeTagSupport extends StringTagSupport {
  
    private String encoding = null;
    private String tagName = null;
  
    public BaseEncodeDecodeTagSupport( String tagName ) {
      super();
      this.tagName = tagName;
    }
  
    public void setEncoding( String encoding ) {
      this.encoding = encoding;
    }
  
    protected abstract String actionWithEncoding( String text, String encoding )
      throws UnsupportedEncodingException;
    
    protected abstract String actionWithoutEncoding( String text );
    
    public final String changeString(String text) throws JspException {
  
        String result = null;
        if ( this.encoding != null ) {
          try {
            //          System.out.println( "++++ TEXT: "+ text + " ENCODING: "+ this.encoding
);
            result = actionWithEncoding( text, this.encoding );
            //          System.out.println( "RESULT: "+ result );
          } catch( NoSuchMethodError exc ) {
            System.err.println( "WARNING: attribute encoding on tag "+tagName+" should be
used in a " +
                                "J2SE 1.4 compatible web container. Using default container.");
          } catch( UnsupportedEncodingException exc2 ) {
            System.err.println( "WARNING: unsupported encoding used on tag "+tagName+": "+this.encoding
);
          }
        }
        if ( result == null ) {
          result = actionWithoutEncoding( text );
        }
        return result;
        
      }
  
      public void initAttributes() {
        this.encoding = null;
      }
  
  
  }
  
  
  
  1.33      +28 -1     jakarta-taglibs/string/xml/string.xml
  
  Index: string.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/xml/string.xml,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- string.xml	11 Mar 2004 12:09:05 -0000	1.32
  +++ string.xml	12 Mar 2004 01:45:51 -0000	1.33
  @@ -475,7 +475,7 @@
             <description>
                 Encoding the URL should be encoded by (NOTE: available only on J2SE 1.4 compatible
containers - otherwise, will use container's platform default encoding);
             </description>
  -          <availability>1.0</availability>
  +          <availability>1.1</availability>
           </attribute>
           <example>
             <usage>
  @@ -511,6 +511,16 @@
             </description>
             <availability>1.0</availability>
           </attribute>
  +        <attribute>
  +          <name>encoding</name>
  +          <required>false</required>
  +          <rtexprvalue>true</rtexprvalue>
  +          <type>java.lang.String</type>
  +          <description>
  +              Encoding the URL should be decoded by (NOTE: available only on J2SE 1.4 compatible
containers - otherwise, will use container's platform default encoding);
  +          </description>
  +          <availability>1.1</availability>
  +        </attribute>
           <example>
             <usage>
               <comment>
  @@ -2032,6 +2042,23 @@
     </tagtoc>
   
   </taglib>
  +
  +<revision release="1.1.0" date="somewhere_2004"> 
  +  <description>
  +    Although this is mostly a bug fixing release, we decided to create a new minor release,
as it now depends on Commons Lang 2.0 and has some new features (see below)
  +  </description>
  +<section name="Bugfixes">
  +    <item>Changed license to ASF 2.0</item>
  +    <item>Bug 25136 - &lt;str:str:chomp&gt; wasn't working anymore</item>
  +    <item>Bug 27324 - changed handlers code to be compliant with Commons Lang 2.0</item>
  +</section>
  +
  +<section name="NewFeatures">
  +    <item>Added attribute delimiterInside to &lt;str:wordWrap&gt; (bug 21866)</item>
  +    <item>Added attribute encoding to &lt;str:encodeUrl&gt; and &lt;str:decodeUrl&gt;
(bug 18964)</item>
  +    <item>Added new custom tag, &lt;str:join&gt; (bug 20204)</item>
  +</section>
  +</revision>
   
   <revision release="1.0.1" date="2003/02/20"> 
     <description>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Mime
View raw message