01: package org.omg.CORBA;
02:
03: /**
04: * Holder class for fixed point types.
05: *
06: */
07:
08: public class FixedHolder implements org.omg.CORBA.portable.Streamable {
09: public java.math.BigDecimal value;
10:
11: public FixedHolder() {
12: }
13:
14: public FixedHolder(java.math.BigDecimal o) {
15: value = o;
16: }
17:
18: public TypeCode _type() {
19: String s = value.toString();
20: short digits = 0;
21: short scale = 0;
22:
23: if (!s.startsWith("0.")) {
24: for (int i = 0; i < s.length(); i++) {
25: if (s.charAt(i) == '.') {
26: break;
27: }
28: digits++;
29: }
30: }
31:
32: int decimal = s.indexOf('.');
33: if (decimal != -1) {
34: s = s.substring(decimal + 1);
35: for (int i = 0; i < s.length(); i++) {
36: digits++;
37: scale++;
38: }
39: }
40:
41: return ORB.init().create_fixed_tc(digits, scale);
42: }
43:
44: public void _read(org.omg.CORBA.portable.InputStream in) {
45: value = in.read_fixed();
46: }
47:
48: public void _write(org.omg.CORBA.portable.OutputStream out) {
49: out.write_fixed(value);
50: }
51:
52: }
|