// Path: src/main/java/org/deri/tarql/functions/ExpandPrefixFunction.java
// public class ExpandPrefixFunction implements Function {
// 
// 	public static String IRI = tarql.NS + "expandPrefix";
// 	public static String NAME = "tarql:expandPrefix";
// 	
// 	public static final Symbol PREFIX_MAPPING = Symbol.create("prefixMapping");
// 	
// 	static {
// 		TarqlQuery.registerFunctions();
// 	}
// 	
// 	public ExpandPrefixFunction() {
// 		super();
// 	}
// 
// 	public NodeValue exec(NodeValue prefix, Context context) {
// 		if (prefix == null) {
// 			return null;
// 		}
// 		if (!prefix.isString()) {
// 			throw new ExprEvalException(NAME + ": not a string: " + prefix);
// 		}
// 		PrefixMapping prefixes = context.get(PREFIX_MAPPING);
// 		if (prefixes == null) {
// 			throw new ExprEvalException(NAME + ": no prefix mapping registered");
// 		}
// 		String iri = prefixes.getNsPrefixURI(prefix.asString());
// 		if (iri == null) {
// 			throw new ExprEvalException(NAME + ": prefix not defined: " + prefix);
// 		}
// 		return NodeValue.makeString(iri);
// 	}
// 
// 	@Override
// 	public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
// 		if (args == null) {
// 			throw new ARQInternalErrorException("ExpandPrefixFunction: Null args list");
// 		}
// 		if (args.size() != 1) {
// 			throw new ExprEvalException("ExpandPrefixFunction: Wrong number of arguments: Wanted 1, got " + args.size());
// 		}
//         return exec(args.get(0).eval(binding, env), env.getContext());
// 	}
// 
// 	@Override
// 	public void build(String uri, ExprList args) {
// 		if (args.size() != 1) {
// 			throw new QueryBuildException("Function '" + Lib.className(this) + "' takes one argument");
// 		}
// 	}
// }
// 
// Path: src/main/java/org/deri/tarql/functions/ExpandPrefixedNameFunction.java
// public class ExpandPrefixedNameFunction implements Function {
// 
// 	public static String IRI = tarql.NS + "expandPrefixedName";
// 	public static String Name = "tarql:expandPrefixedName";
// 
// 	static {
// 		TarqlQuery.registerFunctions();
// 	}
// 	
// 	public ExpandPrefixedNameFunction() {
// 		super();
// 	}
// 	
// 	public NodeValue exec(NodeValue name, Context context) {
// 		if (name == null) return null;
// 		if (!name.isString()) throw new ExprEvalException("Not a string: " + name);
// 		PrefixMapping prefixes = context.get(ExpandPrefixFunction.PREFIX_MAPPING);
// 		if (prefixes == null) throw new ExprEvalException("No prefix mapping registered");
// 		String pname = name.asString();
// 		int idx = pname.indexOf(':');
// 		if (idx == -1) throw new ExprEvalException("Not a prefixed name: " + name);
// 		String prefix = pname.substring(0, idx);
// 		String iri = prefixes.getNsPrefixURI(prefix);
// 		if (iri == null) throw new ExprEvalException("Prefix not defined: " + prefix);
// 		return NodeValue.makeNode(NodeFactory.createURI(iri + pname.substring(idx + 1)));
// 	}
// 
// 	@Override
// 	public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
// 		if (args == null) {
// 			throw new ARQInternalErrorException("ExpandPrefixFunction: Null args list");
// 		}
// 		if (args.size() != 1) {
// 			throw new ExprEvalException("ExpandPrefixFunction: Wrong number of arguments: Wanted 1, got " + args.size());
// 		}
//         return exec(args.get(0).eval(binding, env), env.getContext());
// 	}
// 
// 	@Override
// 	public void build(String uri, ExprList args) {
// 		if (args.size() != 1) {
// 			throw new QueryBuildException("Function '" + Lib.className(this) + "' takes one argument");
// 		}
// 	}
// }


import java.util.ArrayList;
import java.util.List;
import org.apache.jena.query.Query;
import org.apache.jena.sparql.core.Prologue;
import org.apache.jena.sparql.core.Var;
import org.apache.jena.sparql.function.FunctionRegistry;
import org.deri.tarql.functions.ExpandPrefixFunction;
import org.deri.tarql.functions.ExpandPrefixedNameFunction;
package org.deri.tarql;




/**
 * A Tarql mapping. Conceptually, this is one or more SPARQL queries
 * with a shared prologue (prefixes and base declarations).
 */
public class TarqlQuery {

	static {
		registerFunctions();
	}
	
	public static void registerFunctions() {
		if (registered) return;
		registered = true;
// Path: src/main/java/org/deri/tarql/functions/ExpandPrefixFunction.java
// public class ExpandPrefixFunction implements Function {
// 
// 	public static String IRI = tarql.NS + "expandPrefix";
// 	public static String NAME = "tarql:expandPrefix";
// 	
// 	public static final Symbol PREFIX_MAPPING = Symbol.create("prefixMapping");
// 	
// 	static {
// 		TarqlQuery.registerFunctions();
// 	}
// 	
// 	public ExpandPrefixFunction() {
// 		super();
// 	}
// 
// 	public NodeValue exec(NodeValue prefix, Context context) {
// 		if (prefix == null) {
// 			return null;
// 		}
// 		if (!prefix.isString()) {
// 			throw new ExprEvalException(NAME + ": not a string: " + prefix);
// 		}
// 		PrefixMapping prefixes = context.get(PREFIX_MAPPING);
// 		if (prefixes == null) {
// 			throw new ExprEvalException(NAME + ": no prefix mapping registered");
// 		}
// 		String iri = prefixes.getNsPrefixURI(prefix.asString());
// 		if (iri == null) {
// 			throw new ExprEvalException(NAME + ": prefix not defined: " + prefix);
// 		}
// 		return NodeValue.makeString(iri);
// 	}
// 
// 	@Override
// 	public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
// 		if (args == null) {
// 			throw new ARQInternalErrorException("ExpandPrefixFunction: Null args list");
// 		}
// 		if (args.size() != 1) {
// 			throw new ExprEvalException("ExpandPrefixFunction: Wrong number of arguments: Wanted 1, got " + args.size());
// 		}
//         return exec(args.get(0).eval(binding, env), env.getContext());
// 	}
// 
// 	@Override
// 	public void build(String uri, ExprList args) {
// 		if (args.size() != 1) {
// 			throw new QueryBuildException("Function '" + Lib.className(this) + "' takes one argument");
// 		}
// 	}
// }
// 
// Path: src/main/java/org/deri/tarql/functions/ExpandPrefixedNameFunction.java
// public class ExpandPrefixedNameFunction implements Function {
// 
// 	public static String IRI = tarql.NS + "expandPrefixedName";
// 	public static String Name = "tarql:expandPrefixedName";
// 
// 	static {
// 		TarqlQuery.registerFunctions();
// 	}
// 	
// 	public ExpandPrefixedNameFunction() {
// 		super();
// 	}
// 	
// 	public NodeValue exec(NodeValue name, Context context) {
// 		if (name == null) return null;
// 		if (!name.isString()) throw new ExprEvalException("Not a string: " + name);
// 		PrefixMapping prefixes = context.get(ExpandPrefixFunction.PREFIX_MAPPING);
// 		if (prefixes == null) throw new ExprEvalException("No prefix mapping registered");
// 		String pname = name.asString();
// 		int idx = pname.indexOf(':');
// 		if (idx == -1) throw new ExprEvalException("Not a prefixed name: " + name);
// 		String prefix = pname.substring(0, idx);
// 		String iri = prefixes.getNsPrefixURI(prefix);
// 		if (iri == null) throw new ExprEvalException("Prefix not defined: " + prefix);
// 		return NodeValue.makeNode(NodeFactory.createURI(iri + pname.substring(idx + 1)));
// 	}
// 
// 	@Override
// 	public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
// 		if (args == null) {
// 			throw new ARQInternalErrorException("ExpandPrefixFunction: Null args list");
// 		}
// 		if (args.size() != 1) {
// 			throw new ExprEvalException("ExpandPrefixFunction: Wrong number of arguments: Wanted 1, got " + args.size());
// 		}
//         return exec(args.get(0).eval(binding, env), env.getContext());
// 	}
// 
// 	@Override
// 	public void build(String uri, ExprList args) {
// 		if (args.size() != 1) {
// 			throw new QueryBuildException("Function '" + Lib.className(this) + "' takes one argument");
// 		}
// 	}
// }


// Path: src/main/java/org/deri/tarql/TarqlQuery.java
import java.util.ArrayList;
import java.util.List;
import org.apache.jena.query.Query;
import org.apache.jena.sparql.core.Prologue;
import org.apache.jena.sparql.core.Var;
import org.apache.jena.sparql.function.FunctionRegistry;
import org.deri.tarql.functions.ExpandPrefixFunction;
import org.deri.tarql.functions.ExpandPrefixedNameFunction;

package org.deri.tarql;




/**
 * A Tarql mapping. Conceptually, this is one or more SPARQL queries
 * with a shared prologue (prefixes and base declarations).
 */
public class TarqlQuery {

	static {
		registerFunctions();
	}
	
	public static void registerFunctions() {
		if (registered) return;
		registered = true;
		FunctionRegistry.get().put(ExpandPrefixFunction.IRI, ExpandPrefixFunction.class);