/**
   * @param step the step to run
   * @param xStream used to convert a string to declared stepdef arguments
   * @return an Array matching the types or {@code parameterTypes}, or an array of String if {@code
   *     parameterTypes} is null
   */
  private Object[] transformedArgs(Step step, LocalizedXStreams.LocalizedXStream xStream) {
    int argumentCount = getArguments().size();

    if (step.getRows() != null) {
      argumentCount++;
    } else if (step.getDocString() != null) {
      argumentCount++;
    }
    Integer parameterCount = stepDefinition.getParameterCount();
    if (parameterCount != null && argumentCount != parameterCount) {
      throw arityMismatch(parameterCount);
    }

    List<Object> result = new ArrayList<Object>();

    int n = 0;
    for (Argument a : getArguments()) {
      ParameterInfo parameterInfo = getParameterType(n, String.class);
      Object arg = parameterInfo.convert(a.getVal(), xStream);
      result.add(arg);
      n++;
    }

    if (step.getRows() != null) {
      result.add(tableArgument(step, n, xStream));
    } else if (step.getDocString() != null) {
      result.add(step.getDocString().getValue());
    }
    return result.toArray(new Object[result.size()]);
  }
 private List<Argument> createArgumentsForErrorMessage(Step step) {
   List<Argument> arguments = new ArrayList<Argument>(getArguments());
   if (step.getDocString() != null) {
     arguments.add(new Argument(-1, "DocString:" + step.getDocString().getValue()));
   }
   if (step.getRows() != null) {
     List<List<String>> rows =
         map(
             step.getRows(),
             new Mapper<DataTableRow, List<String>>() {
               @Override
               public List<String> map(DataTableRow row) {
                 return row.getCells();
               }
             });
     arguments.add(new Argument(-1, "Table:" + rows.toString()));
   }
   return arguments;
 }