Skip to content

Commit 5368116

Browse files
committed
[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
1 parent 3efb6ba commit 5368116

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

exist-core/src/main/java/org/exist/xquery/XQueryContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3000,7 +3000,7 @@ public Pragma getPragma(final String name, final String contents) throws XPathEx
30003000

30013001
return switch(qname.getLocalPart()) {
30023002
case Optimize.OPTIMIZE_PRAGMA_LOCAL_NAME -> new Optimize(rootExpression, this, qname, sanitizedContents, true);
3003-
case TimerPragma.TIMER_PRAGMA_LOCAL_NAME -> new TimerPragma(rootExpression, qname, sanitizedContents);
3003+
case TimePragma.TIME_PRAGMA_LOCAL_NAME, TimePragma.DEPRECATED_TIMER_PRAGMA_LOCAL_NAME -> new TimePragma(rootExpression, qname, sanitizedContents);
30043004
case ProfilePragma.PROFILING_PRAGMA_LOCAL_NAME -> new ProfilePragma(rootExpression, qname, sanitizedContents);
30053005
case ForceIndexUse.FORCE_INDEX_USE_PRAGMA_LOCAL_NAME -> new ForceIndexUse(rootExpression, qname, sanitizedContents);
30063006
case NoIndexPragma.NO_INDEX_PRAGMA_LOCAL_NAME -> new NoIndexPragma(rootExpression, qname, sanitizedContents);

exist-core/src/main/java/org/exist/xquery/pragmas/TimerPragma.java renamed to exist-core/src/main/java/org/exist/xquery/pragmas/TimePragma.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,30 @@
2929
import org.exist.xquery.util.ExpressionDumper;
3030
import org.exist.xquery.value.Sequence;
3131

32-
public class TimerPragma extends AbstractPragma {
33-
public static final String TIMER_PRAGMA_LOCAL_NAME = "timer";
34-
public static final QName TIMER_PRAGMA = new QName(TIMER_PRAGMA_LOCAL_NAME, Namespaces.EXIST_NS, "exist");
32+
/**
33+
* An XQuery Pragma that will record the execution
34+
* time of the associated expression.
35+
*/
36+
public class TimePragma extends AbstractPragma {
37+
38+
public static final String TIME_PRAGMA_LOCAL_NAME = "time";
39+
public static final QName TIME_PRAGMA = new QName(TIME_PRAGMA_LOCAL_NAME, Namespaces.EXIST_NS, "exist");
40+
public static final String DEPRECATED_TIMER_PRAGMA_LOCAL_NAME = "timer";
3541

3642
private Logger log = null;
3743

3844
private long start;
3945
private boolean verbose = true;
4046

41-
public TimerPragma(final Expression expression, final QName qname, final String contents) throws XPathException {
47+
public TimePragma(final Expression expression, final QName qname, final String contents) throws XPathException {
4248
super(expression, qname, contents);
4349
if (contents != null && !contents.isEmpty()) {
4450

4551
final String[] options = Option.tokenize(contents);
4652
for (final String option : options) {
4753
final String[] param = Option.parseKeyValuePair(option);
4854
if (param == null) {
49-
throw new XPathException((Expression) null, "Invalid content found for pragma " + TIMER_PRAGMA.getStringValue() + ": " + contents);
55+
throw new XPathException((Expression) null, "Invalid content found for pragma " + TIME_PRAGMA.getStringValue() + ": " + contents);
5056
}
5157

5258
if ("verbose".equals(param[0])) {
@@ -57,7 +63,7 @@ public TimerPragma(final Expression expression, final QName qname, final String
5763
}
5864
}
5965
if (log == null) {
60-
log = LogManager.getLogger(TimerPragma.class);
66+
log = LogManager.getLogger(TimePragma.class);
6167
}
6268
}
6369

0 commit comments

Comments
 (0)