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

Quick Search    Search Deep

Source code: org/apache/derby/iapi/types/NumberDataValue.java


1   /*
2   
3      Derby - Class org.apache.derby.iapi.types.NumberDataValue
4   
5      Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable.
6   
7      Licensed under the Apache License, Version 2.0 (the "License");
8      you may not use this file except in compliance with the License.
9      You may obtain a copy of the License at
10  
11        http://www.apache.org/licenses/LICENSE-2.0
12  
13     Unless required by applicable law or agreed to in writing, software
14     distributed under the License is distributed on an "AS IS" BASIS,
15     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16     See the License for the specific language governing permissions and
17     limitations under the License.
18  
19   */
20  
21  package org.apache.derby.iapi.types;
22  
23  import org.apache.derby.iapi.error.StandardException;
24  
25  public interface NumberDataValue extends DataValueDescriptor
26  {
27    /**
28     * The minimum scale when dividing Decimals
29     */
30    public static final int MIN_DECIMAL_DIVIDE_SCALE = 4;
31    public static final int MAX_DECIMAL_PRECISION_SCALE = 31;
32  
33    /**
34     * The SQL + operator.
35     *
36     * @param addend1  One of the addends
37     * @param addend2  The other addend
38     * @param result  The result of the previous call to this method, null
39     *          if not called yet.
40     *
41     * @return  The sum of the two addends
42     *
43     * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
44     */
45    public NumberDataValue plus(NumberDataValue addend1,
46                  NumberDataValue addend2,
47                  NumberDataValue result)
48                throws StandardException;
49  
50    /**
51     * The SQL - operator.
52     *
53     * @param left    The left operand
54     * @param right    The right operand
55     * @param result  The result of the previous call to this method, null
56     *          if not called yet.
57     *
58     * @return  left - right
59     *
60     * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
61     */
62    public NumberDataValue minus(NumberDataValue left,
63                   NumberDataValue right,
64                  NumberDataValue result)
65                throws StandardException;
66  
67    /**
68     * The SQL * operator.
69     *
70     * @param left    The left operand
71     * @param right    The right operand
72     * @param result  The result of the previous call to this method, null
73     *          if not called yet.
74     *
75     * @return  left * right
76     *
77     * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
78     */
79    public NumberDataValue times(NumberDataValue left,
80                  NumberDataValue right,
81                  NumberDataValue result)
82                throws StandardException;
83  
84    /**
85     * The SQL / operator.
86     *
87     * @param dividend    The numerator
88     * @param divisor    The denominator
89     * @param result    The result of the previous call to this method, null
90     *            if not called yet.
91     *
92     * @return  dividend / divisor
93     *
94     * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
95     */
96    public NumberDataValue divide(NumberDataValue dividend,
97                  NumberDataValue divisor,
98                  NumberDataValue result)
99                throws StandardException;
100 
101   /**
102    * The SQL / operator.
103    *
104    * @param dividend    The numerator
105    * @param divisor    The denominator
106    * @param result    The result of the previous call to this method, null
107    *            if not called yet.
108    * @param scale      The scale of the result, for decimal type.  If pass
109    *            in value < 0, can calculate it dynamically.
110    *
111    * @return  dividend / divisor
112    *
113    * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
114    */
115   public NumberDataValue divide(NumberDataValue dividend,
116                 NumberDataValue divisor,
117                 NumberDataValue result,
118                 int scale)
119               throws StandardException;
120 
121 
122   /**
123    * The SQL mod operator.
124    *
125    * @param dividend    The numerator
126    * @param divisor    The denominator
127    * @param result    The result of the previous call to this method, null
128    *            if not called yet.
129    *
130    * @return  dividend / divisor
131    *
132    * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
133    */
134   public NumberDataValue mod(NumberDataValue dividend,
135                 NumberDataValue divisor,
136                 NumberDataValue result)
137               throws StandardException;
138 
139   /**
140    * The SQL unary - operator.  Negates this NumberDataValue.
141    *
142    * @param result  The result of the previous call to this method, null
143    *          if not called yet.
144    *
145    * @return  - operand
146    *
147    * @exception StandardException    Thrown on error, if result is non-null then its value will be unchanged.
148    */
149   public NumberDataValue minus(NumberDataValue result)
150               throws StandardException;
151 
152     /**
153      * The SQL ABSOLUTE operator.  Absolute value of this NumberDataValue.
154      *
155      * @param result    The result of the previous call to this method, null
156      *                  if not called yet.
157      *
158      * @exception StandardException     Thrown on error, if result is non-null then its value will be unchanged.
159      */
160     public NumberDataValue absolute(NumberDataValue result)
161                             throws StandardException;
162 
163     /**
164      * The SQL SQRT operator.  Sqrt value of this NumberDataValue.
165      *
166      * @param result    The result of the previous call to this method, null
167      *                  if not call yet.
168      * 
169      * @exception StandardException     Thrown on error (a negative number), if result is non-null then its value will be unchanged.
170      */
171     public NumberDataValue sqrt(NumberDataValue result)
172                             throws StandardException;
173 
174   /**
175    * Set the value of this NumberDataValue to the given value.
176      This is only intended to be called when mapping values from
177      the Java space into the SQL space, e.g. parameters and return
178      types from procedures and functions. Each specific type is only
179      expected to handle the explicit type according the JDBC.
180      <UL>
181      <LI> SMALLINT from java.lang.Integer
182      <LI> INTEGER from java.lang.Integer
183      <LI> LONG from java.lang.Long
184      <LI> FLOAT from java.lang.Float
185      <LI> DOUBLE from java.lang.Double
186      <LI> DECIMAL from java.math.BigDecimal
187      </UL>
188    *
189    * @param theValue  An Number containing the value to set this
190    *          NumberDataValue to.  Null means set the value
191    *          to SQL null.
192    *
193    * @return  This NumberDataValue
194    *
195    */
196   public void setValue(Number theValue) throws StandardException;
197 
198   /**
199     Return the SQL precision of this specific DECIMAL value.
200     This does not match the return from BigDecimal.precision()
201     added in J2SE 5.0, which represents the precision of the unscaled value.
202     If the value does not represent a SQL DECIMAL then
203     the return is undefined.
204   */
205   public int getDecimalValuePrecision();
206 
207   /**
208     Return the SQL scale of this specific DECIMAL value.
209     This does not match the return from BigDecimal.scale()
210     since in J2SE 5.0 onwards that can return negative scales.
211     If the value does not represent a SQL DECIMAL then
212     the return is undefined.
213   */
214   public int getDecimalValueScale();
215 }
216 
217 
218 
219 
220 
221 
222 
223 
224