public static void writeInitialFactHandleRightTuples(MarshallerWriteContext context)
      throws IOException {
    ObjectOutputStream stream = context.stream;
    InternalRuleBase ruleBase = context.ruleBase;

    ObjectTypeNode initialFactNode =
        ruleBase
            .getRete()
            .getEntryPointNode(EntryPoint.DEFAULT)
            .getObjectTypeNodes()
            .get(ClassObjectType.InitialFact_ObjectType);

    // do we write the fact to the objecttypenode memory
    if (initialFactNode != null) {
      ObjectHashSet initialFactMemory = (ObjectHashSet) context.wm.getNodeMemory(initialFactNode);
      if (initialFactMemory != null && !initialFactMemory.isEmpty()) {
        // context.out.println( "InitialFactMemory true int:" + initialFactNode.getId() );
        stream.writeBoolean(true);
        stream.writeInt(initialFactNode.getId());

        // context.out.println( "InitialFact RightTuples" );
        writeRightTuples(context.wm.getInitialFactHandle(), context);
      } else {
        // context.out.println( "InitialFactMemory false " );
        stream.writeBoolean(false);
      }
    } else {
      // context.out.println( "InitialFactMemory false " );
      stream.writeBoolean(false);
    }
  }
  /** Write a class using safe encoding to workaround java 1.3 serialization bug. */
  private void writeAnyClass(Class clazz, ObjectOutputStream out) throws IOException {
    // safely write out any class
    int primitiveType = 0;
    if (Boolean.TYPE.equals(clazz)) {
      primitiveType = BOOLEAN_TYPE;
    } else if (Byte.TYPE.equals(clazz)) {
      primitiveType = BYTE_TYPE;
    } else if (Character.TYPE.equals(clazz)) {
      primitiveType = CHAR_TYPE;
    } else if (Double.TYPE.equals(clazz)) {
      primitiveType = DOUBLE_TYPE;
    } else if (Float.TYPE.equals(clazz)) {
      primitiveType = FLOAT_TYPE;
    } else if (Integer.TYPE.equals(clazz)) {
      primitiveType = INT_TYPE;
    } else if (Long.TYPE.equals(clazz)) {
      primitiveType = LONG_TYPE;
    } else if (Short.TYPE.equals(clazz)) {
      primitiveType = SHORT_TYPE;
    }

    if (primitiveType == 0) {
      // then it's not a primitive type
      out.writeBoolean(false);
      out.writeObject(clazz);
    } else {
      // we'll write out a constant instead
      out.writeBoolean(true);
      out.writeInt(primitiveType);
    }
  }
  /**
   * Serializes the specified {@link Object} into a byte array (using Java Serialization).
   *
   * @param object the {@link Object} to serialize
   * @return a byte array
   * @throws IOException should serialization fail
   */
  public static byte[] toByteArray(Object object) throws IOException {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);

    // assume the object isn't serializable
    boolean isSerializable = false;

    try {
      objectOutputStream.writeBoolean(true);
      objectOutputStream.writeObject(object);
      isSerializable = true;
    } catch (IOException e) {
      // reconstruct the stream as the object wasn't serializable
      byteArrayOutputStream = new ByteArrayOutputStream();
      objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
    }

    if (!isSerializable) {
      objectOutputStream.writeBoolean(false);
      objectOutputStream.writeObject(object.getClass().getName());
    }

    objectOutputStream.flush();
    objectOutputStream.close();

    return byteArrayOutputStream.toByteArray();
  }
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeInt(CURRENT_SERIAL_VERSION);
   out.writeObject(name);
   out.writeObject(lexicon);
   out.writeBoolean(ignoreCase);
   out.writeBoolean(indvMatch);
 }
  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);
  }
 private void writeObject(java.io.ObjectOutputStream out) throws IOException {
   out.writeInt(getColor());
   out.writeBoolean(isDither());
   out.writeBoolean(isAntiAlias());
   if (getStyle().equals(Style.STROKE)) out.writeObject("stroke");
   else out.writeObject("fill");
   out.writeFloat(getStrokeWidth());
   out.writeFloat(getTextSize());
   if (getColorFilter() != null) out.writeBoolean(true);
   else out.writeBoolean(false);
 }
  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);
    }
  }
Exemple #8
0
  // Serializable//
  // NOTE: they must be declared as private
  private synchronized void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
    s.defaultWriteObject();

    boolean written = false;
    if (_sortAsc instanceof ListitemComparator) {
      final ListitemComparator c = (ListitemComparator) _sortAsc;
      if (c.getListheader() == this && c.isAscending()) {
        s.writeBoolean(true);
        s.writeBoolean(c.shallIgnoreCase());
        s.writeBoolean(c.byValue());
        written = true;
      }
    }
    if (!written) {
      s.writeBoolean(false);
      s.writeObject(_sortAsc);
    }

    written = false;
    if (_sortDsc instanceof ListitemComparator) {
      final ListitemComparator c = (ListitemComparator) _sortDsc;
      if (c.getListheader() == this && !c.isAscending()) {
        s.writeBoolean(true);
        s.writeBoolean(c.shallIgnoreCase());
        s.writeBoolean(c.byValue());
        written = true;
      }
    }
    if (!written) {
      s.writeBoolean(false);
      s.writeObject(_sortDsc);
    }
  }
  public static void writeFactHandles(MarshallerWriteContext context, ObjectStore objectStore)
      throws IOException {
    ObjectOutputStream stream = context.stream;
    InternalWorkingMemory wm = context.wm;
    ObjectMarshallingStrategyStore objectMarshallingStrategyStore =
        context.objectMarshallingStrategyStore;

    List<InternalFactHandle> matchFactHandles = null;

    if (((InternalAgenda) wm.getAgenda()).isDeclarativeAgenda()) {
      ActivationIterator it = ActivationIterator.iterator(wm);
      matchFactHandles = new ArrayList<InternalFactHandle>(100);
      for (Activation item = (Activation) it.next(); item != null; item = (Activation) it.next()) {
        matchFactHandles.add(item.getFactHandle());
      }
    }

    stream.writeInt(
        objectStore.size() + ((matchFactHandles == null) ? 0 : matchFactHandles.size()));

    // Write out FactHandles
    for (InternalFactHandle handle : orderFacts(objectStore)) {
      // stream.writeShort( PersisterEnums.FACT_HANDLE );
      // InternalFactHandle handle = (InternalFactHandle) it.next();
      writeFactHandle(context, stream, objectMarshallingStrategyStore, handle);

      writeRightTuples(handle, context);
    }

    if (matchFactHandles != null) {
      for (InternalFactHandle handle : orderFacts(matchFactHandles)) {
        Object object = handle.getObject();
        handle.setObject(
            null); // we must set it to null as we don't want to write out the Activation
        writeFactHandle(context, stream, objectMarshallingStrategyStore, handle);
        handle.setObject(object); // restore object
        writeRightTuples(handle, context);
      }
    }

    // writeLeftTuples( context );
    writeLeftTuples(context, orderFacts(objectStore));

    if (matchFactHandles != null) {
      stream.writeBoolean(true);
      writeLeftTuples(context, orderFacts(matchFactHandles));
    } else {
      stream.writeBoolean(false);
    }
  }
 /**
  * Writes a map of (<code>Comparable</code>, <code>Paint</code>) elements to a stream.
  *
  * @param map the map (<code>null</code> permitted).
  * @param out
  * @throws IOException
  * @see #readPaintMap(ObjectInputStream)
  */
 private void writePaintMap(Map<Comparable, Paint> map, ObjectOutputStream out)
     throws IOException {
   if (map == null) {
     out.writeBoolean(true);
   } else {
     out.writeBoolean(false);
     Set<Comparable> keys = map.keySet();
     int count = keys.size();
     out.writeInt(count);
     for (Comparable key : keys) {
       out.writeObject(key);
       SerialUtilities.writePaint(map.get(key), out);
     }
   }
 }
 /**
  * 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);
   }
 }
Exemple #12
0
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeInt(CURRENT_SERIAL_VERSION);
   out.writeObject(prefix);
   out.writeInt(gramSizes.length);
   for (int i = 0; i < gramSizes.length; i++) out.writeInt(gramSizes[i]);
   out.writeBoolean(distinguishBorders);
 }
 /**
  * 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);
   }
 }
Exemple #14
0
  private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(this.getEncoded());
    out.writeObject(algorithm);
    out.writeBoolean(withCompression);

    attrCarrier.writeObject(out);
  }
 /**
  * Custom serialization routine used during serialization of a Session/PersistenceContext for
  * increased performance.
  *
  * @param oos The stream to which we should write the serial data.
  * @throws IOException If a stream error occurs
  */
 public void serialize(ObjectOutputStream oos) throws IOException {
   oos.writeObject(entityName);
   oos.writeObject(id);
   oos.writeObject(entityMode.toString());
   oos.writeObject(tenantId);
   oos.writeObject(status.name());
   oos.writeObject((previousStatus == null ? "" : previousStatus.name()));
   // todo : potentially look at optimizing these two arrays
   oos.writeObject(loadedState);
   oos.writeObject(deletedState);
   oos.writeObject(version);
   oos.writeObject(lockMode.toString());
   oos.writeBoolean(existsInDatabase);
   oos.writeBoolean(isBeingReplicated);
   oos.writeBoolean(loadedWithLazyPropertiesUnfetched);
 }
 /** java.io.ObjectOutputStream#writeBoolean(boolean) */
 public void test_writeBooleanZ() throws Exception {
   // Test for method void java.io.ObjectOutputStream.writeBoolean(boolean)
   oos.writeBoolean(true);
   oos.close();
   ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
   assertTrue("Wrote incorrect byte value", ois.readBoolean());
 }
  @Override
  public void write(ObjectOutputStream out) throws IOException {
    super.write(out);

    SerializationUtils.writeCollection(remoteDestinations, out);
    SerializationUtils.writeCollection(throughPeers, out);
    out.writeBoolean(directBroadcast);
  }
 /** Saves the current characters */
 private void saveState() {
   try (ObjectOutputStream oos =
       new ObjectOutputStream(openFileOutput(FILE_NAME, Context.MODE_PRIVATE))) {
     oos.writeObject(Globals.tracker);
     oos.writeBoolean(Globals.combat);
   } catch (Exception e) {
     Toast.makeText(getApplicationContext(), "failed to save state", Toast.LENGTH_SHORT).show();
   }
 }
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeObject(cookie.getName());
   out.writeObject(cookie.getValue());
   out.writeObject(cookie.getComment());
   out.writeObject(cookie.getDomain());
   out.writeObject(cookie.getExpiryDate());
   out.writeObject(cookie.getPath());
   out.writeInt(cookie.getVersion());
   out.writeBoolean(cookie.isSecure());
 }
 private void writeObject(ObjectOutputStream paramObjectOutputStream) throws IOException {
   paramObjectOutputStream.writeObject(this.cookie.getName());
   paramObjectOutputStream.writeObject(this.cookie.getValue());
   paramObjectOutputStream.writeObject(this.cookie.getComment());
   paramObjectOutputStream.writeObject(this.cookie.getDomain());
   paramObjectOutputStream.writeObject(this.cookie.getExpiryDate());
   paramObjectOutputStream.writeObject(this.cookie.getPath());
   paramObjectOutputStream.writeInt(this.cookie.getVersion());
   paramObjectOutputStream.writeBoolean(this.cookie.isSecure());
 }
/*     */   private void writeObject(ObjectOutputStream s) throws IOException {
/* 791 */     long[] key = this.key;
/* 792 */     boolean[] value = this.value;
/* 793 */     MapIterator i = new MapIterator(null);
/* 794 */     s.defaultWriteObject();
/* 795 */     for (int j = this.size; j-- != 0; ) {
/* 796 */       int e = i.nextEntry();
/* 797 */       s.writeLong(key[e]);
/* 798 */       s.writeBoolean(value[e]);
/*     */     }
/*     */   }
 private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
   final int key[] = this.key;
   final boolean value[] = this.value;
   final MapIterator i = new MapIterator();
   s.defaultWriteObject();
   for (int j = size, e; j-- != 0; ) {
     e = i.nextEntry();
     s.writeInt(key[e]);
     s.writeBoolean(value[e]);
   }
 }
Exemple #23
0
  public static void safeSerialize(ObjectOutputStream out, Serializable data) throws IOException {
    if (data == null) {
      out.writeBoolean(false);
      return;
    } else {
      out.writeBoolean(true);
    }

    byte[] serialData;

    if (data instanceof SerializedData) {
      SerializedData dummyData = (SerializedData) data;
      serialData = dummyData.serialData;
    } else {
      serialData = serialize(data);
      ;
    }

    out.writeInt(serialData.length);

    out.write(serialData);
  }
  /**
   * Serializes an Object into the given {@link ObjectOutputStream}. The serialized Object can than
   * be deserialized with <code>SopremoUtil.deserializeObject()</code>
   *
   * @param oos the stream that should be used for serialization
   * @param object the object that should be serialized
   * @throws IOException
   */
  public static void serializeObject(final ObjectOutputStream oos, final Object object)
      throws IOException {

    if (object instanceof Serializable) {
      oos.writeBoolean(true);
      oos.writeObject(object);
      return;
    }

    oos.writeBoolean(false);
    oos.writeUTF(object.getClass().getName());
    final Map<String, Object> values = new HashMap<String, Object>();
    BeanInfo beanInfo;
    try {
      beanInfo = Introspector.getBeanInfo(object.getClass());
    } catch (final IntrospectionException e) {
      LOG.info(
          String.format(
              "Cannot retrieve bean info for type %s: %s", object.getClass(), e.getMessage()));
      oos.writeObject(values);
      return;
    }

    for (final PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors())
      if (Serializable.class.isAssignableFrom(propertyDescriptor.getPropertyType())
          && propertyDescriptor.getReadMethod() != null
          && propertyDescriptor.getWriteMethod() != null)
        try {
          values.put(
              propertyDescriptor.getName(), propertyDescriptor.getReadMethod().invoke(object));
        } catch (final Exception e) {
          LOG.debug(
              String.format(
                  "Cannot serialize field %s of type %s: %s",
                  propertyDescriptor.getName(), object.getClass(), e.getMessage()));
        }
    oos.writeObject(values);
  }
 private void writeObject(ObjectOutputStream objectoutputstream) {
   try {
     objectoutputstream.writeObject(stroke);
     objectoutputstream.writeObject(text);
     objectoutputstream.writeBoolean(hasBorder);
     objectoutputstream.writeBoolean(hasGradient);
     objectoutputstream.writeInt(fillColor);
     objectoutputstream.writeInt(gradientColor);
     objectoutputstream.writeObject(mode);
     objectoutputstream.writeObject(styleData);
     return;
   }
   // Misplaced declaration of an exception variable
   catch (ObjectOutputStream objectoutputstream) {
     com.socialin.android.d.b(
         TAG,
         new Object[] {
           (new StringBuilder("Got unexpected exception: "))
               .append(objectoutputstream.getMessage())
               .toString()
         });
   }
 }
  private void saveOnePlayerVersusGameMarker() {

    // Save identifier that a saved game exists
    try {
      FileOutputStream fileOutputStream =
          openFileOutput("oneplayerversussavedgame", Context.MODE_PRIVATE);
      ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
      objectOutputStream.writeBoolean(false);
      objectOutputStream.close();
      fileOutputStream.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemple #27
0
    /*
     * When object is serialized writeReplace() causes this
     * SerializationProxy object to be written. Write it in a custom way
     * that includes a version ID so that clients and servers can have two
     * different versions of code.
     */
    protected void writeObject(java.io.ObjectOutputStream stream) throws IOException {
      stream.writeShort(currentSerializationVersion);

      stream.writeObject(blockId);
      stream.writeObject(blockAssignmentMethod);
      stream.writeObject(avl);
      stream.writeFloat(heading);
      stream.writeObject(routeId);
      stream.writeObject(routeShortName);
      stream.writeObject(tripId);
      stream.writeObject(tripPatternId);
      stream.writeObject(directionId);
      stream.writeObject(headsign);
      stream.writeBoolean(predictable);
      stream.writeBoolean(schedBasedPred);
      stream.writeObject(realTimeSchdAdh);
      stream.writeBoolean(isDelayed);
      stream.writeBoolean(isLayover);
      stream.writeLong(layoverDepartureTime);
      stream.writeObject(nextStopId);
      stream.writeObject(nextStopName);
      stream.writeObject(vehicleType);
    }
Exemple #28
0
  private void startServer() {
    System.out.println("Starting server...");
    try {
      ServerSocket servSocket = new ServerSocket(6789);
      // endless Server-loop
      int methID;
      Benutzer ben = new Benutzer();
      while (true) {
        Socket client = servSocket.accept();
        System.out.println("Accepted client...");
        ObjectInputStream in = new ObjectInputStream(client.getInputStream());
        ObjectOutputStream out = new ObjectOutputStream(client.getOutputStream());
        System.out.println("Received both Streams on ServerOrb...");
        methID = in.readInt();
        System.out.println("Read the Method-ID...");
        try {
          ben = (Benutzer) in.readObject();
          System.out.println("Received Benutzer-object...");
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        }

        if (methID == 1) {
          out.writeBoolean(bv.benutzerOk(ben));
          out.flush();
          System.out.println("Flushed for Boolean-Value...");
          System.out.println("Boolean bei methID==1 zurueckgegeben.");
          System.out.println();
        } else if (methID == 2) {
          try {
            bv.benutzerEintragen(ben);
            System.out.println("Benutzer erfolgreich in die Datenhaltung eingetragen.#");
            out.writeObject(ben);
            out.flush();
            System.out.println("Wrote Benutzer-Object with manual flush...");
            System.out.println();
          } catch (BenutzerSchonVorhandenException e) {
            out.writeObject(e);
            System.out.println("BenutzerSchonVorhandenException wurde verschickt.");
          }
        }
        in.close();
        out.close();
        System.out.println("Closed OutputStream on ServerOrb...");
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  /**
   * This is to fix bugzilla bug 22438 If the user defined class implements URIResolver and
   * Serializable then we want it to get serialized
   */
  private void writeObject(ObjectOutputStream os) throws IOException, ClassNotFoundException {
    if (_auxClasses != null) {
      // throw with the same message as when Hashtable was used for compatibility.
      throw new NotSerializableException(
          "com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
    }

    // Write serialized fields
    ObjectOutputStream.PutField pf = os.putFields();
    pf.put("_name", _name);
    pf.put("_bytecodes", _bytecodes);
    pf.put("_class", _class);
    pf.put("_transletIndex", _transletIndex);
    pf.put("_outputProperties", _outputProperties);
    pf.put("_indentNumber", _indentNumber);
    os.writeFields();

    if (_uriResolver instanceof Serializable) {
      os.writeBoolean(true);
      os.writeObject((Serializable) _uriResolver);
    } else {
      os.writeBoolean(false);
    }
  }
Exemple #30
0
  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());
  }