From bd704b328f3aba382cbf733e25427db1bc0ba4bb Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Wed, 4 Oct 2023 15:51:37 +0100 Subject: [PATCH] [refactor] Renamed 'exist:timer' pragma to 'exist:time' to better reflect its purpose. Leaves 'exist:timer' as an intact legacy supported name for now too --- .../main/java/org/exist/xquery/XQueryContext.java | 4 ++-- .../pragmas/{TimerPragma.java => TimePragma.java} | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) rename exist-core/src/main/java/org/exist/xquery/pragmas/{TimerPragma.java => TimePragma.java} (81%) diff --git a/exist-core/src/main/java/org/exist/xquery/XQueryContext.java b/exist-core/src/main/java/org/exist/xquery/XQueryContext.java index 13d7e429c41..e1c397daa46 100644 --- a/exist-core/src/main/java/org/exist/xquery/XQueryContext.java +++ b/exist-core/src/main/java/org/exist/xquery/XQueryContext.java @@ -3076,8 +3076,8 @@ public Pragma getPragma(final String name, String contents) throws XPathExceptio } else if (Namespaces.EXIST_NS.equals(qname.getNamespaceURI())) { contents = StringValue.trimWhitespace(contents); - if (TimerPragma.TIMER_PRAGMA_NAME.equals(qname)) { - return new TimerPragma(rootExpression, qname, contents); + if (TimePragma.TIME_PRAGMA_NAME.equals(qname) || TimePragma.DEPRECATED_TIMER_PRAGMA_NAME.equals(qname)) { + return new TimePragma(rootExpression, qname, contents); } if (Optimize.OPTIMIZE_PRAGMA.equals(qname)) { diff --git a/exist-core/src/main/java/org/exist/xquery/pragmas/TimerPragma.java b/exist-core/src/main/java/org/exist/xquery/pragmas/TimePragma.java similarity index 81% rename from exist-core/src/main/java/org/exist/xquery/pragmas/TimerPragma.java rename to exist-core/src/main/java/org/exist/xquery/pragmas/TimePragma.java index a65ac715129..302e8f136c4 100644 --- a/exist-core/src/main/java/org/exist/xquery/pragmas/TimerPragma.java +++ b/exist-core/src/main/java/org/exist/xquery/pragmas/TimePragma.java @@ -29,16 +29,21 @@ import org.exist.xquery.util.ExpressionDumper; import org.exist.xquery.value.Sequence; -public class TimerPragma extends AbstractPragma { +/** + * An XQuery Pragma that will record the execution + * time of the associated expression. + */ +public class TimePragma extends AbstractPragma { - public static final QName TIMER_PRAGMA_NAME = new QName("timer", Namespaces.EXIST_NS, "exist"); + public static final QName TIME_PRAGMA_NAME = new QName("time", Namespaces.EXIST_NS, "exist"); + public static final QName DEPRECATED_TIMER_PRAGMA_NAME = new QName("timer", Namespaces.EXIST_NS, "exist"); private Logger log = null; private long start; private boolean verbose = true; - public TimerPragma(final Expression expression, final QName qname, final String contents) throws XPathException { + public TimePragma(final Expression expression, final QName qname, final String contents) throws XPathException { super(expression, qname, contents); if (contents != null && !contents.isEmpty()) { @@ -46,7 +51,7 @@ public TimerPragma(final Expression expression, final QName qname, final String for (final String option : options) { final String[] param = Option.parseKeyValuePair(option); if (param == null) { - throw new XPathException((Expression) null, "Invalid content found for pragma " + TIMER_PRAGMA_NAME.getStringValue() + ": " + contents); + throw new XPathException((Expression) null, "Invalid content found for pragma " + TIME_PRAGMA_NAME.getStringValue() + ": " + contents); } if ("verbose".equals(param[0])) { @@ -57,7 +62,7 @@ public TimerPragma(final Expression expression, final QName qname, final String } } if (log == null) { - log = LogManager.getLogger(TimerPragma.class); + log = LogManager.getLogger(TimePragma.class); } }