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 12:33:06 UTC
svn commit: r396505 - in /cocoon/trunk:
blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/
core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/
core/cocoon-webapp/src/ma...
Author: antonio
Date: Mon Apr 24 03:33:03 2006
New Revision: 396505
URL: http://svn.apache.org/viewcvs?rev=396505&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/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/site2html.xsl
cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java
cocoon/trunk/core/cocoon-webapp/src/main/webapp/WEB-INF/xconf/cocoon-core.xconf
Modified: cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/site2html.xsl
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/site2html.xsl?rev=396505&r1=396504&r2=396505&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/site2html.xsl (original)
+++ cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/site2html.xsl Mon Apr 24 03:33:03 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/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap?rev=396505&r1=396504&r2=396505&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap Mon Apr 24 03:33:03 2006
@@ -315,12 +315,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/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java?rev=396505&r1=396504&r2=396505&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/modules/input/RandomNumberModule.java Mon Apr 24 03:33:03 2006
@@ -43,37 +43,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/trunk/core/cocoon-webapp/src/main/webapp/WEB-INF/xconf/cocoon-core.xconf
URL: http://svn.apache.org/viewcvs/cocoon/trunk/core/cocoon-webapp/src/main/webapp/WEB-INF/xconf/cocoon-core.xconf?rev=396505&r1=396504&r2=396505&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-webapp/src/main/webapp/WEB-INF/xconf/cocoon-core.xconf (original)
+++ cocoon/trunk/core/cocoon-webapp/src/main/webapp/WEB-INF/xconf/cocoon-core.xconf Mon Apr 24 03:33:03 2006
@@ -210,8 +210,9 @@
</component-instance>
<!--+
- | Following three modules definitions, 'defaults', 'myxml', and
- | 'slashdot', are used only in the samples.
+ | Following five modules definitions, 'defaults', 'myxml',
+ | 'slashdot' 'random-100-to-500' and 'random-5000-to-10000',
+ | are used only in the samples.
+-->
<component-instance logger="core.modules.input" name="defaults" class="org.apache.cocoon.components.modules.input.DefaultsModule">
<values>
@@ -224,6 +225,14 @@
</component-instance>
<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>