KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > math > function > DefaultContext


1 /*
2  *
3  * Copyright (c) 2003-2004 The Apache Software Foundation. All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6  * use this file except in compliance with the License. You may obtain a copy
7  * of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations
15  * under the License.
16  *
17  */

18 package org.apache.commons.math.function;
19
20 /**
21
22  *
23  * To change the template for this generated type comment go to
24  * Window>Preferences>Java>Code Generation>Code and Comments
25  */

26 public class DefaultContext implements EvaluationContext {
27
28     /**
29      *
30      */

31     public DefaultContext() {
32         super();
33         // TODO Auto-generated constructor stub
34
}
35
36     /* (non-Javadoc)
37      * @see org.apache.archimedes.EvaluationContext#doubleValue(org.apache.archimedes.Evaluation)
38      */

39     public double doubleValue(Evaluation argument) throws EvaluationException {
40         // TODO Auto-generated method stub
41
return ((DefaultValue)argument.evaluate(this)).doubleValue();
42     }
43
44     /* (non-Javadoc)
45      * @see org.apache.archimedes.EvaluationContext#floatValue(org.apache.archimedes.Evaluation)
46      */

47     public float floatValue(Evaluation argument) throws EvaluationException {
48         // TODO Auto-generated method stub
49
return ((DefaultValue)argument.evaluate(this)).floatValue();
50     }
51
52     /* (non-Javadoc)
53      * @see org.apache.archimedes.EvaluationContext#intValue(org.apache.archimedes.Evaluation)
54      */

55     public int intValue(Evaluation argument) throws EvaluationException {
56         // TODO Auto-generated method stub
57
return ((DefaultValue)argument.evaluate(this)).intValue();
58     }
59
60     /* (non-Javadoc)
61      * @see org.apache.archimedes.EvaluationContext#longValue(org.apache.archimedes.Evaluation)
62      */

63     public long longValue(Evaluation argument) throws EvaluationException {
64         // TODO Auto-generated method stub
65
return ((DefaultValue)argument.evaluate(this)).longValue();
66     }
67
68     /* (non-Javadoc)
69      * @see org.apache.archimedes.EvaluationContext#shortValue(org.apache.archimedes.Evaluation)
70      */

71     public short shortValue(Evaluation argument) throws EvaluationException {
72         // TODO Auto-generated method stub
73
return ((DefaultValue)argument.evaluate(this)).shortValue();
74     }
75
76     /* (non-Javadoc)
77      * @see org.apache.archimedes.EvaluationContext#byteValue(org.apache.archimedes.Evaluation)
78      */

79     public byte byteValue(Evaluation argument) throws EvaluationException {
80         // TODO Auto-generated method stub
81
return ((DefaultValue)argument.evaluate(this)).byteValue();
82     }
83
84     /* (non-Javadoc)
85      * @see org.apache.archimedes.EvaluationContext#evaluate(double)
86      */

87     public Evaluation evaluate(double d) {
88         // TODO Auto-generated method stub
89
return new DefaultValue(d);
90     }
91
92     /* (non-Javadoc)
93      * @see org.apache.archimedes.EvaluationContext#evaluate(float)
94      */

95     public Evaluation evaluate(float f) {
96         // TODO Auto-generated method stub
97
return new DefaultValue(f);
98     }
99
100     /* (non-Javadoc)
101      * @see org.apache.archimedes.EvaluationContext#evaluate(int)
102      */

103     public Evaluation evaluate(int i) {
104         // TODO Auto-generated method stub
105
return new DefaultValue(i);
106     }
107
108     /* (non-Javadoc)
109      * @see org.apache.archimedes.EvaluationContext#evaluate(long)
110      */

111     public Evaluation evaluate(long l) {
112         // TODO Auto-generated method stub
113
return new DefaultValue(l);
114     }
115
116     /* (non-Javadoc)
117      * @see org.apache.archimedes.EvaluationContext#evaluate(short)
118      */

119     public Evaluation evaluate(short s) {
120         // TODO Auto-generated method stub
121
return new DefaultValue(s);
122     }
123
124     /* (non-Javadoc)
125      * @see org.apache.archimedes.EvaluationContext#evaluate(byte)
126      */

127     public Evaluation evaluate(byte b) {
128         // TODO Auto-generated method stub
129
return new DefaultValue(b);
130     }
131
132     public class DefaultValue extends Number JavaDoc implements Evaluation {
133
134         Number JavaDoc value;
135
136         /**
137          *
138          */

139         DefaultValue() {
140             super();
141             // TODO Auto-generated constructor stub
142
}
143
144         DefaultValue(Number JavaDoc n) {
145             value = n;
146         }
147                 
148         DefaultValue(double d) {
149             value = new Double JavaDoc(d);
150         }
151
152         DefaultValue(float f) {
153             value = new Float JavaDoc(f);
154         }
155
156         DefaultValue(int i) {
157             value = new Integer JavaDoc(i);
158         }
159
160         DefaultValue(long l) {
161             value = new Long JavaDoc(l);
162         }
163         
164         /* (non-Javadoc)
165          * @see org.apache.archimedes.Evaluation#evaluate(org.apache.archimedes.EvaluationContext)
166          */

167         public Evaluation evaluate(EvaluationContext context)
168             throws EvaluationException {
169             return this;
170         }
171
172         /* (non-Javadoc)
173          * @see java.lang.Number#intValue()
174          */

175         public int intValue() {
176             // TODO Auto-generated method stub
177
return value.intValue();
178         }
179
180         /* (non-Javadoc)
181          * @see java.lang.Number#longValue()
182          */

183         public long longValue() {
184             // TODO Auto-generated method stub
185
return value.longValue();
186         }
187
188         /* (non-Javadoc)
189          * @see java.lang.Number#floatValue()
190          */

191         public float floatValue() {
192             // TODO Auto-generated method stub
193
return value.floatValue();
194         }
195
196         /* (non-Javadoc)
197          * @see java.lang.Number#doubleValue()
198          */

199         public double doubleValue() {
200             // TODO Auto-generated method stub
201
return value.doubleValue();
202         }
203
204         /* (non-Javadoc)
205          * @see java.lang.Number#byteValue()
206          */

207         public byte byteValue() {
208             // TODO Auto-generated method stub
209
return value.byteValue();
210         }
211
212         /* (non-Javadoc)
213          * @see java.lang.Number#shortValue()
214          */

215         public short shortValue() {
216             // TODO Auto-generated method stub
217
return value.shortValue();
218         }
219
220     }
221 }
222
Popular Tags