コード例 #1
0
 /** Writes the example set into the given output stream. */
 public void writeSupportVectors(ObjectOutputStream out) throws IOException {
   out.writeInt(getNumberOfSupportVectors());
   out.writeDouble(b);
   out.writeInt(dim);
   if ((meanVarianceMap == null) || (meanVarianceMap.size() == 0)) {
     out.writeUTF("noscale");
   } else {
     out.writeUTF("scale");
     out.writeInt(meanVarianceMap.size());
     Iterator i = meanVarianceMap.keySet().iterator();
     while (i.hasNext()) {
       Integer index = (Integer) i.next();
       MeanVariance meanVariance = meanVarianceMap.get(index);
       out.writeInt(index.intValue());
       out.writeDouble(meanVariance.getMean());
       out.writeDouble(meanVariance.getVariance());
     }
   }
   for (int e = 0; e < train_size; e++) {
     if (alphas[e] != 0.0d) {
       out.writeInt(atts[e].length);
       for (int a = 0; a < atts[e].length; a++) {
         out.writeInt(index[e][a]);
         out.writeDouble(atts[e][a]);
       }
       out.writeDouble(alphas[e]);
       out.writeDouble(ys[e]);
     }
   }
 }
コード例 #2
0
ファイル: WinstoneControl.java プロジェクト: ties/winstone
  /**
   * Execute a call for the specified command.
   *
   * @param host
   * @param port
   * @param command
   * @param extra
   */
  private void execute(
      final String host, final String port, final Command command, final String extra) {
    Socket socket = null;
    try {
      socket = new Socket(host, Integer.parseInt(port));
      socket.setSoTimeout(WinstoneControl.TIMEOUT);
      final OutputStream out = socket.getOutputStream();
      out.write(command.getCode());
      if (extra != null) {
        final ObjectOutputStream objOut = new ObjectOutputStream(out);
        objOut.writeUTF(host);
        objOut.writeUTF(extra);
        objOut.close();
      }
      logger.info("Successfully sent server shutdown command to {}:{}", host, port);

    } catch (final NumberFormatException e) {
      logger.error("execute: " + command, e);
    } catch (final UnknownHostException e) {
      logger.error("execute: " + command, e);
    } catch (final IOException e) {
      logger.error("execute: " + command, e);
    } finally {
      if (socket != null) {
        try {
          socket.close();
        } catch (final IOException e) {
        }
      }
    }
  }
コード例 #3
0
 /**
  * Custom serialization hook used during Session serialization.
  *
  * @param oos The stream to which to write the factory
  * @throws IOException Indicates problems writing out the serial data stream
  */
 void serialize(ObjectOutputStream oos) throws IOException {
   oos.writeUTF(uuid);
   oos.writeBoolean(name != null);
   if (name != null) {
     oos.writeUTF(name);
   }
 }
コード例 #4
0
ファイル: OutputMarshaller.java プロジェクト: Orlandos/drools
  public static void writeWorkItem(MarshallerWriteContext context, WorkItem workItem)
      throws IOException {
    ObjectOutputStream stream = context.stream;
    stream.writeLong(workItem.getId());
    stream.writeLong(workItem.getProcessInstanceId());
    stream.writeUTF(workItem.getName());
    stream.writeInt(workItem.getState());

    // Work Item Parameters
    Map<String, Object> parameters = workItem.getParameters();
    Collection<Object> notNullValues = new ArrayList<Object>();
    for (Object value : parameters.values()) {
      if (value != null) {
        notNullValues.add(value);
      }
    }

    stream.writeInt(notNullValues.size());
    for (String key : parameters.keySet()) {
      Object object = parameters.get(key);
      if (object != null) {
        stream.writeUTF(key);

        ObjectMarshallingStrategy strategy =
            context.objectMarshallingStrategyStore.getStrategyObject(object);
        String strategyClassName = strategy.getClass().getName();
        stream.writeInt(-2); // backwards compatibility
        stream.writeUTF(strategyClassName);
        if (strategy.accept(object)) {
          strategy.write(stream, object);
        }
      }
    }
  }
コード例 #5
0
ファイル: OutputMarshaller.java プロジェクト: Orlandos/drools
  public static void writeActivation(
      MarshallerWriteContext context,
      LeftTuple leftTuple,
      AgendaItem agendaItem,
      RuleTerminalNode ruleTerminalNode)
      throws IOException {
    ObjectOutputStream stream = context.stream;

    stream.writeLong(agendaItem.getActivationNumber());

    stream.writeInt(context.terminalTupleMap.get(leftTuple));

    stream.writeInt(agendaItem.getSalience());

    Rule rule = agendaItem.getRule();
    stream.writeUTF(rule.getPackage());
    stream.writeUTF(rule.getName());

    // context.out.println( "Rule " + rule.getPackage() + "." + rule.getName() );

    // context.out.println( "AgendaItem long:" +
    // agendaItem.getPropagationContext().getPropagationNumber() );
    stream.writeLong(agendaItem.getPropagationContext().getPropagationNumber());

    if (agendaItem.getActivationGroupNode() != null) {
      stream.writeBoolean(true);
      // context.out.println( "ActivationGroup bool:" + true );
      stream.writeUTF(agendaItem.getActivationGroupNode().getActivationGroup().getName());
      // context.out.println( "ActivationGroup string:" +
      // agendaItem.getActivationGroupNode().getActivationGroup().getName() );
    } else {
      stream.writeBoolean(false);
      // context.out.println( "ActivationGroup bool:" + false );
    }

    stream.writeBoolean(agendaItem.isActivated());
    // context.out.println( "AgendaItem bool:" + agendaItem.isActivated() );

    if (agendaItem.getFactHandle() != null) {
      stream.writeBoolean(true);
      stream.writeInt(agendaItem.getFactHandle().getId());
    } else {
      stream.writeBoolean(false);
    }

    org.drools.core.util.LinkedList list = agendaItem.getLogicalDependencies();
    if (list != null && !list.isEmpty()) {
      for (LogicalDependency node = (LogicalDependency) list.getFirst();
          node != null;
          node = (LogicalDependency) node.getNext()) {
        stream.writeShort(PersisterEnums.LOGICAL_DEPENDENCY);
        stream.writeInt(((InternalFactHandle) node.getJustified()).getId());
        // context.out.println( "Logical Depenency : int " + ((InternalFactHandle)
        // node.getFactHandle()).getId() );
      }
    }
    stream.writeShort(PersisterEnums.END);
  }
コード例 #6
0
  public static void main(String[] args) throws IOException, ClassNotFoundException {

    FileOutputStream fout = null;
    ObjectOutputStream out = null;

    FileInputStream fin = null;
    ObjectInputStream in = null;

    SerializeClass obj = null;
    SerializeClass s = null;

    // Serialization for is-a relationship Starts
    obj = new SerializeClass(1, "Dushyant");

    // Serialization
    fout = new FileOutputStream("file.txt");
    out = new ObjectOutputStream(fout);

    out.writeObject(obj);
    out.flush();
    fout.close();
    out.close();

    // De-Serialization
    fin = new FileInputStream("file.txt");
    in = new ObjectInputStream(fin);
    s = (SerializeClass) in.readObject();
    System.out.println(s.getId() + " " + s.getName());

    fin.close();
    in.close();

    // Serialization for is-a relationship Ends

    // Serialization for has-a relationship Starts
    obj = new SerializeClass(1, "Dushyant");
    obj.setCityAndState(new CityState("Gurgaon", "Haryana"));
    fout = new FileOutputStream("file.txt");
    out = new ObjectOutputStream(fout);
    out.writeUTF(obj.getName()); // 1
    out.writeUTF(obj.getCityAndState().getCityName()); // 1
    out.writeUTF(obj.getCityAndState().getStateName()); // 1
    out.flush();
    out.close();

    fin = new FileInputStream("file.txt");
    in = new ObjectInputStream(fin);
    s = new SerializeClass();
    s.setCityAndState(new CityState());
    s.setName(in.readUTF()); // 2
    s.getCityAndState().setCityName(in.readUTF()); // 2
    s.getCityAndState().setStateName(in.readUTF()); // 2

    System.out.println(s);
    // Serialization for has-a relationship Ends
  }
コード例 #7
0
ファイル: FeedItem.java プロジェクト: yieryi/rss
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeUTF(m_title);
   out.writeUTF(m_imageLink);
   out.writeUTF(m_imageName);
   out.writeUTF(m_urlTrimmed);
   out.writeUTF(m_url);
   out.writeUTF(m_content);
   out.writeObject(m_desLines);
   out.writeLong(m_time);
 }
コード例 #8
0
ファイル: OutputMarshaller.java プロジェクト: Orlandos/drools
  private static void writeFactHandle(
      MarshallerWriteContext context,
      ObjectOutputStream stream,
      ObjectMarshallingStrategyStore objectMarshallingStrategyStore,
      int type,
      InternalFactHandle handle)
      throws IOException {
    stream.writeInt(type);
    stream.writeInt(handle.getId());
    stream.writeLong(handle.getRecency());

    if (type == 2) {
      // is event
      EventFactHandle efh = (EventFactHandle) handle;
      stream.writeLong(efh.getStartTimestamp());
      stream.writeLong(efh.getDuration());
      stream.writeBoolean(efh.isExpired());
      stream.writeLong(efh.getActivationsCount());
    }

    // context.out.println( "Object : int:" + handle.getId() + " long:" + handle.getRecency() );
    // context.out.println( handle.getObject() );

    Object object = handle.getObject();

    // Old versions wrote -1 and tested >= 0 to see if there was a strategy available
    // Now, we write -2 to indicate that we write the strategy class name to the stream
    stream.writeInt(-2);
    if (object != null) {
      ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(object);

      String strategyClassName = strategy.getClass().getName();
      stream.writeUTF(strategyClassName);

      strategy.write(stream, object);
    } else {
      stream.writeUTF("");
    }

    if (handle.getEntryPoint() instanceof InternalWorkingMemoryEntryPoint) {
      String entryPoint =
          ((InternalWorkingMemoryEntryPoint) handle.getEntryPoint())
              .getEntryPoint()
              .getEntryPointId();
      if (entryPoint != null && !entryPoint.equals("")) {
        stream.writeBoolean(true);
        stream.writeUTF(entryPoint);
      } else {
        stream.writeBoolean(false);
      }
    } else {
      stream.writeBoolean(false);
    }
  }
コード例 #9
0
ファイル: Zzzxarrivaldocu.java プロジェクト: yqe/demo
 /**
  * 建立中转中心到达单
  *
  * @param EarnedPO earnpo;
  * @return
  * @exception @author zxc
  */
 public boolean BuildZzzxarrivalDocu(ZzzxArrivalDocuPO zzzxpo) {
   boolean IsOk = false;
   try {
     oos.writeUTF("Transit");
     oos.writeUTF("TransitReceive");
     oos.writeObject(zzzxpo);
     IsOk = (boolean) ois.readObject();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return IsOk;
 }
コード例 #10
0
 private static void a_(Map map, ObjectOutputStream objectOutputStream) {
   if (map != null) {
     objectOutputStream.writeInt(map.size());
     Iterator it = map.entrySet().iterator();
     while (it.hasNext()) {
       Entry entry = (Entry) it.next();
       objectOutputStream.writeUTF((String) entry.getKey());
       objectOutputStream.writeUTF((String) entry.getValue());
     }
   } else {
     objectOutputStream.writeInt(0);
   }
 }
コード例 #11
0
ファイル: Personnel.java プロジェクト: bendito/TDprog
  public void ecrire(String destination) {
    try (ObjectOutputStream out =
        new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(destination)))) {

      out.writeUTF(this.nom);
      out.writeUTF(this.prenom);
      out.writeObject(this.birth);
      out.writeUTF(this.fonction);
      out.writeInt(this.telephone);

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #12
0
  @Override
  public void run() {
    try {
      ObjectInputStream in = new ObjectInputStream(sock.getInputStream());
      ObjectOutputStream out = new ObjectOutputStream(sock.getOutputStream());

      Connection con = DriverManager.getConnection(Server.getServer().getDbUrl());
      Statement stmt = con.createStatement();

      Message msg = (Message) in.readObject();
      String data = msg.getMessageText();

      ResultSet rs;

      switch (msg.getDataType()) {
        case IDNumber:
          rs = stmt.executeQuery("SELECT U.uid FROM User U WHERE U.username = '******'");
          out.writeInt(rs.getInt("U.uid"));
          break;

        case UserName:
          rs = stmt.executeQuery("SELECT U.username FROM User U WHERE U.uid = '" + data + "'");
          out.writeUTF(rs.getString("U.username"));
          break;

        case IPAddress:
          rs =
              stmt.executeQuery(
                  "SELECT L.ipaddress FROM Login L, User U WHERE U.uid = L.uid AND L.success = true AND U.username = '******' ORDER BY L.time DESC");
          out.writeUTF(rs.getString("L.ipaddress"));
          break;
      }

    } catch (IOException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    } catch (SQLException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    } catch (ClassNotFoundException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }
コード例 #13
0
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeUTF(label);
   out.writeUTF(uri != null ? uri.toString() : "null");
   if (thumb != null) {
     FileOutputStream thumbOut =
         HistoryItemDao.ctx.openFileOutput(getThumbFilename(), Context.MODE_PRIVATE);
     try {
       thumb.compress(CompressFormat.PNG, 100, thumbOut);
     } finally {
       thumbOut.close();
     }
   } else {
     Log.e(TAG, "thumb is null !");
   }
 }
コード例 #14
0
ファイル: MakeEngine.java プロジェクト: brianhks/tablesaw
  // ---------------------------------------------------------------------------
  private void writeCache() {
    try {
      Debug.print("Writing cache");
      FileOutputStream fos = new FileOutputStream(m_cacheFile);
      ObjectOutputStream oos = new ObjectOutputStream(fos);

      oos.writeObject(m_depCache);

      oos.writeInt(m_newModificationCache.size());

      Iterator<String> it = m_newModificationCache.keySet().iterator();

      while (it.hasNext()) {
        String key = it.next();

        oos.writeUTF(key);
        oos.writeLong(m_newModificationCache.get(key));
      }

      oos.close();
    } catch (Exception e) {
      Debug.print(e.getMessage());
      StringWriter sw = new StringWriter();
      e.printStackTrace(new PrintWriter(sw));
      Debug.print(sw.toString());
    }
  }
コード例 #15
0
 private void writeObject(java.io.ObjectOutputStream s) {
   try {
     String str = org.omg.CORBA.ORB.init().object_to_string(this);
     s.writeUTF(str);
   } catch (java.io.IOException e) {
   }
 }
コード例 #16
0
 public static void main(String[] args) {
   Random r = new Random();
   int n;
   if (args.length == 1) {
     n = Integer.parseInt(args[0]);
   } else {
     n = r.nextInt(10000) + 1;
   }
   try {
     OutputStream ofs = new FileOutputStream("scores.txt");
     ObjectOutputStream oos = new ObjectOutputStream(ofs);
     for (int i = 0; i < n; ++i) {
       int testNum = r.nextInt(21);
       String name = randString(r.nextInt(6) + 5);
       while (testNum-- > 0) {
         oos.writeUTF(name);
         oos.writeInt(r.nextInt(101));
       }
     }
     ofs.close();
   } catch (Exception e) {
     System.out.println("Error creating scores.txt: " + e.getMessage());
   }
   try {
     InputStream ifs = new FileInputStream("scores.txt");
     String name = findStudentWithTopThreeAverageScores(ifs);
     System.out.println("top student is " + name);
     ifs.close();
   } catch (Exception e) {
     System.out.println("Error reading scores.txt: " + e.getMessage());
   }
 }
コード例 #17
0
ファイル: SplitState.java プロジェクト: BrunoMCBraga/CMOV
 private void writeObject(ObjectOutputStream stream) throws IOException {
   stream.writeChar(playerId);
   stream.writeObject(event);
   stream.writeObject(splitAction);
   stream.writeUTF(newOwner);
   stream.writeObject(leavers);
 }
コード例 #18
0
 /**
  * Serializes this object to the specified output stream for JDK Serialization.
  *
  * @param out output stream used for Object serialization.
  * @throws IOException if any of this object's fields cannot be written to the stream.
  * @since 1.0
  */
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.defaultWriteObject();
   short alteredFieldsBitMask = getAlteredFieldsBitMask();
   out.writeShort(alteredFieldsBitMask);
   if (id != null) {
     out.writeObject(id);
   }
   if (startTimestamp != null) {
     out.writeObject(startTimestamp);
   }
   if (stopTimestamp != null) {
     out.writeObject(stopTimestamp);
   }
   if (lastAccessTime != null) {
     out.writeObject(lastAccessTime);
   }
   if (timeout != 0l) {
     out.writeLong(timeout);
   }
   if (expired) {
     out.writeBoolean(expired);
   }
   if (host != null) {
     out.writeUTF(host);
   }
   if (!CollectionUtils.isEmpty(attributes)) {
     out.writeObject(attributes);
   }
 }
コード例 #19
0
  /**
   * java.io.ObjectOutputStream#writeInt(int)
   * java.io.ObjectOutputStream#writeObject(java.lang.Object)
   * java.io.ObjectOutputStream#writeUTF(java.lang.String)
   */
  public void testMixPrimitivesAndObjects() throws Exception {
    int i = 7;
    String s1 = "string 1";
    String s2 = "string 2";
    byte[] bytes = {1, 2, 3};
    try {
      oos = new ObjectOutputStream(bao = new ByteArrayOutputStream());
      oos.writeInt(i);
      oos.writeObject(s1);
      oos.writeUTF(s2);
      oos.writeObject(bytes);
      oos.close();

      ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));

      int j = ois.readInt();
      assertTrue("Wrong int :" + j, i == j);

      String l1 = (String) ois.readObject();
      assertTrue("Wrong obj String :" + l1, s1.equals(l1));

      String l2 = ois.readUTF();
      assertTrue("Wrong UTF String :" + l2, s2.equals(l2));

      byte[] bytes2 = (byte[]) ois.readObject();
      assertTrue("Wrong byte[]", Arrays.equals(bytes, bytes2));
    } finally {
      try {
        if (oos != null) oos.close();
        if (ois != null) ois.close();
      } catch (IOException e) {
      }
    }
  }
コード例 #20
0
 /** java.io.ObjectOutputStream#writeUTF(java.lang.String) */
 public void test_writeUTFLjava_lang_String() throws Exception {
   // Test for method void
   // java.io.ObjectOutputStream.writeUTF(java.lang.String)
   oos.writeUTF("HelloWorld");
   oos.close();
   ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
   assertEquals("Wrote incorrect UTF value", "HelloWorld", ois.readUTF());
 }
コード例 #21
0
 // Special serializer: output XML as serialization
 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   write(baos);
   String str = baos.toString();
   ;
   // System.out.println("str='"+str+"'");
   out.writeUTF(str);
 }
コード例 #22
0
 @Override
 public void execute(ObjectInputStream input, ObjectOutputStream output) {
   try {
     output.writeUTF("Connected to server");
     output.flush();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #23
0
 private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
   String[] args = null;
   java.util.Properties props = null;
   org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);
   try {
     String str = orb.object_to_string(this);
     s.writeUTF(str);
   } finally {
     orb.destroy();
   }
 }
コード例 #24
0
ファイル: GameClient.java プロジェクト: jkoppel/cardtable
  // Initializes a GameClinet over port to the given host,
  // requesting to join using the given handle
  private GameClient(String host, int port, String handle) throws IOException {
    conn = new Socket(host, port);
    oos = new ObjectOutputStream(conn.getOutputStream());
    oos.flush();
    ois = new ObjectInputStream(conn.getInputStream());

    oos.writeUTF(handle);
    oos.flush();

    runReceiveThread();
  }
コード例 #25
0
  private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeUTF(localPath.getName());
    out.writeLong(localPath.length());

    byte[] xfer = new byte[4096];
    FileInputStream fis = new FileInputStream(localPath);
    try {
      for (int read = fis.read(xfer); read >= 0; read = fis.read(xfer)) out.write(xfer, 0, read);
    } finally {
      fis.close();
    }
  }
コード例 #26
0
 public boolean a_(OutputStream outputStream) {
   boolean z = true;
   boolean z2 = false;
   try {
     ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
     objectOutputStream.writeByte(GoogleScorer.CLIENT_PLUS);
     objectOutputStream.writeUTF(this.b);
     objectOutputStream.writeUTF(this.c == null ? AdTrackerConstants.BLANK : this.c);
     objectOutputStream.writeLong(this.d);
     objectOutputStream.writeLong(this.e);
     objectOutputStream.writeLong(this.f);
     a(this.g, objectOutputStream);
     objectOutputStream.flush();
     return z;
   } catch (IOException e) {
     String str = "%s";
     Object[] objArr = new Object[z];
     objArr[z2] = e.toString();
     t.b(str, objArr);
     return z2;
   }
 }
コード例 #27
0
ファイル: TCPChannel.java プロジェクト: diegopasc/Fantapazz
 public void send(Message message) {
   try {
     String messageValue = MessageSerializer.writeMessage(message);
     if (ConfigSettings.instance().isDumpMessages()) {
       System.out.println("Send: " + messageValue);
     }
     out.writeUTF(messageValue);
     out.flush();
     out.reset();
   } catch (IOException ex) {
     ex.printStackTrace();
     receiver.interrupt();
   }
 }
コード例 #28
0
ファイル: UninstallDataWriter.java プロジェクト: Jahia/izpack
  private void writeScriptFiles(UninstallData udata, JarOutputStream outJar) throws IOException {

    ArrayList<String> unInstallScripts = udata.getUninstallScripts();
    ObjectOutputStream rootStream;
    int idx = 0;
    for (String unInstallScript : unInstallScripts) {
      outJar.putNextEntry(new JarEntry(UninstallData.ROOTSCRIPT + Integer.toString(idx)));
      rootStream = new ObjectOutputStream(outJar);
      rootStream.writeUTF(unInstallScript);
      rootStream.flush();
      outJar.closeEntry();
      idx++;
    }
  }
コード例 #29
0
  /** save To save members' information into a binary file */
  public void save() {
    ObjectOutputStream oout = null;
    Member tm;
    ArrayList<String> booksBorrowed = new ArrayList<String>();
    try {
      oout = new ObjectOutputStream(new FileOutputStream("members1.dat"));
      // Loop through memberMap and process each entry
      // Structure for writing
      // __________________________________________________________
      // |String|String|String|Boolean or Double|ArrayList<String>|
      // ----------------------------------------------------------

      for (Map.Entry<String, Member> entry : memberMap.entrySet()) {
        tm = entry.getValue();
        oout.writeUTF(tm.getMemberID());
        oout.writeUTF(tm.getName());
        oout.writeUTF(tm.getPhoneNumber());
        if (tm instanceof Staff) {
          oout.writeBoolean(((Staff) tm).isBookOverdue());
        } else {
          oout.writeDouble(((Student) tm).getFinesOwing());
        }
        for (LibraryBook b : tm.getBooklist()) {
          booksBorrowed.add(b.getBookNumber());
        }
        oout.writeObject(booksBorrowed);
      }
    } catch (Exception e) {
      Log.e(e.getMessage());
    } finally {
      try {
        oout.close();
      } catch (IOException e) {
        Log.e(e.getMessage());
      }
    }
  }
コード例 #30
0
ファイル: OutputMarshaller.java プロジェクト: Orlandos/drools
  public static void writePropagationContext(MarshallerWriteContext context, PropagationContext pc)
      throws IOException {
    ObjectOutputStream stream = context.stream;
    Map<LeftTuple, Integer> tuples = context.terminalTupleMap;

    stream.writeInt(pc.getType());

    Rule ruleOrigin = pc.getRuleOrigin();
    if (ruleOrigin != null) {
      stream.writeBoolean(true);
      stream.writeUTF(ruleOrigin.getPackage());
      stream.writeUTF(ruleOrigin.getName());
    } else {
      stream.writeBoolean(false);
    }

    LeftTuple tupleOrigin = pc.getLeftTupleOrigin();
    if (tupleOrigin != null && tuples.containsKey(tupleOrigin)) {
      stream.writeBoolean(true);
      stream.writeInt(tuples.get(tupleOrigin));
    } else {
      stream.writeBoolean(false);
    }

    stream.writeLong(pc.getPropagationNumber());
    if (pc.getFactHandleOrigin() != null) {
      stream.writeInt(((InternalFactHandle) pc.getFactHandleOrigin()).getId());
    } else {
      stream.writeInt(-1);
    }

    stream.writeInt(pc.getActiveActivations());
    stream.writeInt(pc.getDormantActivations());

    stream.writeUTF(pc.getEntryPoint().getEntryPointId());
  }