Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mrd/jelly/distribution/Uniform.java


1   /*
2    * Normal.java
3    *
4    * Created on May 27, 2002, 5:40 PM
5    */
6   
7   package org.mrd.jelly.distribution;
8   
9   import org.apache.commons.jelly.*;
10  import org.apache.commons.jelly.TagSupport;
11  import org.apache.commons.jelly.expression.Expression;
12  import cern.jet.random.*;
13  
14  /** This is a random number generation class that produces pseudo-random
15   * doubles acording to a configured Normal Distribution. It uses the
16   * cern.jet.random.Normal Class to support this distribution.
17   *
18   * The distribution can be configured by supplying a mean and a standard
19   * devation. A seed can also be provided.
20   *
21   * @author  Mark R. Diggory
22   */
23  public class Uniform extends DistributionTagBase {
24      
25      /** Holds value of property min. */
26      private int min = Integer.MIN_VALUE;
27      
28      /** Holds value of property max. */
29      private int max = Integer.MAX_VALUE;
30      
31      
32      /** Used by Ant to check if the appropriate attributes have been filled out.
33       * @throws BuildException if attribute is not correctly filled in.
34       */
35      public void doStartTag(org.apache.commons.jelly.XMLOutput xMLOutput) throws Exception {
36          
37          
38          if (getVar() == null)
39              throw new MissingAttributeException("var");
40          
41          if(min > max)
42              throw new JellyException("min > max");
43      }
44      
45      /** Simply put, it is where the execution of the tag occurs.
46       * @throws BuildException (Currently does not).
47       */
48      public void doEndTag(org.apache.commons.jelly.XMLOutput xMLOutput) throws Exception {
49          
50          if( context.getVariable(getVar()) == null ){
51              context.setVariable(getVar(),new cern.jet.random.Uniform(min,max,this.getRandomElement()));
52          }
53          
54          
55      }
56      
57      
58      /** Getter for property min.
59       * @return Value of property min.
60       */
61      public int getMin() {
62          return this.min;
63      }
64      
65      /** Setter for property min.
66       * @param min New value of property min.
67       */
68      public void setMin(int min) {
69          this.min = min;
70      }
71      
72      /** Getter for property max.
73       * @return Value of property max.
74       */
75      public int getMax() {
76          return this.max;
77      }
78      
79      /** Setter for property max.
80       * @param max New value of property max.
81       */
82      public void setMax(int max) {
83          this.max = max;
84      }
85      
86      
87      
88      
89  }