1 package org.omg.CORBA; 2 3 7 8 public class FixedHolder 9 implements org.omg.CORBA.portable.Streamable 10 { 11 public java.math.BigDecimal value; 12 13 public FixedHolder(){} 14 15 public FixedHolder(java.math.BigDecimal o) 16 { 17 value = o; 18 } 19 20 public TypeCode _type() 21 { 22 String s = value.toString(); 23 short digits = 0; 24 short scale = 0; 25 26 if ( ! s.startsWith("0.") ) 27 { 28 for( int i = 0; i < s.length(); i++ ) 29 { 30 if ( s.charAt(i) == '.' ) 31 { 32 break; 33 } 34 digits++; 35 } 36 } 37 38 int decimal = s.indexOf('.'); 39 if ( decimal != -1 ) 40 { 41 s = s.substring( decimal + 1 ); 42 for( int i = 0; i < s.length(); i++ ) 43 { 44 digits++; 45 scale++; 46 } 47 } 48 49 return ORB.init().create_fixed_tc( digits, scale ); 50 } 51 52 public void _read(org.omg.CORBA.portable.InputStream in) 53 { 54 value = in.read_fixed(); 55 } 56 57 public void _write(org.omg.CORBA.portable.OutputStream out) 58 { 59 out.write_fixed(value); 60 } 61 62 } 63 | Popular Tags |