Create a new Query Template.

@param name of the query parameter.
@param values in the template.
@param charset for the template.
@param collectionFormat to use.
@return a QueryTemplate
339939
public static QueryTemplate create(String name,
                                     Iterable<String> values,
                                     Charset charset,
                                     CollectionFormat collectionFormat) {
    if (Util.isBlank(name)) {
      throw new IllegalArgumentException("name is required.");
    }

    if (values == null) {
      throw new IllegalArgumentException("values are required");
    }

    /* remove all empty values from the array */
    Collection<String> remaining = StreamSupport.stream(values.spliterator(), false)
        .filter(Util::isNotBlank)
        .collect(Collectors.toList());

    StringBuilder template = new StringBuilder();
    Iterator<String> iterator = remaining.iterator();
    while (iterator.hasNext()) {
      template.append(iterator.next());
      if (iterator.hasNext()) {
        template.append(COLLECTION_DELIMITER);
      }
    }

    return new QueryTemplate(template.toString(), name, remaining, charset, collectionFormat);
  }
38713
private void parseTemplate() {
    /*
     * query string and path literals have different reserved characters and different encoding
     * requirements. to ensure compliance with RFC 6570, we'll need to encode query literals
     * differently from path literals. let's look at the template to see if it contains a query
     * string and if so, keep track of where it starts.
     */
    Matcher queryStringMatcher = QUERY_STRING_PATTERN.matcher(this.template);
    if (queryStringMatcher.find()) {
      /*
       * the template contains a query string, split the template into two parts, the path and query
       */
      String path = this.template.substring(0, queryStringMatcher.start());
      String query = this.template.substring(queryStringMatcher.end() - 1);
      this.parseFragment(path, false);
      this.parseFragment(query, true);
    } else {
      /* parse the entire template */
      this.parseFragment(this.template, false);
    }
  }
925092
public String getQueryString(MultiValueMap<String, String> params) {
		if (params.isEmpty()) {
			return "";
		}
		StringBuilder query = new StringBuilder();
		Map<String, Object> singles = new HashMap<>();
		for (String param : params.keySet()) {
			int i = 0;
			for (String value : params.get(param)) {
				query.append("&");
				query.append(param);
				if (!"".equals(value)) { // don't add =, if original is ?wsdl, output is
					// not ?wsdl=
					String key = param;
					// if form feed is already part of param name double
					// since form feed is used as the colon replacement below
					if (key.contains("\f")) {
						key = (FORM_FEED_PATTERN.matcher(key).replaceAll("\f\f"));
					}
					// colon is special to UriTemplate
					if (key.contains(":")) {
						key = COLON_PATTERN.matcher(key).replaceAll("\f");
					}
					key = key + i;
					singles.put(key, value);
					query.append("={");
					query.append(key);
					query.append("}");
				}
				i++;
			}
		}

		UriTemplate template = new UriTemplate("?" + query.toString().substring(1));
		return template.expand(singles).toString();
	}
289717
@SuppressWarnings("unchecked")
    protected <A, Q extends SimpleExpression<? super A>> CollectionPath<A, Q> createCollection(String property, Class<? super A> type, Class<? super Q> queryType, PathInits inits) {
        return add(new CollectionPath<A, Q>(type, (Class) queryType, forProperty(property), inits));
    }
120561
public T queryString(String name, String value) {
        List<String> l = queryString.get(name);
        if (l == null) {
            l = new ArrayList<String>();
        }
        l.add(value);
        queryString.put(name, l);
        return derived.cast(this);
    }
1068099
public Query addParameter(String name, final Collection<?> values) {
        if(values == null) {
            throw new NullPointerException("Array parameter cannot be null");
        }

        return addParameter(name, values.toArray());
    }
538596
public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, List<?> args) {
        return template(cl, TemplateFactory.DEFAULT.create(template), args);
    }
261517
protected Collection<Pattern> createPatternForMappedAttribute(final String attributeName) {
        val matchingPattern = patterns.get(attributeName).toString();
        val pattern = RegexUtils.createPattern(matchingPattern, this.caseInsensitive ? Pattern.CASE_INSENSITIVE : 0);
        LOGGER.debug("Created pattern for mapped attribute filter [{}]", pattern.pattern());
        return CollectionUtils.wrap(pattern);
    }
613010
@Override
    public EbeanQueryWrapper doCreateQuery(Object[] values) {
        ParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(), values);

        EbeanQueryWrapper query = createEbeanQuery(this.query.getQueryString());

        return createBinder(values).bindAndPrepare(query);
    }
573267
public function generateFilter($name, $value, $documentName='', $format='')
    {
        $collection = $this->documentManager->getDocumentCollection($documentName);
        $collectionName = $collection->getName();
        $dataBase = $this->documentManager->getDocumentDatabase($documentName);
        $key = $name.'.*';
        $value = new \MongoRegex('/.*'.$value.'.*/i');
        $filter = $this->generateCriteria($key, $value, $collectionName, $dataBase);

        if (!empty($filter)) {

            return array('$or' => $filter);
        }

        return null;
    }
831794
public static String expand(final String templateString, Map<String, Object> values)
    throws MalformedUriTemplateException, VariableExpansionException
    {
        UriTemplate t = new UriTemplate(templateString);
        t.set(values);
        return t.expand();
    }
736458
@SuppressWarnings("unchecked")
  @Override
  public <T> List<T> find(String jxQuery, String collectionName) {
    CollectionMetaData cmd = cmdMap.get(collectionName);
    Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
    if((null == cmd) || (null == collection)) {
      throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
    }
    cmd.getCollectionLock().readLock().lock();
    try {
      JXPathContext context = contextsRef.get().get(collectionName);
      Iterator<T> resultItr = context.iterate(jxQuery);
      List<T> newCollection = new ArrayList<T>();
      while (resultItr.hasNext()) {
        T document = resultItr.next();
        Object obj = Util.deepCopy(document);
        if(encrypted && cmd.hasSecret() && null != obj) {
          CryptoUtil.decryptFields(obj, cmd, dbConfig.getCipher());
        }
        newCollection.add((T) obj);
      }
      return newCollection;
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
      logger.error("Error when decrypting value for a @Secret annotated field for entity: " + collectionName, e);
      throw new JsonDBException("Error when decrypting value for a @Secret annotated field for entity: " + collectionName, e);
    } finally {
      cmd.getCollectionLock().readLock().unlock();
    }
  }
1238816
public static <T extends Comparable<?>> DateTemplate<T> dateTemplate(Class<? extends T> cl, String template, List<?> args) {
        return dateTemplate(cl, createTemplate(template), args);
    }
921293
public Template getTemplate(final String name) throws ResourceNotFoundException {
        final Template template = this.cachedTemplates.get(name);
        if (template != null) {
            return template;
        }
        return createTemplateIfAbsent(name);
    }
435718
public static String format(ITemplate template, Number number, String pattern, Locale locale) {
        if (null == number) {
            throw new NullPointerException();
        }
        if (null == locale) {
            locale = I18N.locale(template);
        }
        
        NumberFormat nf;
        if (null == pattern) nf = NumberFormat.getNumberInstance(locale);
        else {
            DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
            nf = new DecimalFormat(pattern, symbols);
        }
        
        return nf.format(number);
    }
129763
public void buildInSqlByCollection(String fieldText, Collection<Object> values) {
        super.buildInSql(fieldText, values == null ? null : values.toArray());
    }
254497
public Model findOrCreateTemplate(String name, InputStream modelJson) throws IOException {
        try {
            Model m = getTemplateByName(name);
            return m;
        } catch (IllegalArgumentException ignore) {
        }

        String modelStr = IOUtils.toString(modelJson, "UTF-8");
        return modelService.createModel(new TypedString(modelStr));
    }