Skip to content

Commit

Permalink
[refactor] Renamed 'exist:timer' pragma to 'exist:time' to better ref…
Browse files Browse the repository at this point in the history
…lect its purpose. Leaves 'exist:timer' as an intact legacy supported name for now too
  • Loading branch information
adamretter committed Oct 5, 2023
1 parent 8640e3e commit bd704b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions exist-core/src/main/java/org/exist/xquery/XQueryContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,29 @@
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()) {

final String[] options = Option.tokenize(contents);
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])) {
Expand All @@ -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);
}
}

Expand Down

0 comments on commit bd704b3

Please sign in to comment.