Esempio n. 1
0
  /** @see BTmsg#writeExternal(java.io.ObjectOutput) */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);

    assert this.offset < Short.MAX_VALUE;
    out.writeShort(this.offset);
    assert this.nbrAssignments < Short.MAX_VALUE;
    out.writeShort(this.nbrAssignments);
    V val = this.assignments[this.offset][0];
    out.writeObject(val); // first assignment
    final boolean externalize = val.externalize();

    // Write the assignments one by one
    for (int i = this.offset; i < this.nbrAssignments; i++) { // the assignments
      V[] assignment = this.assignments[i];
      assert assignment.length < Short.MAX_VALUE;
      out.writeShort(assignment.length);
      for (int j = assignment.length - 1; j >= 0; j--) {
        if (externalize) assignment[j].writeExternal(out);
        else out.writeObject(assignment[j]);
      }
    }

    out.writeObject(this.cost);
  }
Esempio n. 2
0
 /**
  * Write this out.
  *
  * @exception IOException error writing to log stream
  */
 public synchronized void writeExternal(ObjectOutput out) throws IOException {
   out.writeLong(getPrevblk());
   out.writeLong(getNextblk());
   out.writeShort(getBytesused());
   out.writeShort(getBytesinuse());
   out.writeLong(getPageLSN());
   if (getBytesused() == datasize) out.write(data);
   else out.write(data, 0, getBytesused());
 }
 public static void writeOrganizationalEntityList(
     List<OrganizationalEntity> list, ObjectOutput out) throws IOException {
   out.writeInt(list.size());
   for (OrganizationalEntity item : list) {
     if (item instanceof User) {
       out.writeShort(0);
     } else {
       out.writeShort(1);
     }
     item.writeExternal(out);
   }
 }
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   out.write(this.cardinality & 0xFF);
   out.write((this.cardinality >>> 8) & 0xFF);
   if (BufferUtil.isBackedBySimpleArray(content)) {
     short[] a = content.array();
     for (int k = 0; k < this.cardinality; ++k) {
       out.writeShort(Short.reverseBytes(a[k]));
     }
   } else {
     for (int k = 0; k < this.cardinality; ++k) {
       out.writeShort(Short.reverseBytes(content.get(k)));
     }
   }
 }
Esempio n. 5
0
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   super.writeExternal(out);
   out.writeShort(eventType);
   out.writeInt(streamId);
   out.writeInt(bufferLength);
 }
Esempio n. 6
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);
 }
Esempio n. 7
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');
  }
  private static void writeOnPrimitive(
      final ObjectOutput out, final Object obj, final ClassMetadataField metaField)
      throws IOException {

    try {
      final Field field = metaField.getField();
      final Class clazz = field.getType();
      if (clazz == Integer.TYPE) {
        out.writeInt(FieldsManager.getFieldsManager().getInt(obj, metaField));
      } else if (clazz == Byte.TYPE) {
        out.writeByte(FieldsManager.getFieldsManager().getByte(obj, metaField));
      } else if (clazz == Long.TYPE) {
        out.writeLong(FieldsManager.getFieldsManager().getLong(obj, metaField));
      } else if (clazz == Float.TYPE) {
        out.writeFloat(FieldsManager.getFieldsManager().getFloat(obj, metaField));
      } else if (clazz == Double.TYPE) {
        out.writeDouble(FieldsManager.getFieldsManager().getDouble(obj, metaField));
      } else if (clazz == Short.TYPE) {
        out.writeShort(FieldsManager.getFieldsManager().getShort(obj, metaField));
      } else if (clazz == Character.TYPE) {
        out.writeChar(field.getChar(obj));
      } else if (clazz == Boolean.TYPE) {
        out.writeBoolean(field.getBoolean(obj));
      } else {
        throw new RuntimeException("Unexpected datatype " + clazz.getName());
      }
    } catch (IllegalAccessException access) {
      IOException io = new IOException(access.getMessage());
      io.initCause(access);
      throw io;
    }
  }
Esempio n. 9
0
  /** @see java.io.Externalizable#writeExternal(java.io.ObjectOutput) */
  public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(this.sender);
    out.writeObject(this.receiver);

    // Serialize the context manually
    final int size = this.context.size();
    assert size < Short.MAX_VALUE;
    out.writeShort(size); // size of context
    if (size > 0) {
      Iterator<Map.Entry<String, Val>> iter = this.context.entrySet().iterator();
      Map.Entry<String, Val> entry = iter.next();
      out.writeObject(entry.getKey()); // first variable
      out.writeObject(entry.getValue()); // value of first variable
      final boolean externalize = entry.getValue().externalize();

      // Serialize the rest
      while (iter.hasNext()) {
        entry = iter.next();
        out.writeObject(entry.getKey());
        if (externalize) entry.getValue().writeExternal(out);
        else out.writeObject(entry.getValue());
      }
    }

    // Write the bounds
    out.writeObject(this.lb);
    if (this.lb.externalize()) this.ub.writeExternal(out);
    else out.writeObject(this.ub);
  }
 public void writeExternal(ObjectOutput objectoutput) throws IOException {
   int j = size;
   objectoutput.writeInt(j);
   for (int i = 0; i < j; i++) {
     objectoutput.writeShort(data[i]);
   }
 }
Esempio n. 11
0
 void writeObj(ObjectOutput out) throws IOException {
   out.writeInt(numSymbols());
   for (int i = 0; i < numSymbols(); ++i) {
     String symbol = idToSymbol(i);
     out.writeShort(symbol.length());
     out.writeChars(symbol);
   }
 }
Esempio n. 12
0
 protected void writeHeader(ObjectOutput out) throws IOException {
   int len = header.getLength();
   if (len > 0) {
     out.writeByte('H');
     out.writeShort(len);
     out.write(header.pack());
   }
 }
 public void writeExternal(final ObjectOutput out) throws IOException {
   out.writeByte(1);
   out.writeInt(this._pos);
   final int len = this._pos;
   out.writeInt(this._pos);
   for (int i = 0; i < len; ++i) {
     out.writeShort(this._data[i]);
   }
 }
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    // VERSION
    out.writeByte(0);

    // POSITION
    out.writeInt(_pos);

    // NO_ENTRY_VALUE
    out.writeShort(no_entry_value);

    // ENTRIES
    int len = capacity();
    out.writeInt(len);
    for (int i = 0; i < len; i++) {
      out.writeShort(_data.get(i));
    }
  }
Esempio n. 15
0
  /** {@inheritDoc} */
  public void writeExternal(ObjectOutput out) throws IOException {
    // VERSION
    out.writeByte(0);

    // SUPER
    super.writeExternal(out);

    // NUMBER OF ENTRIES
    out.writeInt(_size);

    // ENTRIES
    for (int i = _states.length; i-- > 0; ) {
      if (_states[i] == FULL) {
        out.writeShort(_set[i]);
        out.writeShort(_values[i]);
      }
    }
  }
 /**
  * Writes the value read from the provided byte {@code buffer} at the specified {@code index} to
  * the provided {@code objectOutput}.
  *
  * @param objectOutput the object output stream to which the value is written
  * @param wordSize the number of bytes used to store the value
  * @param inputBuffer the byte buffer from which the value is read
  * @param index the index of the value in the the byte buffer
  * @throws IOException if an error occurred writing to the provided object output stream
  */
 private static void writeExternalWord(
     ObjectOutput objectOutput, int wordSize, ByteBuffer inputBuffer, int index)
     throws IOException {
   int wordIndex = index * wordSize;
   if (wordSize == SHORT_NUM_BYTES) {
     objectOutput.writeShort(inputBuffer.getShort(wordIndex));
   } else {
     objectOutput.writeInt(inputBuffer.getInt(wordIndex));
   }
 }
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    GridUtils.writeUuid(out, nodeId);

    CU.writeVersion(out, ver);

    out.writeLong(timeout);
    out.writeLong(threadId);
    out.writeLong(id);
    out.writeShort(flags());
  }
 /**
  * For Externalizable
  *
  * @see Externalizable
  */
 public void writeExternal(ObjectOutput out) throws IOException {
   //    if (this.transientPort == 0) {
   //      InternalDistributedSystem.getLoggerI18n().warning(
   //          LocalizedStrings.DEBUG,
   //          "externalizing a client ID with zero port: " + this.toString(),
   //          new Exception("Stack trace"));
   //    }
   Assert.assertTrue(this.identity.length <= BYTES_32KB);
   out.writeShort(this.identity.length);
   out.write(this.identity);
   out.writeInt(this.uniqueId);
 }
Esempio n. 19
0
  public void writeExternal(ObjectOutput out) throws IOException {
    out.writeByte(0);

    super.writeExternal(out);

    out.writeInt(this._size);
    for (int i = this._states.length; i-- > 0; ) {
      if (this._states[i] == 1) {
        out.writeChar(this._set[i]);
        out.writeShort(this._values[i]);
      }
    }
  }
Esempio n. 20
0
  /** {@inheritDoc} */
  public void writeExternal(ObjectOutput out) throws IOException {

    // VERSION
    out.writeByte(1);

    // SUPER
    super.writeExternal(out);

    // NUMBER OF ENTRIES
    out.writeInt(_size);

    // LOAD FACTOR -- Added version 1
    out.writeFloat(_loadFactor);

    // NO ENTRY VALUE -- Added version 1
    out.writeShort(no_entry_value);

    // ENTRIES
    for (int i = _states.length; i-- > 0; ) {
      if (_states[i] == FULL) {
        out.writeShort(_set[i]);
      }
    }
  }
Esempio n. 21
0
  @Override
  public void writeExternal(final ObjectOutput out) throws IOException {
    // write out the version of the serialized data for future use
    out.writeByte(1);

    handler.client.setMetaData(metaData);
    handler.client.writeExternal(out);

    final EJBMetaDataImpl ejb = handler.ejb;
    out.writeObject(getClassName(ejb.homeClass));
    out.writeObject(getClassName(ejb.remoteClass));
    out.writeObject(getClassName(ejb.keyClass));
    out.writeByte(ejb.type);
    out.writeUTF(ejb.deploymentID);
    out.writeShort(ejb.deploymentCode);

    handler.server.setMetaData(metaData);
    handler.server.writeExternal(out);
  }
Esempio n. 22
0
  public void writeExternal(final ObjectOutput out) throws IOException {

    if (val2iv == null) throw new IllegalStateException();
    if (iv2val == null) throw new IllegalStateException();

    out.writeShort(currentVersion);

    switch (currentVersion) {
        //        case VERSION0:
        //            writeVersion0(out);
        //            break;
        //        case VERSION1:
        //            writeVersion1(out);
        //            break;
      case VERSION2:
        writeVersion2(out);
        break;
      default:
        throw new AssertionError();
    }
  }
Esempio n. 23
0
  public void releaseOutputStream() throws IOException {
    if (vec != null) {
      oout = conn.getObjectOutputStream();

      for (int i = 0; i < vec.size(); i += 2) {
        boolean primitive = ((Boolean) vec.elementAt(i)).booleanValue();
        Object data = vec.elementAt(i + 1);

        // No type, this is
        if (!primitive) oout.writeObject(data);
        else {
          if (data instanceof Boolean) oout.writeBoolean(((Boolean) data).booleanValue());
          else if (data instanceof Character) oout.writeChar(((Character) data).charValue());
          else if (data instanceof Byte) oout.writeByte(((Byte) data).byteValue());
          else if (data instanceof Short) oout.writeShort(((Short) data).shortValue());
          else if (data instanceof Integer) oout.writeInt(((Integer) data).intValue());
          else if (data instanceof Long) oout.writeLong(((Long) data).longValue());
        }
      }
      vec = null;
    }
    if (oout != null) oout.flush();
  }
Esempio n. 24
0
 public void writeExternal(final ObjectOutput out) throws IOException {
   for (int i = 0; i < _calls.length; i++) {
     out.writeShort(_calls[i]);
   }
 }
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(this.characterid);
    out.writeInt(this.accountid);
    out.writeUTF(this.accountname);
    out.writeByte(this.channel);
    out.writeInt(this.ACash);
    out.writeInt(this.MaplePoints);
    out.writeUTF(this.name);
    out.writeInt(this.fame);
    out.writeInt(this.love);
    out.writeByte(this.gender);
    out.writeShort(this.level);
    out.writeShort(this.str);
    out.writeShort(this.dex);
    out.writeShort(this.int_);
    out.writeShort(this.luk);
    out.writeInt(this.hp);
    out.writeInt(this.mp);
    out.writeInt(this.maxhp);
    out.writeInt(this.maxmp);
    out.writeLong(this.exp);
    out.writeShort(this.hpApUsed);
    out.writeShort(this.remainingAp);
    out.writeShort(this.remainingSp);
    out.writeLong(this.meso);
    out.writeByte(this.skinColor);
    out.writeShort(this.job);
    out.writeInt(this.hair);
    out.writeInt(this.face);
    out.writeInt(this.mapid);
    out.writeByte(this.initialSpawnPoint);
    out.writeByte(this.world);
    out.writeInt(this.guildid);
    out.writeByte(this.guildrank);
    out.writeInt(this.guildContribution);
    out.writeByte(this.alliancerank);
    out.writeInt(this.sidekick);
    out.writeByte(this.gmLevel);
    out.writeInt(this.points);
    out.writeInt(this.vpoints);
    out.writeByte(this.BlessOfFairy == null ? 0 : 1);
    if (this.BlessOfFairy != null) {
      out.writeUTF(this.BlessOfFairy);
    }
    out.writeByte(this.BlessOfEmpress == null ? 0 : 1);
    if (this.BlessOfEmpress != null) {
      out.writeUTF(this.BlessOfEmpress);
    }
    out.writeByte(this.chalkboard == null ? 0 : 1);
    if (this.chalkboard != null) {
      out.writeUTF(this.chalkboard);
    }
    out.writeObject(this.skillmacro);
    out.writeLong(this.lastfametime);
    out.writeObject(this.storage);
    out.writeObject(this.pvpStats);
    out.writeObject(this.potionPot);
    out.writeObject(this.coreAura);
    out.writeObject(this.cs);
    out.writeObject(this.battlers);
    out.writeInt(this.mount_itemid);
    out.writeByte(this.mount_Fatigue);
    out.writeByte(this.mount_level);
    out.writeInt(this.mount_exp);
    out.writeInt(this.partyid);
    out.writeInt(this.messengerid);
    out.writeObject(this.inventorys);
    out.writeByte(this.fairyExp);
    out.writeByte(this.subcategory);
    out.writeShort(this.fatigue);
    out.writeInt(this.marriageId);
    out.writeInt(this.familyid);
    out.writeInt(this.seniorid);
    out.writeInt(this.junior1);
    out.writeInt(this.junior2);
    out.writeInt(this.currentrep);
    out.writeInt(this.totalrep);
    out.writeInt(this.gachexp);
    out.writeInt(this.totalWins);
    out.writeInt(this.totalLosses);
    out.writeObject(this.anticheat);
    out.writeUTF(this.tempIP);
    out.writeInt(this.pvpExp);
    out.writeInt(this.pvpPoints);
    out.writeObject(this.antiMacro);
    out.writeInt(this.decorate);
    out.writeInt(this.beans);
    out.writeInt(this.warning);
    out.writeInt(this.dollars);
    out.writeInt(this.shareLots);
    out.writeInt(this.apstorage);
    out.writeInt(this.honor);
    out.writeInt(this.cardStack);
    out.writeInt(this.morphCount);
    out.writeInt(this.powerCount);
    out.writeInt(this.playerPoints);
    out.writeInt(this.playerEnergy);
    out.writeInt(this.pvpDeaths);
    out.writeInt(this.pvpKills);
    out.writeInt(this.pvpVictory);
    out.writeInt(this.runningDark);
    out.writeInt(this.runningDarkSlot);
    out.writeInt(this.runningLight);
    out.writeInt(this.runningLightSlot);

    out.writeShort(this.mbook.size());
    for (Map.Entry ms : this.mbook.entrySet()) {
      out.writeInt(((Integer) ms.getKey()));
      out.writeInt(((Integer) ms.getValue()));
    }

    out.writeShort(this.Skills.size());
    for (Map.Entry qs : this.Skills.entrySet()) {
      out.writeInt(((Integer) qs.getKey()));
      out.writeInt(((SkillEntry) qs.getValue()).skillLevel);
      out.writeByte(((SkillEntry) qs.getValue()).masterlevel);
      out.writeLong(((SkillEntry) qs.getValue()).expiration);
      out.writeInt(((SkillEntry) qs.getValue()).teachId);
      out.writeByte(((SkillEntry) qs.getValue()).position);
    }

    out.writeByte(this.buddysize);
    out.writeShort(this.buddies.size());
    for (Map.Entry qs : this.buddies.entrySet()) {
      out.writeInt(((CharacterNameAndId) qs.getKey()).getId());
      out.writeUTF(((CharacterNameAndId) qs.getKey()).getName());
      out.writeUTF(((CharacterNameAndId) qs.getKey()).getGroup());
      out.writeBoolean(((Boolean) qs.getValue()));
    }

    out.writeShort(this.Quest.size());
    for (Map.Entry qs : this.Quest.entrySet()) {
      out.writeInt(((Integer) qs.getKey()));
      out.writeObject(qs.getValue());
    }

    out.writeByte(this.reports.size());
    for (Map.Entry ss : this.reports.entrySet()) {
      out.writeByte(((Byte) ss.getKey()));
      out.writeInt(((Integer) ss.getValue()));
    }

    out.writeByte(this.finishedAchievements.size());
    for (Integer zz : this.finishedAchievements) {
      out.writeInt(zz);
    }

    out.writeByte(this.famedcharacters.size());
    for (Integer zz : this.famedcharacters) {
      out.writeInt(zz);
    }

    out.writeInt(this.battledaccs.size());
    for (Integer zz : this.battledaccs) {
      out.writeInt(zz);
    }

    out.writeByte(this.savedlocation.length);
    for (int zz : this.savedlocation) {
      out.writeInt(zz);
    }

    out.writeByte(this.wishlist.length);
    for (int zz : this.wishlist) {
      out.writeInt(zz);
    }

    out.writeByte(this.rocks.length);
    for (int zz : this.rocks) {
      out.writeInt(zz);
    }

    out.writeByte(this.regrocks.length);
    for (int zz : this.regrocks) {
      out.writeInt(zz);
    }

    out.writeByte(this.hyperrocks.length);
    for (int zz : this.hyperrocks) {
      out.writeInt(zz);
    }

    out.writeShort(this.KeyValue.size());
    for (Map.Entry key : this.KeyValue.entrySet()) {
      out.writeUTF((String) key.getKey());
      out.writeUTF((String) key.getValue());
    }

    out.writeShort(this.InfoQuest.size());
    for (Map.Entry qs : this.InfoQuest.entrySet()) {
      out.writeInt(((Integer) qs.getKey()));
      out.writeUTF((String) qs.getValue());
    }

    out.writeInt(this.keymap.size());
    for (Map.Entry qs : this.keymap.entrySet()) {
      out.writeInt(((Integer) qs.getKey()));
      out.writeByte(((Byte) ((Pair) qs.getValue()).left));
      out.writeInt(((Integer) ((Pair) qs.getValue()).right));
    }

    out.writeInt(this.quickslot.size());
    for (Pair qs : this.quickslot) {
      out.writeInt(((Integer) qs.getLeft()));
      out.writeInt(((Integer) qs.getRight()));
    }

    out.writeShort(this.familiars.size());
    for (Map.Entry qs : this.familiars.entrySet()) {
      out.writeInt(((Integer) qs.getKey()));
      MonsterFamiliar f = (MonsterFamiliar) qs.getValue();
      out.writeInt(f.getId());
      out.writeInt(f.getFamiliar());
      out.writeLong(f.getExpiry());
      out.writeUTF(f.getName());
      out.writeInt(f.getFatigue());
      out.writeByte(f.getVitality());
    }

    out.writeByte(this.petStore);

    out.writeShort(this.boxed.size());
    for (Object boxed1 : this.boxed) {
      out.writeObject(boxed1);
    }

    out.writeShort(this.rebuy.size());
    for (MapleShopItem rebuy1 : this.rebuy) {
      out.writeObject(rebuy1);
    }

    out.writeByte(this.imps.length);
    for (MapleImp imp : this.imps) {
      if (imp != null) {
        out.writeByte(1);
        out.writeInt(imp.getItemId());
        out.writeShort(imp.getFullness());
        out.writeShort(imp.getCloseness());
        out.writeByte(imp.getState());
        out.writeByte(imp.getLevel());
      } else {
        out.writeByte(0);
      }
    }

    out.writeLong(this.lastLoveTime);
    out.writeByte(this.loveCharacters.size());
    for (Map.Entry loves : this.loveCharacters.entrySet()) {
      out.writeInt(((Integer) loves.getKey()));
      out.writeLong(((Long) loves.getValue()));
    }
  }
Esempio n. 26
0
 public void writeShort(int i) throws IOException {
   oo.writeShort(i);
 }
 @Override
 protected void writeObject(ObjectOutput out, Object obj) throws IOException {
   out.writeShort(((Short) obj).shortValue());
 }