Exemple #1
0
  /**
   * constructs HooMEResponse from input stream
   *
   * @param in deserialization input source
   * @throws java.io.IOException if I/O problem
   * @throws BadAttributeValueException if bad data value
   */
  public HooMEResponse(MessageInput in) throws java.io.IOException, BadAttributeValueException {
    super(in);
    this.resultList = new ArrayList<Result>();
    int payloadLength = HooMEUtilities.getUnsignedInt(in.getScanner().readShort());
    long expecting = 0;
    byte rawMatches = in.getScanner().readByte();
    int mul = 8; // cobined size in octets of file id and size for every result
    short rawPort = in.getScanner().readShort();
    byte[] addressArray = new byte[Consts.FOUR_BITS];

    for (int i = 0; i < Consts.FOUR_BITS; i++) {
      addressArray[i] = in.getScanner().readByte();
    }
    this.setResponseHost(
        new InetSocketAddress(
            InetAddress.getByAddress(addressArray), HooMEUtilities.getUnsignedInt(rawPort)));
    long matches = HooMEUtilities.getUnsignedLongInt(rawMatches);
    expecting = (mul * matches);
    for (long i = 0; i < matches; i++) {
      Result aResult = new Result(in);
      // check to see if we have exceeded the specified payload length and throw exception
      if ((aResult.getFileName().length() + expecting) > payloadLength
          || (aResult.getFileName().length() + expecting) > Consts.MAX_UNSIGNED_SHORT) {
        throw new BadAttributeValueException(Consts.ILL_ARG);
      } else {
        expecting += aResult.getFileName().length();
        this.addResult(aResult);
      }
    }
  }
Exemple #2
0
 /**
  * constructs HooMESearch from inputstream
  *
  * @param in input steam
  * @throws java.io.IOException if i/o error occurs
  * @throws BadAttributeValueException if bad attribute value
  */
 public HooMESearch(MessageInput in) throws java.io.IOException, BadAttributeValueException {
   super(in);
   // read in the payload length
   int payloadLength = HooMEUtilities.getUnsignedInt(in.getScanner().readShort());
   this.setSearchString((in.readString()));
   if (this.searchString.length() + 1 > payloadLength) {
     throw new BadAttributeValueException(Consts.ILL_ARG);
   }
 }
  public void processMessage() {

    input.setMessageInput(output.toString());
    System.out.println(output.getMessage());
  }
Exemple #4
0
 public void getMessage() {
   output.outputMessage(input.getMessageInput());
 }