Exemplo n.º 1
0
  /**
   * Convert the ImageInfo (renamed ImageData) object into bytes so we can store it in RMS Order of
   * the string will look like this: <recordId>*<foreignRecordId>*<labelName>*<imageLabel> Depending
   * on the optional features, additional fields may be: <phoneNum>
   *
   * @throws InvalidImageDataException
   */
  public byte[] getBytesFromImageInfo(ImageData ii) throws InvalidImageDataException {

    // Take each String and get the bytes from it, separating fields with a
    // delimiter
    try {
      String byteString = new String();

      // Convert the record ID for this record
      int i = ii.getRecordId();
      Integer j = new Integer(i);
      byteString = byteString.concat(j.toString());
      byteString = byteString.concat(DELIMITER);

      // Convert the 'Foreign' Record ID field for the corresponding Image
      // record store
      int i2 = ii.getForeignRecordId();
      Integer j2 = new Integer(i2);
      byteString = byteString.concat(j2.toString());
      byteString = byteString.concat(DELIMITER);

      // Convert the album name field
      byteString = byteString.concat(ii.getParentAlbumName());
      byteString = byteString.concat(DELIMITER);

      // Convert the label (name) field
      byteString = byteString.concat(ii.getImageLabel());

      // Convert the phone number field
      return byteString.getBytes();
    } catch (Exception e) {
      throw new InvalidImageDataException("The provided data are not valid");
    }
  }