示例#1
0
  public static Map<String, Object> getFieldMatchingPattern(LocalDocument doc, String pattern) {
    Map<String, Object> fieldToUrl = new HashMap<String, Object>();

    for (String field : doc.getContentFields()) {
      Pattern p = Pattern.compile(pattern);
      Matcher m = p.matcher(field);
      if (m.matches()) {
        String toField;
        if (m.groupCount() >= 1) {
          toField = m.group(1);
        } else {
          toField = m.group();
        }
        Logger.debug("Added " + doc.getContentField(field) + " to " + toField);
        fieldToUrl.put(toField, doc.getContentField(field));
      }
    }

    return fieldToUrl;
  }