[BACK]Return to OXmessage.java CVS log [TXT][DIR] Up to [local] / OpenXM / src / OpenMath / ORG / openxm / tam

File: [local] / OpenXM / src / OpenMath / ORG / openxm / tam / OXmessage.java (download)

Revision 1.2, Wed Sep 13 06:32:43 2000 UTC (23 years, 9 months ago) by tam
Branch: MAIN
CVS Tags: maekawa-ipv6, R_1_3_1-2, RELEASE_1_3_1_13b, RELEASE_1_2_3_12, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, RELEASE_1_1_3, KNOPPIX_2006, HEAD, DEB_REL_1_2_3-9
Changes since 1.1: +2 -2 lines

I changed from OpenXMconnection to OpenXMstream.

/**
 * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OXmessage.java,v 1.2 2000/09/13 06:32:43 tam Exp $
 */
package ORG.openxm.tam;

import java.io.*;

/**
 * OpenXM $B%a%C%;!<%8$rI=$9%/%i%9(B.
 * $B%X%C%@$H%\%G%#$+$i@.$k(B.
 */
public class OXmessage{
  OXbody body = null;
  int tag;
  int serial;

  // OX message_tag
  /**
   * Stack Machine $B%3%^%s%I$G$"$k$3$H$rI=$9(B.
   */
  final public static int OX_COMMAND                  = 513;

  /**
   * CMO $B7A<0$N%G!<%?$G$"$k$3$H$rI=$9(B.
   */
  final public static int OX_DATA                     = 514;

  final public static int OX_SYNC_BALL                = 515;
  final public static int OX_DATA_WITH_LENGTH         = 521;
  final public static int OX_DATA_OPENMATH_XML        = 523;
  final public static int OX_DATA_OPENMATH_BINARY     = 524;
  final public static int OX_DATA_MP                  = 525;
  final public static int OX_PRIVATE                  = 0x7fff0000;

  public OXmessage(OpenXMstream is) throws IOException{
    tag    = is.readInt();
    serial = is.readInt();
    switch(tag){
    case OX_COMMAND:
      body = SM.receive(is);
      break;

    case OX_DATA:
      body = CMO.receive(is);
      break;

    case OX_SYNC_BALL:
      body = null;
      break;
    }
  }

  public OXmessage(int serial,OXbody body){
    this.serial = serial;
    this.body = body;

    if(body == null){
      this.tag = OX_SYNC_BALL;
    }else if(body instanceof SM){
      this.tag = OX_COMMAND;
    }else if(body instanceof CMO){
      this.tag = OX_DATA;
    }else{
      this.tag = OX_PRIVATE;
    }
  }

  public int getTag(){
    return this.tag;
  }

  public OXbody getBody(){
    return this.body;
  }

  public void write(OpenXMstream os) throws IOException,MathcapViolation{
    os.writeInt(this.tag);
    os.writeInt(this.serial);
    body.write(os);
    return;
  }

  public String toOXexpression(){
    //return "("+ this.toCMOexpressionByObject() +")";
    return "";
  }

  public String toString(){
    return this.toOXexpression();
  }
}