MCPcopy Create free account
hub / github.com/BaseXdb/basex / bestQf

Method bestQf

basex-api/src/main/java/org/basex/http/web/WebModules.java:259–280  ·  view source on GitHub ↗

Filters functions by their quality factors. @param funcs list of functions @param conn HTTP connection

(final List<RestXqFunction> funcs, final HTTPConnection conn)

Source from the content-addressed store, hash-verified

257 * @param conn HTTP connection
258 */
259 private static void bestQf(final List<RestXqFunction> funcs, final HTTPConnection conn) {
260 // find the highest matching quality factors
261 final ArrayList<MediaType> accepts = conn.accepts();
262 double cQf = 0, sQf = 0;
263 for(final RestXqFunction func : funcs) {
264 for(final MediaType accept : accepts) {
265 if(func.produces.isEmpty()) {
266 cQf = Math.max(cQf, qf(accept, "q"));
267 sQf = 1;
268 } else {
269 for(final MediaType produce : func.produces) {
270 if(produce.matches(accept)) {
271 cQf = Math.max(cQf, qf(accept, "q"));
272 sQf = Math.max(sQf, qf(produce, "qs"));
273 }
274 }
275 }
276 }
277 }
278 bestQf(funcs, accepts, cQf, -1);
279 if(funcs.size() > 1) bestQf(funcs, accepts, cQf, sQf);
280 }
281
282 /**
283 * Filters functions by their quality factors.

Callers 1

restxqMethod · 0.95

Calls 9

qfMethod · 0.95
acceptsMethod · 0.80
anyMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
removeMethod · 0.65
isEmptyMethod · 0.45
maxMethod · 0.45
matchesMethod · 0.45

Tested by

no test coverage detected