|
21 | 21 | */
|
22 | 22 | package org.exist.xquery.functions.fn;
|
23 | 23 |
|
24 |
| -import org.exist.dom.QName; |
25 |
| -import org.exist.xquery.*; |
26 |
| -import org.exist.xquery.value.FunctionParameterSequenceType; |
| 24 | +import org.exist.xquery.Cardinality; |
| 25 | +import org.exist.xquery.FunctionSignature; |
| 26 | +import org.exist.xquery.XQueryContext; |
27 | 27 | import org.exist.xquery.value.FunctionReturnSequenceType;
|
28 |
| -import org.exist.xquery.value.IntegerValue; |
29 |
| -import org.exist.xquery.value.Item; |
30 | 28 | import org.exist.xquery.value.NumericValue;
|
31 |
| -import org.exist.xquery.value.Sequence; |
32 |
| -import org.exist.xquery.value.SequenceType; |
33 | 29 | import org.exist.xquery.value.Type;
|
34 | 30 |
|
35 | 31 | import java.math.RoundingMode;
|
36 | 32 |
|
| 33 | +import static org.exist.xquery.FunctionDSL.optParam; |
| 34 | +import static org.exist.xquery.functions.fn.FnModule.functionSignature; |
| 35 | + |
37 | 36 | /**
|
38 | 37 | * Implements the fn:round-half-to-even() function.
|
39 | 38 | *
|
|
45 | 44 | */
|
46 | 45 | public class FunRoundHalfToEven extends FunRoundBase {
|
47 | 46 |
|
48 |
| - private static final QName qName = new QName("round-half-to-even", Function.BUILTIN_FUNCTION_NS); |
| 47 | + private static final String FN_NAME = "round-half-to-even"; |
49 | 48 |
|
50 | 49 | protected static final String FUNCTION_DESCRIPTION_1_PARAM =
|
51 | 50 | "The value returned is the nearest (that is, numerically closest) " +
|
@@ -78,16 +77,15 @@ public class FunRoundHalfToEven extends FunRoundBase {
|
78 | 77 | "If $arg is of type xs:float or xs:double, rounding occurs on the " +
|
79 | 78 | "value of the mantissa computed with exponent = 0.";
|
80 | 79 |
|
81 |
| - protected static final FunctionParameterSequenceType ARG_PARAM = new FunctionParameterSequenceType("arg", Type.NUMBER, Cardinality.ZERO_OR_ONE, "The input number"); |
82 |
| - protected static final FunctionParameterSequenceType PRECISION_PARAM = new FunctionParameterSequenceType("precision", Type.INTEGER, Cardinality.EXACTLY_ONE, "The precision factor"); |
83 | 80 | protected static final FunctionReturnSequenceType RETURN_TYPE = new FunctionReturnSequenceType(Type.NUMBER, Cardinality.ZERO_OR_ONE, "the rounded value");
|
84 | 81 |
|
85 | 82 | public static final FunctionSignature[] FN_ROUND_HALF_TO_EVEN_SIGNATURES = {
|
86 |
| - FunctionDSL.functionSignature(FunRoundHalfToEven.qName, FunRoundHalfToEven.FUNCTION_DESCRIPTION_1_PARAM + FunRoundHalfToEven.FUNCTION_DESCRIPTION_COMMON, FunRoundHalfToEven.RETURN_TYPE, |
87 |
| - new FunctionParameterSequenceType("arg", Type.NUMBER, Cardinality.ZERO_OR_ONE, "The input number")), |
88 |
| - FunctionDSL.functionSignature(FunRoundHalfToEven.qName, FunRoundHalfToEven.FUNCTION_DESCRIPTION_2_PARAM + FunRoundHalfToEven.FUNCTION_DESCRIPTION_COMMON, RETURN_TYPE, |
89 |
| - new FunctionParameterSequenceType("arg", Type.NUMBER, Cardinality.ZERO_OR_ONE, "The input number"), |
90 |
| - new FunctionParameterSequenceType("precision", Type.INTEGER, Cardinality.ZERO_OR_ONE, "The input number")) }; |
| 83 | + functionSignature(FN_NAME, FunRoundHalfToEven.FUNCTION_DESCRIPTION_1_PARAM + FunRoundHalfToEven.FUNCTION_DESCRIPTION_COMMON, FunRoundHalfToEven.RETURN_TYPE, |
| 84 | + optParam("arg", Type.NUMBER, "The input number")), |
| 85 | + functionSignature(FN_NAME, FunRoundHalfToEven.FUNCTION_DESCRIPTION_2_PARAM + FunRoundHalfToEven.FUNCTION_DESCRIPTION_COMMON, RETURN_TYPE, |
| 86 | + optParam("arg", Type.NUMBER, "The input number"), |
| 87 | + optParam("precision", Type.INTEGER, "Precision to round to")) |
| 88 | + }; |
91 | 89 |
|
92 | 90 | public FunRoundHalfToEven(final XQueryContext context,
|
93 | 91 | final FunctionSignature signature) {
|
|
0 commit comments