Annotation of OpenXM/src/OpenMath/ORG/openxm/tam/OXmessage.java, Revision 1.2
1.1 tam 1: /**
1.2 ! tam 2: * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OXmessage.java,v 1.1 2000/09/08 07:29:45 tam Exp $
1.1 tam 3: */
4: package ORG.openxm.tam;
5:
6: import java.io.*;
7:
8: /**
9: * OpenXM $B%a%C%;!<%8$rI=$9%/%i%9(B.
10: * $B%X%C%@$H%\%G%#$+$i@.$k(B.
11: */
12: public class OXmessage{
13: OXbody body = null;
14: int tag;
15: int serial;
16:
17: // OX message_tag
18: /**
19: * Stack Machine $B%3%^%s%I$G$"$k$3$H$rI=$9(B.
20: */
21: final public static int OX_COMMAND = 513;
22:
23: /**
24: * CMO $B7A<0$N%G!<%?$G$"$k$3$H$rI=$9(B.
25: */
26: final public static int OX_DATA = 514;
27:
28: final public static int OX_SYNC_BALL = 515;
29: final public static int OX_DATA_WITH_LENGTH = 521;
30: final public static int OX_DATA_OPENMATH_XML = 523;
31: final public static int OX_DATA_OPENMATH_BINARY = 524;
32: final public static int OX_DATA_MP = 525;
33: final public static int OX_PRIVATE = 0x7fff0000;
34:
35: public OXmessage(OpenXMstream is) throws IOException{
36: tag = is.readInt();
37: serial = is.readInt();
38: switch(tag){
39: case OX_COMMAND:
40: body = SM.receive(is);
41: break;
42:
43: case OX_DATA:
44: body = CMO.receive(is);
45: break;
46:
47: case OX_SYNC_BALL:
48: body = null;
49: break;
50: }
51: }
52:
53: public OXmessage(int serial,OXbody body){
54: this.serial = serial;
55: this.body = body;
56:
57: if(body == null){
58: this.tag = OX_SYNC_BALL;
59: }else if(body instanceof SM){
60: this.tag = OX_COMMAND;
61: }else if(body instanceof CMO){
62: this.tag = OX_DATA;
63: }else{
64: this.tag = OX_PRIVATE;
65: }
66: }
67:
68: public int getTag(){
69: return this.tag;
70: }
71:
72: public OXbody getBody(){
73: return this.body;
74: }
75:
1.2 ! tam 76: public void write(OpenXMstream os) throws IOException,MathcapViolation{
1.1 tam 77: os.writeInt(this.tag);
78: os.writeInt(this.serial);
79: body.write(os);
80: return;
81: }
82:
83: public String toOXexpression(){
84: //return "("+ this.toCMOexpressionByObject() +")";
85: return "";
86: }
87:
88: public String toString(){
89: return this.toOXexpression();
90: }
91: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>