Annotation of OpenXM/src/OpenMath/ORG/openxm/tam/CMO.java, Revision 1.2
1.1 tam 1: /**
1.2 ! tam 2: * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/CMO.java,v 1.1 2000/09/09 11:54:08 tam Exp $
1.1 tam 3: */
4: package ORG.openxm.tam;
5:
6: import java.io.*;
7:
8: /**
9: * OpenXM $B%a%C%;!<%8$N(B CMO $B%*%V%8%'%/%H$rI=$9Cj>]%/%i%9(B.
10: */
11: abstract public class CMO extends OXbody{
12: final public static int LARGEID = 0x7f000000;
13: final public static int ERROR = ( LARGEID +1 );
14: final public static int ERROR2 = ( LARGEID +2 );
15: final public static int NULL = 1;
16: final public static int INT32 = 2;
17: final public static int DATUM = 3;
18: final public static int STRING = 4;
19: final public static int MATHCAP = 5;
20: final public static int LIST = 17;
21:
22: final public static int MONOMIAL32 = 19;
23: final public static int ZZ = 20;
24: final public static int QQ = 21;
25: final public static int ZERO = 22;
26: final public static int DMS = 23;
27: final public static int DMS_GENERIC = 24;
28: final public static int DMS_OF_N_VARIABLES = 25;
29: final public static int RING_BY_NAME = 26;
30:
31: final public static int RECURSIVE_POLYNOMIAL = 27;
32: final public static int DISTRIBUTED_POLYNOMIAL = 31;
33: final public static int POLYNOMIAL_IN_ONE_VARIABLE = 33;
34:
35: final public static int RATIONAL = 34;
36:
37: final public static int CMO_64BIT_MACHINE_DOUBLE = 40;
38: final public static int ARRAY_OF_64BIT_MACHINE_DOUBLE = 41;
39: final public static int CMO_128BIT_MACHINE_DOUBLE = 42;
40: final public static int ARRAY_OF_128BIT_MACHINE_DOUBLE = 43;
41:
42: final public static int BIGFLOAT = 50;
43: final public static int IEEE_DOUBLE_FLOAT = 51;
44:
45: final public static int INDETERMINATE = 60;
46: final public static int TREE = 61;
47: final public static int LAMBDA = 62;
48:
49: final public static int PRIVATE = 0x7fff0000;
50:
51: abstract protected int DISCRIMINATOR();
52:
53: public int getDISCRIMINATOR(){
54: return this.DISCRIMINATOR();
55: }
56:
1.2 ! tam 57: abstract protected void sendByObject(OpenXMstream stream)
1.1 tam 58: throws IOException,MathcapViolation;
59:
1.2 ! tam 60: final public void write(OpenXMstream os)
1.1 tam 61: throws IOException,MathcapViolation{
62: CMO[] mathcap = os.getMathcap(OXmessage.OX_DATA);
63:
64: if(mathcap != null){ // check mathcap
65: CMO[] datacap = ((CMO_LIST)mathcap[1]).getElements();
66: int i=0;
67:
68: for(;i<datacap.length;i++){
69: if(((CMO_INT32)datacap[i]).intValue() == this.DISCRIMINATOR()){
70: break;
71: }
72: }
73: if(i>=datacap.length){
74: throw new MathcapViolation(this.toCMOexpression());
75: }
76: }
77: os.writeInt(this.DISCRIMINATOR());
78: this.sendByObject(os);
79: }
80:
1.2 ! tam 81: static protected CMO receive(OpenXMstream is) throws IOException{
1.1 tam 82: int a = is.readInt();
83:
84: switch(a){
85: case CMO.ERROR2:
86: return CMO_ERROR2.receive(is);
87:
88: case CMO.NULL:
89: return CMO_NULL.receive(is);
90:
91: case CMO.INT32:
92: return CMO_INT32.receive(is);
93:
94: case CMO.DATUM:
95: return CMO_DATUM.receive(is);
96:
97: case CMO.STRING:
98: return CMO_STRING.receive(is);
99:
100: case CMO.MATHCAP:
101: return CMO_MATHCAP.receive(is);
102:
103: case CMO.LIST:
104: return CMO_LIST.receive(is);
105:
106: case CMO.MONOMIAL32:
107: return CMO_MONOMIAL32.receive(is);
108:
109: case CMO.ZZ:
110: return CMO_ZZ.receive(is);
111:
112: case CMO.QQ:
113: return CMO_QQ.receive(is);
114:
115: case CMO.ZERO:
116: return CMO_ZERO.receive(is);
117:
118: case CMO.DMS:
119: return CMO_DMS.receive(is);
120:
121: case CMO.DMS_GENERIC:
122: return CMO_DMS_GENERIC.receive(is);
123:
124: case CMO.RECURSIVE_POLYNOMIAL:
125: return CMO_RECURSIVE_POLYNOMIAL.receive(is);
126:
127: case CMO.DISTRIBUTED_POLYNOMIAL:
128: return CMO_DISTRIBUTED_POLYNOMIAL.receive(is);
129:
130: case CMO.POLYNOMIAL_IN_ONE_VARIABLE:
131: return CMO_POLYNOMIAL_IN_ONE_VARIABLE.receive(is);
132:
133: case CMO.RATIONAL:
134: return CMO_RATIONAL.receive(is);
135:
136: case CMO.BIGFLOAT:
137: return CMO_BIGFLOAT.receive(is);
138:
139: case CMO.INDETERMINATE:
140: return CMO_INDETERMINATE.receive(is);
141:
142: case CMO.TREE:
143: return CMO_TREE.receive(is);
144:
145: default:
146: System.err.println("unknown CMO type("+ a +")");
147: }
148: return null;
149: }
150:
151: abstract protected String toCMOexpressionByObject();
152:
153: /**
154: * $B%*%V%8%'%/%H$r(B CMO expression $B$KJQ49$7$^$9(B.
155: */
156: final public String toCMOexpression(){
157: return "("+ this.toCMOexpressionByObject() +")";
158: }
159:
160: /**
161: * $B%*%V%8%'%/%H$r(B OX expression $B$KJQ49$7$^$9(B.
162: * $B8=:_$O(B CMO expression $B$X$HJQ49$7$^$9(B.
163: */
164: final public String toOXexpression(){
165: return toCMOexpression();
166: }
167:
168: final public String toString(){
169: return this.toCMOexpression();
170: }
171: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>