KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > types > NumberDataValue


1 /*
2
3    Derby - Class org.apache.derby.iapi.types.NumberDataValue
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.types;
23
24 import org.apache.derby.iapi.error.StandardException;
25
26 public interface NumberDataValue extends DataValueDescriptor
27 {
28     /**
29      * The minimum scale when dividing Decimals
30      */

31     public static final int MIN_DECIMAL_DIVIDE_SCALE = 4;
32     public static final int MAX_DECIMAL_PRECISION_SCALE = 31;
33
34     /**
35      * The SQL + operator.
36      *
37      * @param addend1 One of the addends
38      * @param addend2 The other addend
39      * @param result The result of the previous call to this method, null
40      * if not called yet.
41      *
42      * @return The sum of the two addends
43      *
44      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
45      */

46     public NumberDataValue plus(NumberDataValue addend1,
47                                 NumberDataValue addend2,
48                                 NumberDataValue result)
49                             throws StandardException;
50
51     /**
52      * The SQL - operator.
53      *
54      * @param left The left operand
55      * @param right The right operand
56      * @param result The result of the previous call to this method, null
57      * if not called yet.
58      *
59      * @return left - right
60      *
61      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
62      */

63     public NumberDataValue minus(NumberDataValue left,
64                                  NumberDataValue right,
65                                 NumberDataValue result)
66                             throws StandardException;
67
68     /**
69      * The SQL * operator.
70      *
71      * @param left The left operand
72      * @param right The right operand
73      * @param result The result of the previous call to this method, null
74      * if not called yet.
75      *
76      * @return left * right
77      *
78      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
79      */

80     public NumberDataValue times(NumberDataValue left,
81                                 NumberDataValue right,
82                                 NumberDataValue result)
83                             throws StandardException;
84
85     /**
86      * The SQL / operator.
87      *
88      * @param dividend The numerator
89      * @param divisor The denominator
90      * @param result The result of the previous call to this method, null
91      * if not called yet.
92      *
93      * @return dividend / divisor
94      *
95      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
96      */

97     public NumberDataValue divide(NumberDataValue dividend,
98                                 NumberDataValue divisor,
99                                 NumberDataValue result)
100                             throws StandardException;
101
102     /**
103      * The SQL / operator.
104      *
105      * @param dividend The numerator
106      * @param divisor The denominator
107      * @param result The result of the previous call to this method, null
108      * if not called yet.
109      * @param scale The scale of the result, for decimal type. If pass
110      * in value < 0, can calculate it dynamically.
111      *
112      * @return dividend / divisor
113      *
114      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
115      */

116     public NumberDataValue divide(NumberDataValue dividend,
117                                 NumberDataValue divisor,
118                                 NumberDataValue result,
119                                 int scale)
120                             throws StandardException;
121
122
123     /**
124      * The SQL mod operator.
125      *
126      * @param dividend The numerator
127      * @param divisor The denominator
128      * @param result The result of the previous call to this method, null
129      * if not called yet.
130      *
131      * @return dividend / divisor
132      *
133      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
134      */

135     public NumberDataValue mod(NumberDataValue dividend,
136                                 NumberDataValue divisor,
137                                 NumberDataValue result)
138                             throws StandardException;
139
140     /**
141      * The SQL unary - operator. Negates this NumberDataValue.
142      *
143      * @param result The result of the previous call to this method, null
144      * if not called yet.
145      *
146      * @return - operand
147      *
148      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
149      */

150     public NumberDataValue minus(NumberDataValue result)
151                             throws StandardException;
152
153     /**
154      * The SQL ABSOLUTE operator. Absolute value of this NumberDataValue.
155      *
156      * @param result The result of the previous call to this method, null
157      * if not called yet.
158      *
159      * @exception StandardException Thrown on error, if result is non-null then its value will be unchanged.
160      */

161     public NumberDataValue absolute(NumberDataValue result)
162                             throws StandardException;
163
164     /**
165      * The SQL SQRT operator. Sqrt value of this NumberDataValue.
166      *
167      * @param result The result of the previous call to this method, null
168      * if not call yet.
169      *
170      * @exception StandardException Thrown on error (a negative number), if result is non-null then its value will be unchanged.
171      */

172     public NumberDataValue sqrt(NumberDataValue result)
173                             throws StandardException;
174
175     /**
176      * Set the value of this NumberDataValue to the given value.
177        This is only intended to be called when mapping values from
178        the Java space into the SQL space, e.g. parameters and return
179        types from procedures and functions. Each specific type is only
180        expected to handle the explicit type according the JDBC.
181        <UL>
182        <LI> SMALLINT from java.lang.Integer
183        <LI> INTEGER from java.lang.Integer
184        <LI> LONG from java.lang.Long
185        <LI> FLOAT from java.lang.Float
186        <LI> DOUBLE from java.lang.Double
187        <LI> DECIMAL from java.math.BigDecimal
188        </UL>
189      *
190      * @param theValue An Number containing the value to set this
191      * NumberDataValue to. Null means set the value
192      * to SQL null.
193      *
194      */

195     public void setValue(Number JavaDoc theValue) throws StandardException;
196
197     /**
198         Return the SQL precision of this specific DECIMAL value.
199         This does not match the return from BigDecimal.precision()
200         added in J2SE 5.0, which represents the precision of the unscaled value.
201         If the value does not represent a SQL DECIMAL then
202         the return is undefined.
203     */

204     public int getDecimalValuePrecision();
205
206     /**
207         Return the SQL scale of this specific DECIMAL value.
208         This does not match the return from BigDecimal.scale()
209         since in J2SE 5.0 onwards that can return negative scales.
210         If the value does not represent a SQL DECIMAL then
211         the return is undefined.
212     */

213     public int getDecimalValueScale();
214 }
215
216
217
218
219
220
221
222
223
224
Popular Tags