jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-taglibs/string/src/org/apache/taglibs/string/util StringW.java
Date Tue, 23 Apr 2002 13:36:38 GMT
bayard      02/04/23 06:36:37

  Modified:    string/xml string.xml
               string/src/org/apache/taglibs/string/util StringW.java
  Log:
  Bug submitted by: "L. Mohan Arun".
  The random methods return the same value within the same millisecond due
  to the methods creating a new Random object each time. I've pulled out the
  Random object and made it static so it can be reused.
  
  Revision  Changes    Path
  1.15      +86 -41    jakarta-taglibs/string/xml/string.xml
  
  Index: string.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/xml/string.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- string.xml	14 Feb 2002 05:23:25 -0000	1.14
  +++ string.xml	23 Apr 2002 13:36:37 -0000	1.15
  @@ -80,7 +80,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -101,7 +101,7 @@
             <description>
                Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -124,7 +124,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -145,7 +145,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -166,7 +166,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -188,7 +188,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -210,7 +210,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -233,7 +233,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -254,7 +254,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -278,7 +278,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -299,7 +299,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -321,7 +321,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -343,7 +343,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
         </tag>
         <tag>
  @@ -367,7 +367,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
     
           <example>
  @@ -403,7 +403,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <example>
             <usage>
  @@ -439,7 +439,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <example>
             <usage>
  @@ -473,7 +473,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <example>
             <usage>
  @@ -518,7 +518,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>set</name>
  @@ -563,7 +563,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>set</name>
  @@ -610,7 +610,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>set</name>
  @@ -655,7 +655,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -712,7 +712,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -768,7 +768,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -825,7 +825,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -871,7 +871,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -917,7 +917,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -964,7 +964,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -1010,7 +1010,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -1056,7 +1056,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -1100,7 +1100,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -1145,7 +1145,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>delimiter</name>
  @@ -1193,7 +1193,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>with</name>
  @@ -1259,7 +1259,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>start</name>
  @@ -1318,7 +1318,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>count</name>
  @@ -1366,7 +1366,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>width</name>
  @@ -1432,7 +1432,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>open</name>
  @@ -1488,7 +1488,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>substring</name>
  @@ -1536,7 +1536,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>value</name>
  @@ -1595,7 +1595,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>replace</name>
  @@ -1670,7 +1670,7 @@
             <description>
                 Variable to store result in.
             </description>
  -          <availability>1.1</availability>
  +          <availability>1.0</availability>
           </attribute>
           <attribute>
             <name>count</name>
  @@ -1744,7 +1744,52 @@
   
   </taglib>
   
  -<revision release="Initial Version" date="08/30/2001"> 
  +<revision release="1.0" date="2002/04/20"> 
  +  <description>
  +    Release of code....
  +  </description>
  +<section name="New features added">
  +<item>Changed implementation of random() to use the same Randome instance 
  +across calls. This stops the same value coming out if called in the same 
  +millisecond.</item>
  +
  +<item>Swapcase tag. Non-alphabetical text was replaced with the previous alphabetical

  +character and not left alone. this_is_blue becomes thississblue.</item>
  +
  +<item>Substring tag. Added protection into substring so that it doesnt complain
  +when end indexes larger than the string are passed in.</item>
  +<item>Added ability to pass -ve indexes in, meaning distance from the end of
  +the string.</item>
  +
  +<item>Newlines on their own were being rubbed out in the wordWrap method.
  +More generically, any whitespace delimiter was being rubbed out. This is due
  +to the fact that the method considers whitespace to be the type of character
  +to split upon. It forgot that a newline was a whitespace though.</item>
  +
  +<item>Changed implementation of StringWisLine so it doesn't try to goto the
  +n+1th element of an array. Was a missing -1 in the algorithm's
  +max value.</item>
  +
  +<item>Updated StringW.center/leftPad/rightPad inline with fixes in Commons.</item>
  +<item>Updated StringW.replaceString with the version in the Commons.</item>
  +<item>Fixed StringW.evaulateSet's javadoc.</item>
  +<item>Fixed a logic fault in the negation logic for CharSet class.</item>
  +
  +<item>ReverseDelimitedString renamed to ReverseDelimitedStringTag.</item>
  +
  +<item>Substring tag default start set to be 0 so an end can be specified on 
  +its own. Default end no longer -1 as implementation no longer uses that.</item>
  +
  +<item>Fixed a bug in which the tags were returning SKIP_BODY. This is illegal in

  +a doEndTag method.  Now it returns EVAL_PAGE.</item>
  +
  +<item>Added a 'var' attribute to all tags. The var attribute tells the tag to
  +place the result in the pagecontext under that variable name and not to
  +output the result to the screen. </item>
  +</section>
  +</revision>
  +
  +<revision release="Initial Version" date="2001/08/30"> 
     <description>
       Initial version of String tag-library. Matching the v0.4 of the 
       GenerationJava String taglib.
  
  
  
  1.9       +13 -6     jakarta-taglibs/string/src/org/apache/taglibs/string/util/StringW.java
  
  Index: StringW.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/util/StringW.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StringW.java	15 Apr 2002 21:53:55 -0000	1.8
  +++ StringW.java	23 Apr 2002 13:36:37 -0000	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/util/StringW.java,v
1.8 2002/04/15 21:53:55 bayard Exp $
  - * $Revision: 1.8 $
  - * $Date: 2002/04/15 21:53:55 $
  + * $Header: /home/cvs/jakarta-taglibs/string/src/org/apache/taglibs/string/util/StringW.java,v
1.9 2002/04/23 13:36:37 bayard Exp $
  + * $Revision: 1.9 $
  + * $Date: 2002/04/23 13:36:37 $
    *
    * ====================================================================
    *
  @@ -85,6 +85,13 @@
   final public class StringW {
   
       /**
  +     * Random object used by random method. This has to be not local
  +     * to the random method so as to not return the same value in the
  +     * same millisecond.
  +     */
  +    private static Random RANDOM = new Random();   
  +
  +    /**
        * Merge an array of Objects into a list of delimited 
        * Strings. No delimiter is added before or after the list.
        *
  @@ -1470,16 +1477,16 @@
                   end = Integer.MAX_VALUE;
               }
           }
  -        Random rnd = new Random();
  +
           StringBuffer buffer = new StringBuffer();
           int gap = end - start;
   
           while(count-- != 0) {
               char ch;
               if(set == null) {
  -                ch = (char)(rnd.nextInt(gap) + start);
  +                ch = (char)(RANDOM.nextInt(gap) + start);
               } else {
  -                ch = set[rnd.nextInt(gap) + start];
  +                ch = set[RANDOM.nextInt(gap) + start];
               }
               if( (letters && numbers && Character.isLetterOrDigit(ch)) ||
                   (letters && Character.isLetter(ch)) ||
  
  
  

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


Mime
View raw message