forked from eXist-db/exist
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eXist-db#5078 from evolvedbinary/feat/time-pragma
New exist:time XQuery Pragma
- Loading branch information
Showing
15 changed files
with
753 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
exist-core/src/main/java/org/exist/xquery/AbstractPragma.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* eXist-db Open Source Native XML Database | ||
* Copyright (C) 2001 The eXist-db Authors | ||
* | ||
* [email protected] | ||
* http://www.exist-db.org | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
package org.exist.xquery; | ||
|
||
import org.exist.dom.QName; | ||
import org.exist.xquery.util.ExpressionDumper; | ||
import org.exist.xquery.value.Item; | ||
import org.exist.xquery.value.Sequence; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Base class for implementing an XQuery Pragma expression. | ||
* | ||
* @author <a href="mailto:[email protected]">Adam Retter</a> | ||
*/ | ||
public abstract class AbstractPragma implements Pragma { | ||
private final QName name; | ||
private @Nullable final String contents; | ||
private @Nullable final Expression expression; | ||
|
||
public AbstractPragma(@Nullable final Expression expression, final QName name, @Nullable final String contents) { | ||
this.expression = expression; | ||
this.name = name; | ||
this.contents = contents; | ||
} | ||
|
||
@Override | ||
public QName getName() { | ||
return name; | ||
} | ||
|
||
public @Nullable Expression getExpression() { | ||
return expression; | ||
} | ||
|
||
@Override | ||
public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException { | ||
// no-op by default | ||
} | ||
|
||
@Override | ||
public void before(final XQueryContext context, @Nullable final Expression expression, final Sequence contextSequence) throws XPathException { | ||
// no-op by default | ||
} | ||
|
||
@Override | ||
public Sequence eval(final Sequence contextSequence, final Item contextItem) throws XPathException { | ||
// no-op by default | ||
return null; | ||
} | ||
|
||
@Override | ||
public void after(final XQueryContext context, @Nullable final Expression expression) throws XPathException { | ||
// no-op by default | ||
} | ||
|
||
protected @Nullable String getContents() { | ||
return contents; | ||
} | ||
|
||
@Override | ||
public void dump(final ExpressionDumper dumper) { | ||
dumper.display("(# " + getName().getStringValue()); | ||
if (getContents() != null) { | ||
dumper.display(' ').display(getContents()); | ||
} | ||
} | ||
|
||
@Override | ||
public void resetState(final boolean postOptimization) { | ||
//no-op by default | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(# " + name + ' ' + contents + "#)"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,60 +22,30 @@ | |
package org.exist.xquery; | ||
|
||
import org.exist.dom.QName; | ||
import org.exist.xquery.util.ExpressionDumper; | ||
import org.exist.xquery.value.Item; | ||
import org.exist.xquery.value.Sequence; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public abstract class Pragma { | ||
|
||
private QName qname; | ||
private @Nullable String contents; | ||
private Expression expression; | ||
|
||
public Pragma(final QName qname, final @Nullable String contents) throws XPathException { | ||
this(null, qname, contents); | ||
} | ||
|
||
public Pragma(final Expression expression, final QName qname, @Nullable final String contents) throws XPathException { | ||
this.expression = expression; | ||
this.qname = qname; | ||
this.contents = contents; | ||
} | ||
/** | ||
* Interface for implementing an XQuery Pragma expression. | ||
* | ||
* @author <a href="mailto:[email protected]">Adam Retter</a> | ||
*/ | ||
public interface Pragma { | ||
|
||
public Expression getExpression() { | ||
return expression; | ||
} | ||
QName getName(); | ||
|
||
public void analyze(final AnalyzeContextInfo contextInfo) throws XPathException { | ||
} | ||
void analyze(AnalyzeContextInfo contextInfo) throws XPathException; | ||
|
||
public Sequence eval(final Sequence contextSequence, @Nullable final Item contextItem) | ||
throws XPathException { | ||
return null; | ||
} | ||
|
||
public abstract void before(final XQueryContext context, final Sequence contextSequence) throws XPathException; | ||
|
||
public abstract void before(final XQueryContext context, final Expression expression, final Sequence contextSequence) throws XPathException; | ||
|
||
public abstract void after(final XQueryContext context) throws XPathException; | ||
|
||
public abstract void after(final XQueryContext context, final Expression expression) throws XPathException; | ||
void before(XQueryContext context, @Nullable Expression expression, Sequence contextSequence) throws XPathException; | ||
|
||
protected String getContents() { | ||
return contents; | ||
} | ||
Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException; | ||
|
||
protected QName getQName() { | ||
return qname; | ||
} | ||
void after(XQueryContext context, @Nullable Expression expression) throws XPathException; | ||
|
||
public void resetState(final boolean postOptimization) { | ||
} | ||
void dump(final ExpressionDumper dumper); | ||
|
||
@Override | ||
public String toString() { | ||
return "(# " + qname + (contents == null ? "" : ' ' + contents) + " #)"; | ||
} | ||
} | ||
void resetState(boolean postOptimization); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.