class URLDecodeOperation implements EventOperation {

  @Override
  public InternalEvent perform(InternalEvent ievent) {
    if (ievent == null || ievent.getEventObj() == null
        || ievent.getEventObj().getPayload() == null) {
      return ievent;
    }

    for (String fieldName : fieldNames) {
      /*
       * Get field value
       */
      String value = null;
      try {
        value = ievent.getEventObj().getFieldAsString(fieldName);
      } catch (FieldNotFoundException e) {
        continue;
      }

      if (value == null) {
        return ievent;
      }

      /*
       * Perform decode multiple times if required.
       */
      try {
        for (int i = 0; i < this.times; i++) {
          value = codec.decode(value);
        }
      } catch (DecoderException e) {
        continue;
      }

      /*
       * Update value
       */
      try {
        ievent.getEventObj().setField(fieldName, value);
      } catch (FieldNotFoundException e) {
        throw new OperationException("failed to update original field in URL decode");
      }
    }

    return ievent;
  }

  public  URLDecodeOperation(List<String> fieldNames, int times);

}