MCPcopy Create free account
hub / github.com/BaseXdb/basex / StaticScope

Class StaticScope

basex-core/src/main/java/org/basex/query/scope/StaticScope.java:24–123  ·  view source on GitHub ↗

Superclass for static functions, variables and the main expression. @author BaseX Team, BSD License @author Leo Woerteler

Source from the content-addressed store, hash-verified

22 * @author Leo Woerteler
23 */
24public abstract class StaticScope extends ExprInfo implements Scope {
25 /** Static context. */
26 public final StaticContext sc;
27
28 /** Expression of this declaration ({@code null} if this is an external function). */
29 public Expr expr;
30 /** Resulting value (can be {@code null}). */
31 public Value value;
32
33 /** Input info (can be {@code null}). */
34 public InputInfo info;
35 /** Name of the scope (can be {@code null}). */
36 public QNm name;
37
38 /** Variable scope. */
39 protected VarScope vs;
40 /** Compilation flag. */
41 protected boolean compiled;
42
43 /** Declared type, {@code null} if not specified. */
44 protected SeqType declType;
45
46 /** Documentation string. */
47 private byte[] doc = Token.EMPTY;
48
49 /**
50 * Constructor.
51 * @param sc static context
52 */
53 StaticScope(final StaticContext sc) {
54 this.sc = sc;
55 }
56
57 /**
58 * Assigns a documentation string.
59 * @param string xqdoc string (can be {@code null})
60 */
61 public void doc(final String string) {
62 if(string != null) doc = Token.token(string.trim());
63 }
64
65 @Override
66 public final boolean compiled() {
67 return compiled;
68 }
69
70 /**
71 * Evaluates the expression and returns the resulting value.
72 * @param qc query context
73 * @return result
74 * @throws QueryException query exception
75 */
76 public Value value(final QueryContext qc) throws QueryException {
77 if(value == null) {
78 final int fp = vs.enter(qc);
79 try {
80 final Value val = expr.value(qc);
81 value = declType != null ? declType.coerce(val, qc, info, name, null) : val;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected