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

File: [local] / OpenXM / src / OpenMath / ORG / openxm / tam / CMO_STRING.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: +3 -3 lines

I changed from OpenXMconnection to OpenXMstream.

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

import java.io.*;

/**
 * CMO $B7A<0$N(B STRING $B7?$rI=$7$^$9(B.
 */
final public class CMO_STRING extends CMO{
  private String str = null;

  /**
   * $B6uJ8;zNs$rFbMF$H$9$k(B STRING $B$r:n@.$7$^$9(B.
   */
  public CMO_STRING(){
    str = null;
  }

  /**
   * $BJ8;zNs(B a $B$rFbMF$H$9$k(B STRING $B$r:n@.$7$^$9(B.
   */
  public CMO_STRING(String a){
    str = a;
  }

  /**
   * $BFbMF$NJ8;zNs$rF@$^$9(B.
   */
  public String getString(){
    return str;
  }

  public int DISCRIMINATOR(){
    return CMO.STRING;
  }

  protected void sendByObject(OpenXMstream os) throws IOException{
    byte[] buf = str.getBytes();

    os.writeInt(buf.length);
    for(int i=0;i<buf.length;i++){
      os.writeByte(buf[i]);
    }
  }

  static protected CMO receive(OpenXMstream is) throws IOException{
    int len;
    byte[] buf=null;

    len=is.readInt();
    if(len==0){
      return new CMO_STRING("");
    }

    buf = new byte[len];
    for(int i=0;i<len;i++){
      buf[i] = is.readByte();
    }

    return new CMO_STRING(new String(buf));
  }

  protected String toCMOexpressionByObject(){
    return "CMO_STRING,"+ str.length() +","+ str;
  }
}