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

Method arity

basex-core/src/main/java/org/basex/query/QueryError.java:1817–1841  ·  view source on GitHub ↗

Returns an information string for the supplied input and the expected arity. @param supplied arguments @param arities allowed arities (if single arity is negative, function is variadic) @return string

(final String supplied, final IntList arities)

Source from the content-addressed store, hash-verified

1815 * @return string
1816 */
1817 public static String arity(final String supplied, final IntList arities) {
1818 final String expected;
1819 final int as = arities.ddo().size();
1820 if(as == 1 && arities.peek() < 0) {
1821 expected = "at least " + -arities.peek();
1822 } else {
1823 int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
1824 for(int a = 0; a < as; a++) {
1825 final int m = arities.get(a);
1826 if(m < min) min = m;
1827 if(m > max) max = m;
1828 }
1829 final TokenBuilder tb = new TokenBuilder();
1830 if(as > 2 && max - min + 1 == as) {
1831 tb.addInt(min).add('-').addInt(max);
1832 } else {
1833 for(int a = 0; a < as; a++) {
1834 if(a != 0) tb.add(a + 1 < as ? ", " : " or ");
1835 tb.addInt(arities.get(a));
1836 }
1837 }
1838 expected = tb.toString();
1839 }
1840 return Util.info("% supplied, % expected", supplied, expected);
1841 }
1842
1843 /**
1844 * Returns an info message for similar strings.

Callers 1

arityErrorMethod · 0.95

Calls 10

addIntMethod · 0.95
addMethod · 0.95
toStringMethod · 0.95
infoMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
addIntMethod · 0.65
addMethod · 0.65
ddoMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected