Example #1
1
  /**
   * Reads the payload of a tag, given the name and type.
   *
   * @param type The type.
   * @param name The name.
   * @param depth The depth.
   * @return The tag.
   * @throws IOException if an I/O error occurs.
   */
  private Tag readTagPayload(int type, String name, int depth) throws IOException {
    switch (type) {
      case NBTConstants.TYPE_END:
        if (depth == 0) {
          throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
        } else {
          return new EndTag();
        }
      case NBTConstants.TYPE_BYTE:
        return new ByteTag(name, is.readByte());
      case NBTConstants.TYPE_SHORT:
        return new ShortTag(name, is.readShort());
      case NBTConstants.TYPE_INT:
        return new IntTag(name, is.readInt());
      case NBTConstants.TYPE_LONG:
        return new LongTag(name, is.readLong());
      case NBTConstants.TYPE_FLOAT:
        return new FloatTag(name, is.readFloat());
      case NBTConstants.TYPE_DOUBLE:
        return new DoubleTag(name, is.readDouble());
      case NBTConstants.TYPE_BYTE_ARRAY:
        int length = is.readInt();
        byte[] bytes = new byte[length];
        is.readFully(bytes);
        return new ByteArrayTag(name, bytes);
      case NBTConstants.TYPE_STRING:
        length = is.readShort();
        bytes = new byte[length];
        is.readFully(bytes);
        return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
      case NBTConstants.TYPE_LIST:
        int childType = is.readByte();
        length = is.readInt();

        List<Tag> tagList = new ArrayList<Tag>();
        for (int i = 0; i < length; i++) {
          Tag tag = readTagPayload(childType, "", depth + 1);
          if (tag instanceof EndTag) {
            throw new IOException("TAG_End not permitted in a list.");
          }
          tagList.add(tag);
        }

        return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
      case NBTConstants.TYPE_COMPOUND:
        Map<String, Tag> tagMap = new HashMap<String, Tag>();
        while (true) {
          Tag tag = readTag(depth + 1);
          if (tag instanceof EndTag) {
            break;
          } else {
            tagMap.put(tag.getName(), tag);
          }
        }

        return new CompoundTag(name, tagMap);
      default:
        throw new IOException("Invalid tag type: " + type + ".");
    }
  }
  /**
   * generate schema automatically
   *
   * @throws IOException
   */
  private MessageType autoGenSchema(DataInputStream dis) throws IOException {
    dis.readInt(); // skip schema-head length

    short version = dis.readShort();
    if (version != GPDBWritable.SCHEMA_VERSION) {
      throw new IOException("schema version mismatched, should: 2 now:" + version);
    }

    int tableNameLen = dis.readInt();
    byte[] tableNameBytes = new byte[tableNameLen];
    dis.readFully(tableNameBytes);
    String tableName = new String(tableNameBytes);

    MessageTypeBuilder typeBuilder = Types.buildMessage();

    int colCount = dis.readInt();
    List<Type> fields = new ArrayList<Type>();
    for (int i = 0; i < colCount; i++) {
      int colLen = dis.readInt();
      byte[] colName = new byte[colLen];
      dis.readFully(colName);

      int colType = dis.readInt();
      int notNull = dis.readByte();
      int ndims = dis.readInt();
      char delim = (char) dis.readByte();

      columnSchemas.add(new ColumnSchema(new String(colName), colType, notNull, ndims, delim));
      fields.add(generateParquetType(new String(colName), colType, notNull, ndims));
    }

    return new MessageType(tableName, fields);
  }
 private byte[] readPacket() throws IOException {
   byte[] reslutPacket = null;
   byte p_head, p_type;
   byte[] p_lenByte = new byte[4];
   int p_lenInt;
   int index, buf;
   while (true) {
     try {
       p_head = in.readByte();
       if (p_head == ProtocolVar.PacketType.PACKET_HEAD) {
         p_type = in.readByte();
         in.read(p_lenByte);
         p_lenInt = (int) ConvertTools.byteArrToLong_littleEnd(p_lenByte, 0);
         reslutPacket = new byte[p_lenInt];
         reslutPacket[0] = p_head;
         reslutPacket[1] = p_type;
         ConvertTools.copyByteArr(p_lenByte, reslutPacket, 0, 2, 4);
         index = 6;
         /** 直到收到所有数据 */
         while (index < p_lenInt) {
           if (in.available() != 0) {
             buf = in.read(reslutPacket, index, p_lenInt - index);
             if (buf != -1) {
               index += buf;
             }
           }
         }
         break;
       }
     } catch (ArrayIndexOutOfBoundsException ex) {
       Logger.getLogger(CameraTask.class.getName()).log(Level.INFO, devSeqStr, ex);
     }
   }
   return reslutPacket;
 }
Example #4
0
 /**
  * Reads a byte stream, which was written by {@linkplain #writeTo(OutputStream)}, into a {@code
  * BloomFilter<T>}.
  *
  * <p>The {@code Funnel} to be used is not encoded in the stream, so it must be provided here.
  * <b>Warning:</b> the funnel provided <b>must</b> behave identically to the one used to populate
  * the original Bloom filter!
  *
  * @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
  *     appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
  */
 public static <T> BloomFilter<T> readFrom(InputStream in, Funnel<T> funnel) throws IOException {
   checkNotNull(in, "InputStream");
   checkNotNull(funnel, "Funnel");
   int strategyOrdinal = -1;
   int numHashFunctions = -1;
   int dataLength = -1;
   try {
     DataInputStream din = new DataInputStream(in);
     // currently this assumes there is no negative ordinal; will have to be updated if we
     // add non-stateless strategies (for which we've reserved negative ordinals; see
     // Strategy.ordinal()).
     strategyOrdinal = din.readByte();
     numHashFunctions = UnsignedBytes.toInt(din.readByte());
     dataLength = din.readInt();
     Strategy strategy = BloomFilterStrategies.values()[strategyOrdinal];
     long[] data = new long[dataLength];
     for (int i = 0; i < data.length; i++) {
       data[i] = din.readLong();
     }
     return new BloomFilter<T>(new BitArray(data), numHashFunctions, funnel, strategy);
   } catch (RuntimeException e) {
     IOException ioException =
         new IOException(
             "Unable to deserialize BloomFilter from InputStream."
                 + " strategyOrdinal: "
                 + strategyOrdinal
                 + " numHashFunctions: "
                 + numHashFunctions
                 + " dataLength: "
                 + dataLength);
     ioException.initCause(e);
     throw ioException;
   }
 }
 public void a(DataInputStream paramDataInputStream) {
   this.a = paramDataInputStream.readInt();
   this.e = paramDataInputStream.readByte();
   this.b = paramDataInputStream.readInt();
   this.c = paramDataInputStream.readByte();
   this.d = paramDataInputStream.readInt();
 }
  private BigInteger readBigIntegerData(DataInputStream in) throws IOException {
    int bitCount = in.readInt();
    throwIfNotEqual(MartusKeyPairDataConstants.BIGINTEGER_BIT_COUNT, bitCount);
    int bitLength = in.readInt();
    throwIfNotEqual(MartusKeyPairDataConstants.BIGINTEGER_BIT_LENGTH, bitLength);
    int firstNonZeroByteNum = in.readInt();
    throwIfNotEqual(
        MartusKeyPairDataConstants.BIGINTEGER_FIRST_NONZERO_BYTE_NUMBER, firstNonZeroByteNum);
    int lowestSetBit = in.readInt();
    throwIfNotEqual(MartusKeyPairDataConstants.BIGINTEGER_LOWEST_SET_BIT, lowestSetBit);
    int signum = in.readInt();
    throwIfNotEqual(MartusKeyPairDataConstants.BIGINTEGER_SIGNUM, signum);

    byte typeCode = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_ARRAY, typeCode);
    byte typeCodeRefFlag = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_REFERENCE, typeCodeRefFlag);
    int refbyteArrayClassHandle = in.readInt();
    throwIfNotEqual(byteArrayClassHandle, refbyteArrayClassHandle);
    nextHandle++;

    int arrayLength = in.readInt();

    byte[] magnitude = new byte[arrayLength];
    in.read(magnitude);

    int arrayEndDataFlag = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_ENDBLOCKDATA, arrayEndDataFlag);

    BigInteger gotBigInteger = new BigInteger(signum, magnitude);
    return gotBigInteger;
  }
  /**
   * Método auxiliar que gerar uma Coleção de Dados da Movimentação
   *
   * @param data
   * @return
   * @throws IOException
   */
  private Collection<DadosMovimentacao> gerarColecaoDadosMovimentacao(
      DataInputStream data, Long imei) throws IOException {
    Collection<DadosMovimentacao> dados = new ArrayList<DadosMovimentacao>();
    int imovel = data.read();
    while (imovel != -1) {

      byte[] b = new byte[4];
      b[0] = (byte) imovel;
      b[1] = (byte) data.read();
      b[2] = (byte) data.read();
      b[3] = (byte) data.read();

      dados.add(
          new DadosMovimentacao(
              new Integer(this.convertArrayByteToInt(b)),
              new Integer(data.readInt()),
              new Integer(data.readByte()),
              new Date(data.readLong()),
              imei,
              new Byte(data.readByte()),
              new Integer(data.readInt())));

      // System.out.println("imovel=" + data.read());
      imovel = data.read();
    }
    return dados;
  }
  private void readEmptyHashTableData(DataInputStream in) throws IOException {
    float loadFactor = in.readFloat();
    throwIfNotEqual(
        "loadfactor wrong?",
        MartusKeyPairDataConstants.HASHTABLE_LOADFACTOR,
        loadFactor,
        MartusKeyPairDataConstants.HASHTABLE_LOADFACTOR / 100);

    int threshold = in.readInt();
    throwIfNotEqual("threshold wrong?", MartusKeyPairDataConstants.HASHTABLE_THRESHOLD, threshold);

    byte hashTableBlockDataFlag = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_BLOCKDATA, hashTableBlockDataFlag);

    byte blockDataByteCount = in.readByte();
    throwIfNotEqual(
        "wrong block data byte count?",
        MartusKeyPairDataConstants.HASHTABLE_BYTE_COUNT,
        blockDataByteCount);

    // originalLength
    in.readInt();

    int elements = in.readInt();
    throwIfNotEqual(
        "Hashtable not empty?", MartusKeyPairDataConstants.HASHTABLE_NUMBER_OF_ELEMENTS, elements);

    byte hashTableEndDataFlag = in.readByte();
    throwIfNotEqual(ObjectStreamConstants.TC_ENDBLOCKDATA, hashTableEndDataFlag);
  }
Example #9
0
  private static String readString(DataInputStream dis) {
    byte[] bytes = new byte[MAX_SIZE];
    StringBuilder sb = new StringBuilder();
    try {
      byte b = dis.readByte();
      int i = -1;

      if (b == 10) b = dis.readByte();

      while (b != 32 && b != 10) {
        i++;
        bytes[i] = b;
        b = dis.readByte();
        if (i == 49) {
          sb.append(new String(bytes));
          i = -1;
          bytes = new byte[MAX_SIZE];
        }
      }
      sb.append(new String(bytes, 0, i + 1));

    } catch (IOException e) {
      e.printStackTrace();
    }
    String s = sb.toString();
    return s;
  }
Example #10
0
  public static void main(String[] args) throws IOException {
    // Create a FileOutputStream.
    FileOutputStream outputFile = new FileOutputStream("primitives.data");

    // Create a DataOutputStream which is chained to the FileOutputStream.
    DataOutputStream outputStream = new DataOutputStream(outputFile);

    // Write Java primitive values in binary representation:
    outputStream.writeBoolean(true);
    outputStream.writeChar('A'); // int written as Unicode char
    outputStream.writeByte(Byte.MAX_VALUE); // int written as 8-bits byte
    outputStream.writeShort(Short.MIN_VALUE); // int written as 16-bits short
    outputStream.writeInt(Integer.MAX_VALUE);
    outputStream.writeLong(Long.MIN_VALUE);
    outputStream.writeFloat(Float.MAX_VALUE);
    outputStream.writeDouble(Math.PI);

    // Close the output stream, which also closes the underlying stream.
    outputStream.flush();
    outputStream.close();

    // Create a FileInputStream.
    FileInputStream inputFile = new FileInputStream("primitives.data");

    // Create a DataInputStream which is chained to the FileInputStream.
    DataInputStream inputStream = new DataInputStream(inputFile);

    // Read the binary representation of Java primitive values
    // in the same order they were written out:
    boolean v = inputStream.readBoolean();
    char c = inputStream.readChar();
    byte b = inputStream.readByte();
    short s = inputStream.readShort();
    int i = inputStream.readInt();
    long l = inputStream.readLong();
    float f = inputStream.readFloat();
    double d = inputStream.readDouble();

    // Check for end of stream:
    try {
      int value = inputStream.readByte();
      System.out.println("More input: " + value);
    } catch (EOFException eofe) {
      System.out.println("End of stream");
    } finally {
      // Close the input stream, which also closes the underlying stream.
      inputStream.close();
    }

    // Write the values read to the standard input stream:
    System.out.println("Values read:");
    System.out.println(v);
    System.out.println(c);
    System.out.println(b);
    System.out.println(s);
    System.out.println(i);
    System.out.println(l);
    System.out.println(f);
    System.out.println(d);
  }
Example #11
0
 private static int readRGBA() throws IOException {
   byte r = dis.readByte();
   byte g = dis.readByte();
   byte b = dis.readByte();
   byte a = dis.readByte();
   return (a << 24) + (r << 16) + (g << 8) + b;
 }
Example #12
0
 @Override
 public void onPacketData(NetworkManager network, String channel, byte[] data) {
   DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data));
   int x;
   int y;
   int z;
   int typ;
   boolean hasStacks;
   int[] items = null;
   try {
     x = dis.readInt();
     y = dis.readInt();
     z = dis.readInt();
     typ = dis.readByte();
     hasStacks = dis.readByte() != 0;
     if (hasStacks) {
       items = new int[24];
       for (int i = 0; i < items.length; i++) {
         items[i] = dis.readInt();
       }
     }
   } catch (IOException e) {
     return;
   }
   World world = mod_IronChest.proxy.getCurrentWorld();
   TileEntity te = world.getBlockTileEntity(x, y, z);
   if (te instanceof TileEntityIronChest) {
     TileEntityIronChest icte = (TileEntityIronChest) te;
     icte.handlePacketData(typ, items);
   }
 }
 private int readClassFooter(DataInputStream in) throws IOException {
   byte superEndDataFlag = in.readByte();
   throwIfNotEqual(ObjectStreamConstants.TC_ENDBLOCKDATA, superEndDataFlag);
   byte superNoSuperFlag = in.readByte();
   throwIfNotEqual(ObjectStreamConstants.TC_NULL, superNoSuperFlag);
   // new handle
   return nextHandle++;
 }
 /** Abstract. Reads the raw packet data from the data stream. */
 public void readPacketData(DataInputStream par1DataInputStream) throws IOException {
   this.language = readString(par1DataInputStream, 7);
   this.renderDistance = par1DataInputStream.readByte();
   byte var2 = par1DataInputStream.readByte();
   this.chatVisisble = var2 & 7;
   this.chatColours = (var2 & 8) == 8;
   this.gameDifficulty = par1DataInputStream.readByte();
 }
 @Override
 public void read(DataInputStream in) throws IOException {
   this.id = in.readByte();
   this.type = in.readByte();
   this.name = IOUtils.readString(in);
   this.slots = in.readByte();
   this.useTitle = in.readBoolean();
 }
 @Override
 public void decode(DataInputStream in) throws IOException {
   x = in.readInt();
   y = in.readShort();
   z = in.readInt();
   instrumentType = in.readByte();
   pitch = in.readByte();
 }
Example #17
0
  public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException {
    ArrayList arraylist = null;

    for (byte byte0 = par0DataInputStream.readByte();
        byte0 != 127;
        byte0 = par0DataInputStream.readByte()) {
      if (arraylist == null) {
        arraylist = new ArrayList();
      }

      int i = (byte0 & 0xe0) >> 5;
      int j = byte0 & 0x1f;
      WatchableObject watchableobject = null;

      switch (i) {
        case 0:
          watchableobject = new WatchableObject(i, j, Byte.valueOf(par0DataInputStream.readByte()));
          break;

        case 1:
          watchableobject =
              new WatchableObject(i, j, Short.valueOf(par0DataInputStream.readShort()));
          break;

        case 2:
          watchableobject =
              new WatchableObject(i, j, Integer.valueOf(par0DataInputStream.readInt()));
          break;

        case 3:
          watchableobject =
              new WatchableObject(i, j, Float.valueOf(par0DataInputStream.readFloat()));
          break;

        case 4:
          watchableobject = new WatchableObject(i, j, Packet.readString(par0DataInputStream, 64));
          break;

        case 5:
          short word0 = par0DataInputStream.readShort();
          byte byte1 = par0DataInputStream.readByte();
          short word1 = par0DataInputStream.readShort();
          watchableobject = new WatchableObject(i, j, new ItemStack(word0, byte1, word1));
          break;

        case 6:
          int k = par0DataInputStream.readInt();
          int l = par0DataInputStream.readInt();
          int i1 = par0DataInputStream.readInt();
          watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
          break;
      }

      arraylist.add(watchableobject);
    }

    return arraylist;
  }
Example #18
0
 public void func_73267_a(DataInputStream p_73267_1_) throws IOException {
   this.field_73468_a = func_73282_a(p_73267_1_, 7);
   this.field_73466_b = p_73267_1_.readByte();
   byte var2 = p_73267_1_.readByte();
   this.field_73467_c = var2 & 7;
   this.field_73464_d = (var2 & 8) == 8;
   this.field_73465_e = p_73267_1_.readByte();
   this.field_82564_f = p_73267_1_.readBoolean();
 }
Example #19
0
 public static NSEC3PARAM parse(DataInputStream dis) throws IOException {
   byte hashAlgorithm = dis.readByte();
   byte flags = dis.readByte();
   int iterations = dis.readUnsignedShort();
   int saltLength = dis.readUnsignedByte();
   byte[] salt = new byte[saltLength];
   if (dis.read(salt) != salt.length && salt.length != 0) throw new IOException();
   return new NSEC3PARAM(hashAlgorithm, flags, iterations, salt);
 }
 private String readBigIntegerFieldReference(DataInputStream in) throws IOException {
   byte typeCode = in.readByte();
   String fieldName = in.readUTF();
   byte refFlag = in.readByte();
   int refBigIntStringHandle = in.readInt();
   throwIfNotEqual(MartusKeyPairDataConstants.FIELD_TYPE_CODE_OBJECT, typeCode);
   throwIfNotEqual(ObjectStreamConstants.TC_REFERENCE, refFlag);
   throwIfNotEqual(bigIntStringHandle, refBigIntStringHandle);
   return fieldName;
 }
 private int readBigIntegerObjectHeader(DataInputStream in) throws IOException {
   int publicExponentObjectFlag = in.readByte();
   throwIfNotEqual(ObjectStreamConstants.TC_OBJECT, publicExponentObjectFlag);
   int refFlag = in.readByte();
   throwIfNotEqual(ObjectStreamConstants.TC_REFERENCE, refFlag);
   int refBigIntClassHandle = in.readInt();
   throwIfNotEqual(bigIntClassHandle, refBigIntClassHandle);
   int thisHandle = nextHandle++;
   return thisHandle;
 }
Example #22
0
 @Override
 public void read(DataInputStream in) throws IOException {
   this.entityId = in.readInt();
   this.levelType = IOUtils.readString(in);
   this.gameMode = in.readByte();
   this.dimension = in.readByte();
   this.difficulty = in.readByte();
   this.unused = in.readByte();
   this.maxPlayers = in.readByte();
 }
Example #23
0
 public void readPacketData(DataInputStream datainputstream) throws IOException {
   entityId = datainputstream.readInt();
   type = datainputstream.readByte();
   xPosition = datainputstream.readInt();
   yPosition = datainputstream.readInt();
   zPosition = datainputstream.readInt();
   yaw = datainputstream.readByte();
   pitch = datainputstream.readByte();
   receivedMetadata = DataWatcher.readWatchableObjects(datainputstream);
 }
Example #24
0
  public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException {
    ArrayList var1 = null;

    for (byte var2 = par0DataInputStream.readByte();
        var2 != 127;
        var2 = par0DataInputStream.readByte()) {
      if (var1 == null) {
        var1 = new ArrayList();
      }

      int var3 = (var2 & 224) >> 5;
      int var4 = var2 & 31;
      WatchableObject var5 = null;

      switch (var3) {
        case 0:
          var5 = new WatchableObject(var3, var4, Byte.valueOf(par0DataInputStream.readByte()));
          break;

        case 1:
          var5 = new WatchableObject(var3, var4, Short.valueOf(par0DataInputStream.readShort()));
          break;

        case 2:
          var5 = new WatchableObject(var3, var4, Integer.valueOf(par0DataInputStream.readInt()));
          break;

        case 3:
          var5 = new WatchableObject(var3, var4, Float.valueOf(par0DataInputStream.readFloat()));
          break;

        case 4:
          var5 = new WatchableObject(var3, var4, Packet.readString(par0DataInputStream, 64));
          break;

        case 5:
          short var9 = par0DataInputStream.readShort();
          byte var10 = par0DataInputStream.readByte();
          short var11 = par0DataInputStream.readShort();
          var5 = new WatchableObject(var3, var4, new ItemStack(var9, var10, var11));
          break;

        case 6:
          int var6 = par0DataInputStream.readInt();
          int var7 = par0DataInputStream.readInt();
          int var8 = par0DataInputStream.readInt();
          var5 = new WatchableObject(var3, var4, new ChunkCoordinates(var6, var7, var8));
      }

      var1.add(var5);
    }

    return var1;
  }
Example #25
0
 @Override
 public void read(DataInputStream stream) throws IOException {
   this.eid = stream.readInt();
   this.item = new ItemStack(stream.readShort(), stream.readByte(), stream.readShort());
   this.x = stream.readInt();
   this.y = stream.readInt();
   this.z = stream.readInt();
   this.rotation = stream.readByte();
   this.pitch = stream.readByte();
   this.roll = stream.readByte();
 }
 private String readArrayFieldDecription(DataInputStream in) throws IOException {
   byte typeCode = in.readByte();
   throwIfNotEqual(MartusKeyPairDataConstants.FIELD_TYPE_CODE_ARRAY, typeCode);
   String fieldName = in.readUTF();
   byte vecString = in.readByte();
   throwIfNotEqual(ObjectStreamConstants.TC_STRING, vecString);
   String fieldClassName = in.readUTF();
   throwIfNotEqual(MartusKeyPairDataConstants.LJAVA_LANG_OBJECT_CLASS_NAME, fieldClassName);
   nextHandle++;
   return fieldName;
 }
Example #27
0
  public static List a(DataInputStream datainputstream) {
    ArrayList arraylist = null;

    for (byte b0 = datainputstream.readByte(); b0 != 127; b0 = datainputstream.readByte()) {
      if (arraylist == null) {
        arraylist = new ArrayList();
      }

      int i = (b0 & 224) >> 5;
      int j = b0 & 31;
      WatchableObject watchableobject = null;

      switch (i) {
        case 0:
          watchableobject = new WatchableObject(i, j, Byte.valueOf(datainputstream.readByte()));
          break;

        case 1:
          watchableobject = new WatchableObject(i, j, Short.valueOf(datainputstream.readShort()));
          break;

        case 2:
          watchableobject = new WatchableObject(i, j, Integer.valueOf(datainputstream.readInt()));
          break;

        case 3:
          watchableobject = new WatchableObject(i, j, Float.valueOf(datainputstream.readFloat()));
          break;

        case 4:
          watchableobject = new WatchableObject(i, j, Packet.a(datainputstream, 64));
          break;

        case 5:
          short short1 = datainputstream.readShort();
          byte b1 = datainputstream.readByte();
          short short2 = datainputstream.readShort();

          watchableobject = new WatchableObject(i, j, new ItemStack(short1, b1, short2));
          break;

        case 6:
          int k = datainputstream.readInt();
          int l = datainputstream.readInt();
          int i1 = datainputstream.readInt();

          watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
      }

      arraylist.add(watchableobject);
    }

    return arraylist;
  }
 private String readByteArrayFieldDescription(DataInputStream in) throws IOException {
   byte typeCode = in.readByte();
   throwIfNotEqual(MartusKeyPairDataConstants.FIELD_TYPE_CODE_ARRAY, typeCode);
   String fieldName = in.readUTF();
   int refFlag = in.readByte();
   throwIfNotEqual(ObjectStreamConstants.TC_STRING, refFlag);
   String fieldClassName = in.readUTF();
   throwIfNotEqual(MartusKeyPairDataConstants.BYTE_ARRAY_FIELD_NAME, fieldClassName);
   // new handle
   nextHandle++;
   return fieldName;
 }
Example #29
0
  public int ReadCInt(DataInputStream data) throws IOException {
    int dado;
    int b1 = data.readByte();
    int b2 = data.readByte();
    int b3 = data.readByte();
    int b4 = data.readByte();

    return dado =
        ((int) b1 & 0x00ff)
            | (((int) b2 & 0x00ff) << 8)
            | (((int) b3 & 0x00ff) << 16)
            | (((int) b4 & 0x00ff) << 24);
  }
Example #30
0
  static Ship load(DataInputStream din) throws IOException {
    byte t = din.readByte();
    String name = din.readUTF();
    byte crew = din.readByte();
    Ship ship = new Ship(t, name, crew);
    ship.dock = din.readUTF();
    if (ship.dock.length() == 0) ship.dock = null;

    byte cargoCount = din.readByte();
    for (int c = 0; c < cargoCount; c++) ship.addCargo(din.readByte());

    return ship;
  }