class NpmSearchParameterExtractor extends ComponentSupport {

  public int extractFrom(final Parameters parameters) {
    int from = 0;
    String fromParameter = Strings.nullToEmpty(parameters.get("from")).trim();
    if (!fromParameter.isEmpty()) {
      try {
        from = Integer.parseInt(fromParameter);
      }
      catch (NumberFormatException e) {
        log.debug("Invalid from encountered in search parameters {}, using default", parameters, e);
      }
      if (from < 0) {
        from = 0;
      }
    }
    return from;
  }

}