<commit_before>package org.basex.http.restxq;

import static org.basex.http.restxq.RestXqText.*;
import static org.basex.query.QueryText.*;
import static org.basex.util.Token.*;

import java.util.*;
import java.util.regex.*;

import org.basex.http.*;
import org.basex.query.util.inspect.*;
import org.basex.query.value.item.*;
import org.basex.query.value.node.*;
import org.basex.query.var.*;
import org.basex.util.hash.*;
import org.basex.util.list.*;

/**
 * This class returns a Web Application Description Language (WADL) file,
 * listing all available RESTXQ services.
 *
 * @author BaseX Team 2005-13, BSD License
 * @author <NAME>
 */
final class RestXqWadl {
  /** HTTP context. */
  private final HTTPContext http;

  /**
   * Constructor.
   * @param hc HTTP context
   */
  RestXqWadl(final HTTPContext hc) {
    http = hc;
  }

  /**
   * Returns a WADL description for all available URIs.
   * @param modules available modules
   * @return WADL description
   */
  synchronized FElem create(final HashMap<String, RestXqModule> modules) {
    // create root nodes
    final FElem application = new FElem(WADL + "application", WADL_URI).declareNS();
    final String base = http.req.getRequestURL().toString();
    final FElem resources = elem("resources", application).add("base", base);

    // create children
    final TreeMap<String, FElem> map = new TreeMap<String, FElem>();
    for(final RestXqModule mod : modules.values()) {
      for(final RestXqFunction func : mod.functions()) {
        final TokenObjMap<TokenList> xqdoc = func.function.doc();
        final String path = func.path.toString();
        final String methods = func.methods.toString().replaceAll("[^A-Z ]", "");

        // create resource
        final FElem resource = new FElem(WADL + "resource", WADL_URI).add("path", path);
        map.put(path + '?' + methods, resource);

        // add documentation for path variables
        final Matcher var = Pattern.compile("\\$[^}]*").matcher(path);
        while(var.find()) {<commit_msg>[FIX] RESTXQ, WADL: ignore functions without %rest:path annotation<commit_after>package org.basex.http.restxq;

import static org.basex.http.restxq.RestXqText.*;
import static org.basex.query.QueryText.*;
import static org.basex.util.Token.*;

import java.util.*;
import java.util.regex.*;

import org.basex.http.*;
import org.basex.query.util.inspect.*;
import org.basex.query.value.item.*;
import org.basex.query.value.node.*;
import org.basex.query.var.*;
import org.basex.util.hash.*;
import org.basex.util.list.*;

/**
 * This class returns a Web Application Description Language (WADL) file,
 * listing all available RESTXQ services.
 *
 * @author BaseX Team 2005-13, BSD License
 * @author <NAME>
 */
final class RestXqWadl {
  /** HTTP context. */
  private final HTTPContext http;

  /**
   * Constructor.
   * @param hc HTTP context
   */
  RestXqWadl(final HTTPContext hc) {
    http = hc;
  }

  /**
   * Returns a WADL description for all available URIs.
   * @param modules available modules
   * @return WADL description
   */
  synchronized FElem create(final HashMap<String, RestXqModule> modules) {
    // create root nodes
    final FElem application = new FElem(WADL + "application", WADL_URI).declareNS();
    final String base = http.req.getRequestURL().toString();
    final FElem resources = elem("resources", application).add("base", base);

    // create children
    final TreeMap<String, FElem> map = new TreeMap<String, FElem>();
    for(final RestXqModule mod : modules.values()) {
      for(final RestXqFunction func : mod.functions()) {
        if(func.path == null) continue;

        final TokenObjMap<TokenList> xqdoc = func.function.doc();
        final String path = func.path.toString();
        final String methods = func.methods.toString().replaceAll("[^A-Z ]", "");

        // create resource
        final FElem resource = new FElem(WADL + "resource", WADL_URI).add("path", path);
        map.put(path + '?' + methods, resource);

        // add documentation for path variables
        final Matcher var = Pattern.compile("\\$[^}]*").matcher(path);
        while(var.find()) {
{'fraction_non_alphanumeric': 0.1398264223722276, 'fraction_numerical': 0.0028929604628736743, 'mean_word_length': 3.3581932773109244, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6539510', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1269, 'n_words': 338}