1 /*
2 * Copyright (C) 2002-2003, Mark Diggory
3 *
4 * This file is part of the Repast Taglibrary Package for use with Jelly.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. License
19 * information is also available at http://www.gnu.org.
20 *
21 * @author Mark Diggory <mdiggory@latte.harvard.edu>
22 */
23 package org.mrd.jelly.random;
24
25 import org.apache.commons.jelly.*;
26 import org.apache.commons.jelly.expression.Expression;
27
28 /***
29 *
30 * @author Administrator
31 */
32 public class MersenneTwister extends TagSupport {
33
34 /*** Holds value of property var. */
35 private String var;
36
37 /*** Holds value of property seed. */
38 private Expression seed;
39
40
41 /*** Used to check if the appropriate attributes have been filled out.
42 * @throws BuildException if attribute is not correctly filled in.
43 */
44 public void doTag(XMLOutput xMLOutput)
45 throws MissingAttributeException,
46 JellyTagException {
47
48 if (var == null)
49 throw new MissingAttributeException("var");
50
51 this.invokeBody(xMLOutput);
52
53 if(seed == null){
54 context.setVariable(getVar(),new cern.jet.random.engine.MersenneTwister((int)System.currentTimeMillis()));
55 }else{
56 context.setVariable(getVar(),new cern.jet.random.engine.MersenneTwister(Integer.parseInt(this.seed.evaluateAsString(this.context))));
57 }
58 }
59
60 /*** Getter for property seed.
61 * @return Value of property seed.
62 */
63 public Expression getSeed() {
64 return this.seed;
65 }
66
67 /*** Setter for property seed.
68 * @param seed New value of property seed.
69 */
70 public void setSeed(Expression seed) {
71 this.seed = seed;
72 }
73
74 /*** Getter for property var.
75 * @return Value of property var.
76 */
77 public String getVar() {
78 return this.var;
79 }
80
81 /*** Setter for property var.
82 * @param var New value of property var.
83 */
84 public void setVar(String var) {
85 this.var = var;
86 }
87
88 }
This page was automatically generated by Maven