@Override
 protected void writeObject(ObjectOutput out, Object obj) throws IOException {
   BigInteger val = (BigInteger) obj;
   byte[] bytes = val.toByteArray();
   out.writeInt(bytes.length);
   out.write(bytes);
 }
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   out.writeObject(this.propertyName);
   out.writeObject(this.persistList);
   out.writeBoolean(this.clear);
   out.writeBoolean(this.exclusive);
 }
 /**
  * compare the byte-array representation of two TaskObjects.
  *
  * @param f TaskObject
  * @param s TaskObject
  * @return true if the two arguments have the same byte-array
  */
 private boolean sameBytes(TaskObject f, TaskObject s) {
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   ObjectOutput out = null;
   try {
     out = new ObjectOutputStream(bos);
     out.writeObject(f);
     byte[] fs = bos.toByteArray();
     out.writeObject(s);
     byte[] ss = bos.toByteArray();
     if (fs.length != ss.length) return false;
     for (int i = 0; i < fs.length; i++) {
       if (fs[i] != ss[i]) return false;
     }
     return true;
   } catch (IOException e) {
     e.printStackTrace();
     return false;
   } finally {
     if (out != null) {
       try {
         out.close();
       } catch (IOException e) {
         // ignore
       }
       try {
         bos.close();
       } catch (IOException e) {
         // ignore
       }
     }
   }
 }
示例#4
0
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    boolean done;
    boolean cancelled;
    Object res;
    Throwable err;
    boolean syncNotify;
    boolean concurNotify;

    synchronized (mux) {
      done = this.done;
      cancelled = this.cancelled;
      res = this.res;
      err = this.err;
      syncNotify = this.syncNotify;
      concurNotify = this.concurNotify;
    }

    out.writeBoolean(done);
    out.writeBoolean(syncNotify);
    out.writeBoolean(concurNotify);

    // Don't write any further if not done, as deserialized future
    // will be invalid anyways.
    if (done) {
      out.writeBoolean(cancelled);
      out.writeObject(res);
      out.writeObject(err);
    }
  }
示例#5
0
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {

    out.writeObject(fixMessageArr);
    out.writeInt(objGetPosition);
    out.writeInt(objectPutPosition);
  }
 public void writeExternal(ObjectOutput out) throws IOException {
   super.writeExternal(out);
   out.writeInt(LATEST_VERSION);
   out.writeObject(username);
   out.writeObject(dn);
   out.writeObject(tokenTypeLabel);
 }
 public static byte[] serializeAction(Action action) {
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   ObjectOutput out = null;
   byte[] yourBytes = null;
   try {
     out = new ObjectOutputStream(bos);
     out.writeObject(action);
     yourBytes = bos.toByteArray();
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     try {
       if (out != null) {
         out.close();
       }
     } catch (IOException ex) {
       // ignore close exception
     }
     try {
       bos.close();
     } catch (IOException ex) {
       // ignore close exception
     }
   }
   return yourBytes;
 }
  /** Serialize an instance, restore it, and check for equality. */
  public void testSerialization() {
    DefaultHighLowDataset d1 =
        new DefaultHighLowDataset(
            "Series 1",
            new Date[] {new Date(123L)},
            new double[] {1.2},
            new double[] {3.4},
            new double[] {5.6},
            new double[] {7.8},
            new double[] {99.9});
    DefaultHighLowDataset d2 = null;

    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(d1);
      out.close();

      ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
      d2 = (DefaultHighLowDataset) in.readObject();
      in.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
    assertEquals(d1, d2);
  }
示例#9
0
 public void writeExternal(ObjectOutput out) throws IOException {
   super.writeExternal(out);
   out.writeObject(rmAddress);
   out.writeObject(filter);
   out.writeInt(port);
   out.writeObject(usedAcc);
 }
示例#10
0
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   String typeName = type.getName();
   out.writeInt(typeName.length());
   out.writeChars(typeName);
   out.writeObject(arg);
 }
  // implementation of doSomething()
  public void doSomething() throws java.rmi.RemoteException {
    String codebase = System.getProperty("java.rmi.server.codebase", "");

    try {
      if (useNewInvoke) {
        ref.invoke(
            this, $method_doSomething_1, new java.lang.Object[] {codebase}, 3082155412933025001L);
      } else {
        java.rmi.server.RemoteCall call =
            ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
        try {
          java.io.ObjectOutput out = call.getOutputStream();
          out.writeObject(codebase);
        } catch (java.io.IOException e) {
          throw new java.rmi.MarshalException("error marshalling arguments", e);
        }
        ref.invoke(call);
        ref.done(call);
      }
    } catch (java.lang.RuntimeException e) {
      throw e;
    } catch (java.rmi.RemoteException e) {
      throw e;
    } catch (java.lang.Exception e) {
      throw new java.rmi.UnexpectedException("undeclared checked exception", e);
    }
  }
示例#12
0
文件: LDA.java 项目: hqmshhxx/jmlp
  public void writeExternal(ObjectOutput out) throws IOException {
    // TODO Auto-generated method stub
    out.writeInt(_n_inputs);
    out.writeInt(_n_outputs);

    out.writeObject(_eig_mat);
  }
 public void writeExternal(ObjectOutput out) throws IOException {
   out.writeObject(this.element1);
   out.writeObject(this.element2);
   out.writeObject(this.element3);
   out.writeObject(this.element4);
   out.writeObject(this.element5);
 }
示例#14
0
 @Override
 public void writeExternal(final ObjectOutput out) throws IOException {
   out.writeInt(this.length);
   for (int i = 0; i < this.length; i++) {
     out.writeLong(Double.doubleToRawLongBits(this.realValues[i]));
   }
 }
示例#15
0
  public void writeExternal(ObjectOutput out) throws IOException {
    out.writeByte(0); // reserved for future expansion (version id)
    out.writeShort(fieldNumber);

    if (header != null) writeHeader(out);
    if (packager != null) writePackager(out);
    if (direction > 0) writeDirection(out);

    // List keySet = new ArrayList (fields.keySet());
    // Collections.sort (keySet);
    Iterator iter = fields.values().iterator();
    while (iter.hasNext()) {
      ISOComponent c = (ISOComponent) iter.next();
      if (c instanceof ISOMsg) {
        writeExternal(out, 'M', c);
      } else if (c instanceof ISOBinaryField) {
        writeExternal(out, 'B', c);
      } else if (c instanceof ISOAmount) {
        writeExternal(out, 'A', c);
      } else if (c instanceof ISOField) {
        writeExternal(out, 'F', c);
      }
    }
    out.writeByte('E');
  }
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    if (correlationId != null) out.writeUTF(correlationId);
    else out.writeObject(null);
  }
  /**
   * Save the base state of the instance. This method performs step finalization if it has not been
   * done before.
   *
   * @param out stream where to save the state
   * @exception IOException in case of write error
   */
  protected void writeBaseExternal(final ObjectOutput out) throws IOException {

    if (currentState == null) {
      out.writeInt(-1);
    } else {
      out.writeInt(currentState.length);
    }
    out.writeDouble(globalPreviousTime);
    out.writeDouble(globalCurrentTime);
    out.writeDouble(softPreviousTime);
    out.writeDouble(softCurrentTime);
    out.writeDouble(h);
    out.writeBoolean(forward);

    if (currentState != null) {
      for (int i = 0; i < currentState.length; ++i) {
        out.writeDouble(currentState[i]);
      }
    }

    out.writeDouble(interpolatedTime);

    // we do not store the interpolated state,
    // it will be recomputed as needed after reading

    // finalize the step (and don't bother saving the now true flag)
    try {
      finalizeStep();
    } catch (DerivativeException e) {
      IOException ioe = new IOException(e.getLocalizedMessage());
      ioe.initCause(e);
      throw ioe;
    }
  }
示例#18
0
 public static void writeEnum(ObjectOutput out, Enum<?> value) throws IOException {
   if (value == null) {
     out.writeObject(null);
   } else {
     out.writeUTF(value.name());
   }
 }
示例#19
0
  /** {@inheritDoc} */
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    byte[] data = path.getBytes(Constants.DEFAULT_ENCODING);
    out.writeInt(data.length);
    out.write(data);
  }
示例#20
0
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   super.writeExternal(out);
   out.writeUTF(libelle);
   out.writeUTF(emplacement);
   out.writeObject(allees);
 }
示例#21
0
 @Override
 public void writeExternal(final ObjectOutput out) throws IOException {
   out.writeInt(data.length);
   for (final byte element : data) {
     out.writeByte(element);
   }
 }
  /** Serialize an instance, restore it, and check for equality. */
  public void testSerialization() {

    List u1 = new java.util.ArrayList();
    u1.add("URL A1");
    u1.add("URL A2");
    u1.add("URL A3");

    List u2 = new java.util.ArrayList();
    u2.add("URL B1");
    u2.add("URL B2");
    u2.add("URL B3");

    CustomXYURLGenerator g1 = new CustomXYURLGenerator();
    CustomXYURLGenerator g2 = null;

    g1.addURLSeries(u1);
    g1.addURLSeries(u2);

    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(g1);
      out.close();

      ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
      g2 = (CustomXYURLGenerator) in.readObject();
      in.close();
    } catch (Exception e) {
      System.out.println(e.toString());
    }
    assertEquals(g1, g2);
  }
示例#23
0
 @Override
 public void writeExternal(ObjectOutput output) throws IOException {
   output.writeUTF(keyTypeClassName);
   output.writeInt(version);
   output.writeInt(mergePoint);
   output.writeInt(instanceCount);
 }
 @Override
 public void writeExternal(final ObjectOutput out) throws IOException {
   super.writeExternal(out);
   out.writeObject(this.key);
   out.writeObject(this.text);
   out.writeObject(this.nextEvent);
 }
  private void updatePackageBinaries(PackageItem item, PackageAssembler packageAssembler)
      throws DetailedSerializationException {
    try {
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      ObjectOutput out = new DroolsObjectOutputStream(bout);
      out.writeObject(packageAssembler.getBinaryPackage());

      item.updateCompiledPackage(new ByteArrayInputStream(bout.toByteArray()));
      out.flush();
      out.close();

      item.updateBinaryUpToDate(true);

      RuleBase ruleBase =
          RuleBaseFactory.newRuleBase(new RuleBaseConfiguration(getClassLoaders(packageAssembler)));
      ruleBase.addPackage(packageAssembler.getBinaryPackage());

      rulesRepository.save();
    } catch (Exception e) {
      e.printStackTrace();
      log.error(
          "An error occurred building the package [" + item.getName() + "]: " + e.getMessage());
      throw new DetailedSerializationException(
          "An error occurred building the package.", e.getMessage());
    }
  }
示例#26
0
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   super.writeExternal(out);
   out.writeShort(eventType);
   out.writeInt(streamId);
   out.writeInt(bufferLength);
 }
  // Implements Externalizable
  public void writeExternal(ObjectOutput out) throws IOException {
    // VERSION
    out.writeByte(0);

    // MAP
    out.writeObject(_map);
  }
示例#28
0
 protected void writePackager(ObjectOutput out) throws IOException {
   out.writeByte('P');
   String pclass = packager.getClass().getName();
   byte[] b = pclass.getBytes();
   out.writeShort(b.length);
   out.write(b);
 }
 /*     */ public void writeExternal(ObjectOutput objOut) throws IOException {
   /* 129 */ objOut.writeDouble(this.mFWED.mMatchWeight);
   /* 130 */ objOut.writeDouble(this.mFWED.mDeleteWeight);
   /* 131 */ objOut.writeDouble(this.mFWED.mInsertWeight);
   /* 132 */ objOut.writeDouble(this.mFWED.mSubstituteWeight);
   /* 133 */ objOut.writeDouble(this.mFWED.mTransposeWeight);
   /*     */ }
示例#30
0
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   byte[] bytes = getBytes();
   out.writeInt(bytes.length);
   out.writeInt(this.numFields);
   out.write(bytes);
 }