Example #1
0
  /**
   * Method responsible for receiving messages from the Server, reading information from the
   * DataInputStream.
   *
   * @param in The DataInputStream where we are going to read the information about the idea.
   * @return A boolean value, indicating the success or failure of the operation.
   */
  public boolean readFromDataStream(DataInputStream in) {

    if ((this.id = Common.recvInt(in)) == -1) return false;
    if ((this.uid = Common.recvInt(in)) == -1) return false;
    if ((this.title = Common.recvString(in)) == null) return false;
    if ((this.body = Common.recvString(in)) == null) return false;
    if ((this.file = Common.recvString(in)) == null) return false;
    if ((this.shares_to_buy = Common.recvInt(in)) == -1) return false;
    if ((this.numSharesOwned = Common.recvInt(in)) == -1) return false;
    if ((this.percentOwned = Common.recvFloat(in)) == -1) return false;

    int tmp;
    if ((tmp = Common.recvInt(in)) == -1) return false;
    this.inWatchList = tmp == 1;

    if ((this.sellingPrice = Common.recvFloat(in)) == -1) return false;
    if ((this.marketValue = Common.recvFloat(in)) == -1) return false;
    if ((this.facebookId = Common.recvInt(in)) == -1) return false;

    return true;
  }
Example #2
0
  /**
   * Method responsible for comunicating with the Server, writing information to the
   * DataOutputStream.
   *
   * @param out The DataOutputStream where we are going to write the information about the idea.
   * @return A boolean value, indicating the success or failure of the operation.
   */
  public boolean writeToDataStream(DataOutputStream out) {
    if (!Common.sendInt(id, out)) return false;
    if (!Common.sendInt(uid, out)) return false;
    if (!Common.sendString(title, out)) return false;
    if (!Common.sendString(body, out)) return false;
    if (!Common.sendString(file, out)) return false;
    if (!Common.sendInt(shares_to_buy, out)) return false;
    if (!Common.sendInt(numSharesOwned, out)) return false;
    if (!Common.sendFloat(percentOwned, out)) return false;
    if (!Common.sendInt(inWatchList ? 1 : 0, out)) return false;
    if (!Common.sendFloat(sellingPrice, out)) return false;
    if (!Common.sendFloat(marketValue, out)) return false;
    if (!Common.sendInt(facebookId, out)) return false;

    return true;
  }