Skip to content

Commit bd704b3

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 8640e3e commit bd704b3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,8 +3076,8 @@ public Pragma getPragma(final String name, String contents) throws XPathExceptio
30763076
} else if (Namespaces.EXIST_NS.equals(qname.getNamespaceURI())) {
30773077
contents = StringValue.trimWhitespace(contents);
30783078

3079-
if (TimerPragma.TIMER_PRAGMA_NAME.equals(qname)) {
3080-
return new TimerPragma(rootExpression, qname, contents);
3079+
if (TimePragma.TIME_PRAGMA_NAME.equals(qname) || TimePragma.DEPRECATED_TIMER_PRAGMA_NAME.equals(qname)) {
3080+
return new TimePragma(rootExpression, qname, contents);
30813081
}
30823082

30833083
if (Optimize.OPTIMIZE_PRAGMA.equals(qname)) {

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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,29 @@
2929
import org.exist.xquery.util.ExpressionDumper;
3030
import org.exist.xquery.value.Sequence;
3131

32-
public class TimerPragma extends AbstractPragma {
32+
/**
33+
* An XQuery Pragma that will record the execution
34+
* time of the associated expression.
35+
*/
36+
public class TimePragma extends AbstractPragma {
3337

34-
public static final QName TIMER_PRAGMA_NAME = new QName("timer", Namespaces.EXIST_NS, "exist");
38+
public static final QName TIME_PRAGMA_NAME = new QName("time", Namespaces.EXIST_NS, "exist");
39+
public static final QName DEPRECATED_TIMER_PRAGMA_NAME = new QName("timer", Namespaces.EXIST_NS, "exist");
3540

3641
private Logger log = null;
3742

3843
private long start;
3944
private boolean verbose = true;
4045

41-
public TimerPragma(final Expression expression, final QName qname, final String contents) throws XPathException {
46+
public TimePragma(final Expression expression, final QName qname, final String contents) throws XPathException {
4247
super(expression, qname, contents);
4348
if (contents != null && !contents.isEmpty()) {
4449

4550
final String[] options = Option.tokenize(contents);
4651
for (final String option : options) {
4752
final String[] param = Option.parseKeyValuePair(option);
4853
if (param == null) {
49-
throw new XPathException((Expression) null, "Invalid content found for pragma " + TIMER_PRAGMA_NAME.getStringValue() + ": " + contents);
54+
throw new XPathException((Expression) null, "Invalid content found for pragma " + TIME_PRAGMA_NAME.getStringValue() + ": " + contents);
5055
}
5156

5257
if ("verbose".equals(param[0])) {
@@ -57,7 +62,7 @@ public TimerPragma(final Expression expression, final QName qname, final String
5762
}
5863
}
5964
if (log == null) {
60-
log = LogManager.getLogger(TimerPragma.class);
65+
log = LogManager.getLogger(TimePragma.class);
6166
}
6267
}
6368

0 commit comments

Comments
 (0)