コード例 #1
0
 /**
  * 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
       }
     }
   }
 }
コード例 #2
0
  private void writeTo(ObjectOutput o) throws IOException {
    o.writeInt(x);
    o.writeInt(y);
    o.writeInt(width);
    o.writeInt(height);
    o.writeInt(measuredWidth);
    o.writeInt(measuredHeight);
    o.writeInt(scrollX);
    o.writeInt(scrollY);
    o.writeInt(absoluteX);
    o.writeInt(absoluteY);
    o.writeFloat(cameraDistance);
    o.writeBoolean(visible);
    o.writeLong(drawingTime);
    o.writeBoolean(isShown);
    o.writeBoolean(hasFocus);
    o.writeBoolean(focusable);
    o.writeBoolean(hasOnClickListener);
    o.writeObject(viewType);
    o.writeObject(textContent);
    o.writeBoolean(isEditText);
    o.writeBoolean(isInputMethodTarget);
    o.writeBoolean(isContainer);
    o.writeInt(inputMethod);
    o.writeInt(id);

    if (children != null) {
      o.writeInt(children.size());
      for (ViewComponentInfo child : children) {
        child.writeTo(o);
      }
    } else {
      o.writeInt(0);
    }
  }
コード例 #3
0
  /** Serializes this <code>DataFlavor</code>. */
  public synchronized void writeExternal(ObjectOutput os) throws IOException {
    if (mimeType != null) {
      mimeType.setParameter("humanPresentableName", humanPresentableName);
      os.writeObject(mimeType);
      mimeType.removeParameter("humanPresentableName");
    } else {
      os.writeObject(null);
    }

    os.writeObject(representationClass);
  }
コード例 #4
0
 public void writeExternal(ObjectOutput out) throws IOException {
   // esto es solo para serializar tickets que no estan en la bolsa de tickets pendientes
   out.writeObject(m_sId);
   out.writeInt(tickettype);
   out.writeInt(m_iTicketId);
   out.writeInt(m_iTicketNCF); // NCF
   out.writeObject(m_Customer);
   out.writeObject(m_dDate);
   out.writeObject(attributes);
   out.writeObject(m_aLines);
 }
コード例 #5
0
ファイル: Skill.java プロジェクト: DonnieSantos/TempestMUD
  public void writeExternal(ObjectOutput out) {

    try {
      out.writeObject("LEVEL");
      out.writeObject(new Integer(level));
      out.writeObject("TIMESUSED");
      out.writeObject(new Integer(timesUsed));
      out.writeObject("SKILL END");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #6
0
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    out.writeBoolean(depEnabled);

    if (depEnabled) {
      U.writeByteArray(out, topicBytes);
      U.writeByteArray(out, predBytes);
      U.writeString(out, clsName);
      out.writeObject(depInfo);
    } else {
      out.writeObject(topic);
      out.writeObject(pred);
    }
  }
コード例 #7
0
  // Implements Externalizable
  public void writeExternal(ObjectOutput out) throws IOException {
    // VERSION
    out.writeByte(0);

    // MAP
    out.writeObject(_map);
  }
コード例 #8
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);
    }
  }
コード例 #9
0
 /**
  * @param out Output stream.
  * @param err Error cause.
  */
 private void sendErrorResponse(ObjectOutput out, Exception err) {
   try {
     out.writeObject(new IpcSharedMemoryInitResponse(err));
   } catch (IOException e) {
     U.error(log, "Failed to send error response to client.", e);
   }
 }
コード例 #10
0
  // write data to server's database file
  private void updateFile(String file_name, Object data) {
    try {
      OutputStream file_data = new FileOutputStream(file_name);
      OutputStream buffer = new BufferedOutputStream(file_data);
      ObjectOutput data_out = new ObjectOutputStream(buffer);

      data_out.writeObject(data);
      data_out.close();
    } catch (Exception e) {
      System.out.println("updateFile: Failed to update data to " + file_name);
    }
  }
コード例 #11
0
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    out.writeLong(topVer);
    out.writeBoolean(implicitTx);
    out.writeBoolean(implicitSingleTx);
    out.writeBoolean(syncCommit);
    out.writeBoolean(syncRollback);
    out.writeObject(filterBytes);

    U.writeArray(out, dhtVers);

    assert miniId != null;

    U.writeGridUuid(out, miniId);
  }
コード例 #12
0
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    assert futId != null;
    assert miniId != null;
    assert ver != null;

    U.writeGridUuid(out, futId);
    U.writeGridUuid(out, miniId);
    U.writeCollection(out, entries);
    U.writeIntCollection(out, invalidParts);

    CU.writeVersion(out, ver);

    out.writeObject(err);
  }
コード例 #13
0
  /**
   * @param out Object output.
   * @throws IOException If failed.
   */
  @SuppressWarnings("TypeMayBeWeakened")
  private void writeFieldsCollection(ObjectOutput out) throws IOException {
    assert fields;

    out.writeInt(data != null ? data.size() : -1);

    if (data == null) return;

    for (Object o : data) {
      List<GridIndexingEntity<?>> list = (List<GridIndexingEntity<?>>) o;

      out.writeInt(list.size());

      for (GridIndexingEntity<?> idxEnt : list) {
        try {
          out.writeObject(idxEnt.value());
        } catch (GridSpiException e) {
          throw new IOException("Failed to write indexing entity: " + idxEnt, e);
        }
      }
    }
  }
コード例 #14
0
ファイル: SubCharSeq.java プロジェクト: maoueh/kawa-fork
 public void writeExternal(ObjectOutput out) throws IOException {
   out.writeObject(base);
   out.writeInt(start);
   out.writeInt(end);
 }
コード例 #15
0
 /** {@inheritDoc} */
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   out.writeObject(key);
   out.writeObject(val);
 }