コード例 #1
0
  public boolean checkForParams(final ParsedURL purl) {
    if (params != null) {
      HashMap<String, String> purlParams = purl.extractParams(true);
      for (MetaMetadataSelectorParam param : params) {
        String paramName = param.getName();
        String paramValue = param.getValue();
        String paramValueIsNot = param.getValueIsNot();
        String actualValue = purlParams == null ? null : purlParams.get(paramName);
        if (actualValue == null) {
          actualValue = "";
        }

        if (paramValue != null && paramValue.length() > 0) {

          boolean allowEmptyAndIsEmpty = param.isAllowEmptyValue() && actualValue.length() == 0;
          if (!allowEmptyAndIsEmpty && !paramValue.equals(actualValue)) {
            return false;
          }
        }

        if (paramValueIsNot != null && paramValueIsNot.length() > 0) {
          if (paramValueIsNot.equals(actualValue)) {
            return false;
          }
        }
      }
    }
    return true;
  }
コード例 #2
0
 @Override
 public Object operateOn(Object rawValue) {
   if (rawValue != null && name != null && value != null) {
     ParsedURL purl =
         (rawValue instanceof ParsedURL)
             ? ((ParsedURL) rawValue)
             : ParsedURL.getAbsolute(rawValue.toString());
     HashMap<String, String> params = purl.extractParams(true);
     if (!onlyWhenNotSet || !params.containsKey(name)) {
       params.put(name, value);
     }
     return purl.updateParams(params);
   }
   return rawValue;
 }