1   package mobisnap.mobile_trx;
2   
3   import java.math.*;
4   
5   /***
6    * Used to represent variables and constants internally
7    */
8   public class MSQLTNumber extends MSQLTVariable
9   {
10  	int precision, scale;
11  
12  	public MSQLTNumber( boolean constant, boolean notnull, int precision, int scale) {
13  		super( constant, notnull);
14  		this.precision = precision;
15  		this.scale = scale;
16  	}
17  	
18  	/***
19  	 * Sets the value of the given variable
20  	 */
21  	public void setValue( Object obj) throws Exception {
22  		if( constant && value != null)
23  			throw new mobisnap.MobisnapException( "Assigning value to constant");
24  		if( obj instanceof Integer)
25  			value = new BigDecimal( ((Integer)obj).toString());
26  		else if( obj instanceof Double)
27  			value = new BigDecimal( ((Double)obj).doubleValue());
28  		else if( obj instanceof Float)
29  			value = new BigDecimal( ((Float)obj).doubleValue());
30  		else if( obj instanceof BigDecimal)
31  			value = obj;
32  		else if( obj instanceof SQLNull && ! notnull)
33  			value = obj;
34  		else if( obj instanceof String)
35  			value = new Integer( (String)obj);
36  		else
37  			throw new mobisnap.MobisnapException( "Invalid assgnment to number : " + obj.getClass().getName());
38  	}
39  }
This page was automatically generated by Maven