jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1209904 - in /jmeter/trunk: src/functions/org/apache/jmeter/functions/CharFunction.java xdocs/changes.xml xdocs/usermanual/functions.xml
Date Sat, 03 Dec 2011 13:03:07 GMT
Author: sebb
Date: Sat Dec  3 13:03:07 2011
New Revision: 1209904

URL: http://svn.apache.org/viewvc?rev=1209904&view=rev
Log:
Simplify char function and support octal
Fix error in CRLF example

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/functions.xml

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java?rev=1209904&r1=1209903&r2=1209904&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/CharFunction.java Sat Dec  3 13:03:07
2011
@@ -57,18 +57,13 @@ public class CharFunction extends Abstra
         StringBuilder sb = new StringBuilder(values.length);
         for (int i=0; i < values.length; i++){
             String numberString = ((CompoundVariable) values[i]).execute().trim();
-            long value = 0;
             try {
-                if (numberString.startsWith("0x")) {// $NON-NLS-1$
-                    value=Long.parseLong(numberString.substring(2),16);
-                } else {
-                    value=Long.parseLong(numberString);
-                }
+                long value=Long.decode(numberString).longValue();
+                char ch = (char) value;
+                sb.append(ch);
             } catch (NumberFormatException e){
                 log.warn("Could not parse "+numberString+" : "+e);
             }
-            char ch = (char) value;
-            sb.append(ch);
         }
         return sb.toString();
 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1209904&r1=1209903&r2=1209904&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Dec  3 13:03:07 2011
@@ -131,6 +131,7 @@ This behaviour can be changed with prope
 
 <h3>Functions</h3>
 <ul>
+<li>The CRLF example for the char function was wrong; CRLF=(0xD,0xA), not (0xC,0xA)</li>
 </ul>
 
 <h3>I18N</h3>
@@ -196,6 +197,7 @@ This behaviour can be changed with prope
 <ul>
 <li>Bug 52006 - Create a function RandomString to generate random Strings</li>
 <li>Bug 52016 - It would be useful to support Jexl2</li>
+<li>__char() function now supports octal values</li>
 </ul>
 
 <h3>I18N</h3>

Modified: jmeter/trunk/xdocs/usermanual/functions.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/functions.xml?rev=1209904&r1=1209903&r2=1209904&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/functions.xml (original)
+++ jmeter/trunk/xdocs/usermanual/functions.xml Sat Dec  3 13:03:07 2011
@@ -1029,12 +1029,12 @@ The following variables are made availab
 
 <properties>
         <property name="Unicode character number (decimal or 0xhex)" required="Yes">
-        The decimal number (or hex number, if prefixed by 0x) to be converted to a Unicode
character.
+        The decimal number (or hex number, if prefixed by 0x, or octal, if prefixed by 0)
to be converted to a Unicode character.
         </property>
 </properties>
 <p>Examples:
 <br/>
-${__char(0xC,0xA)} = CRLF
+${__char(13,10)} = ${__char(0xD,0xA)} = ${__char(015,012)} = CRLF
 <br/>
 ${__char(165)} = &#165; (yen)
  </p>



Mime
View raw message