You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2006/04/24 11:24:11 UTC

svn commit: r396487 - in /cocoon/branches/BRANCH_2_1_X: src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java src/webapp/WEB-INF/cocoon.xconf src/webapp/samples/modules/site2html.xsl src/webapp/samples/modules/sitemap.xmap status.xml

Author: antonio
Date: Mon Apr 24 02:24:08 2006
New Revision: 396487

URL: http://svn.apache.org/viewcvs?rev=396487&view=rev
Log:

<action dev="AG" type="fix" fixes-bug="COCOON-1716">
  RandomNumberModule: does not returns random number in the range (min,max) as expected.
</action>

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java
    cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/site2html.xsl
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/sitemap.xmap
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java?rev=396487&r1=396486&r2=396487&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java Mon Apr 24 02:24:08 2006
@@ -44,37 +44,28 @@
         returnNames = tmp;
     }
 
-    public Object getAttribute( String name, Configuration modeConf, Map objectModel ) throws ConfigurationException {
-        
-        long min = 0;
-        long max = java.lang.Long.MAX_VALUE;
+    public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+        long min = Long.parseLong((String)this.settings.get("min", "0"));
+        long max = Long.parseLong((String)this.settings.get("max", String.valueOf(Long.MAX_VALUE)));
         if (modeConf != null) {
-            min = Long.parseLong(modeConf.getAttribute("min","0"));
-            max = Long.parseLong(modeConf.getAttribute("max",String.valueOf(max)));
-            
+            min = modeConf.getAttributeAsLong("max", min);
+            max = modeConf.getAttributeAsLong("max", max);
+
             //preferred
-            min = Long.parseLong(modeConf.getChild("min").getValue("0"));
-            max = Long.parseLong(modeConf.getChild("max").getValue(String.valueOf(max)));
+            min = modeConf.getChild("min").getValueAsLong(min);
+            max = modeConf.getChild("max").getValueAsLong(max);
         }
-        return Long.toString(java.lang.Math.round(java.lang.Math.random()*(max-min)));
-
+        return Long.toString(min + Math.round(Math.random()*(max-min)));
     }
 
-
-    public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) throws ConfigurationException {
-
+    public Iterator getAttributeNames(Configuration modeConf, Map objectModel) throws ConfigurationException {
         return RandomNumberModule.returnNames.iterator();
     }
 
-
-    public Object[] getAttributeValues( String name, Configuration modeConf, Map objectModel )
+    public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
         throws ConfigurationException {
-
             List values = new LinkedList();
-            values.add( this.getAttribute(name, modeConf, objectModel ) );
-
+            values.add(this.getAttribute(name, modeConf, objectModel));
             return values.toArray();
-            
     }
-
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf?rev=396487&r1=396486&r2=396487&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/WEB-INF/cocoon.xconf Mon Apr 24 02:24:08 2006
@@ -211,8 +211,8 @@
     </component-instance>
 
     <!--+
-        | Following three modules definitions, 'defaults', 'myxml', and
-        | 'slashdot', are used only in the samples.
+        | Following five modules definitions, 'defaults', 'myxml',
+        | 'slashdot' '' and '', are used only in the samples.
         +-->
     <component-instance logger="core.modules.input" name="defaults"     class="org.apache.cocoon.components.modules.input.DefaultsModule">
       <values>
@@ -226,7 +226,14 @@
     <component-instance logger="core.modules.input" name="slashdot"     class="org.apache.cocoon.components.modules.input.XMLFileModule">
       <file src="http://slashdot.org/slashdot.rss"/>
     </component-instance>
-
+    <component-instance logger="core.modules.input" name="random-100-to-500" class="org.apache.cocoon.components.modules.input.RandomNumberModule">
+      <min>100</min>
+      <max>500</max>
+    </component-instance>
+    <component-instance  logger="core.modules.input" name="random-5000-to-10000" class="org.apache.cocoon.components.modules.input.RandomNumberModule">
+      <min>5000</min>
+      <max>10000</max>
+    </component-instance>
   </input-modules>
 
   <!--+

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/site2html.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/site2html.xsl?rev=396487&r1=396486&r2=396487&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/site2html.xsl (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/site2html.xsl Mon Apr 24 02:24:08 2006
@@ -69,7 +69,7 @@
         <table>
           <tr>
             <td class="copyright">
-              Copyright (c) 1999-2004 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.
+              Copyright (c) 1999-2006 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.
             </td>
           </tr>
         </table>

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/sitemap.xmap?rev=396487&r1=396486&r2=396487&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/modules/sitemap.xmap Mon Apr 24 02:24:08 2006
@@ -316,12 +316,14 @@
 
       <map:match pattern="content/randomnumber.xml">
         <map:generate type="jx" src="properties.xml">
-          <map:parameter name="x" value="{random:x}"/>
+          <map:parameter name="default" value="{random:x}"/>
+          <map:parameter name="from 100 to 500" value="{random-100-to-500:y}"/>
+          <map:parameter name="from 5000 to 10000" value="{random-5000-to-10000:z}"/>
         </map:generate>
         <map:transform src="properties2html.xsl">
           <map:parameter name="title" value="Random number module (RandomNumberModule)"/>
           <map:parameter name="description" value="Returns a random number in a
-            user-configurable range (by default 0 to 9999999999)"/>
+            user-configurable range (by default 0 to (2^63)-1 (cca. 9.22337204 × 10^18)"/>
         </map:transform>
         <map:serialize/>
       </map:match>

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=396487&r1=396486&r2=396487&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Mon Apr 24 02:24:08 2006
@@ -182,6 +182,9 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.10" date="TBD">
+    <action dev="AG" type="fix" fixes-bug="COCOON-1716">
+      RandomNumberModule: does not returns random number in the range (min,max) as expected.
+    </action>
     <action dev="AG" type="fix" fixes-bug="COCOON-1721" due-to="Georg Hüttenegger" due-to-email="georg.huettenegger@gmx.at">
       Performance Issue/JavaScriptFlowScript: If &lt;reload-scripts&gt; is set to false,
       don't check for last modification time of javascript source files.