@Override public final NodeValue exec(List<NodeValue> args) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("FunctionBase1: Null args list") ; if ( args.size() != 1 ) throw new ExprEvalException("FunctionBase1: Wrong number of arguments: Wanted 1, got "+args.size()) ; NodeValue v1 = args.get(0) ; return exec(v1) ; }
@Override public final NodeValue exec(List<NodeValue> args) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("FunctionBase1: Null args list") ; if ( args.size() != 1 ) throw new ExprEvalException("FunctionBase1: Wrong number of arguments: Wanted 1, got "+args.size()) ; NodeValue v1 = args.get(0) ; return exec(v1) ; }
protected NodeValue cast(String s, NodeValue nv, XSDDatatype castType2) { // Plain cast. if ( ! castType.isValid(s) ) throw new ExprEvalException("CastXSD: Not a valid literal form: "+s) ; // Unfortunately, validity testing happens in NodeValue.makeNode as well. return NodeValue.makeNode(s, castType) ; } }
public static NodeValue dtGetTZ(NodeValue nv) { DateTimeStruct dts = parseAnyDT(nv) ; if ( dts == null ) throw new ExprEvalException("Not a data/time value: "+nv) ; if ( dts.timezone == null) return NodeValue.nvEmptyString ; return NodeValue.makeString(dts.timezone) ; }
public static NodeValue dtGetTZ(NodeValue nv) { DateTimeStruct dts = parseAnyDT(nv) ; if ( dts == null ) throw new ExprEvalException("Not a data/time value: "+nv) ; if ( dts.timezone == null) return NodeValue.nvEmptyString ; return NodeValue.makeString(dts.timezone) ; }
@Override public final NodeValue exec(List<NodeValue> args) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException(Utils.className(this)+": Null args list") ; if ( args.size() != 2 ) throw new ExprEvalException(Utils.className(this)+": Wrong number of arguments: Wanted 2, got "+args.size()) ; NodeValue v1 = args.get(0) ; NodeValue v2 = args.get(1) ; return exec(v1, v2) ; }
@Override public NodeValue evalSpecial(Binding binding, FunctionEnv env) { for ( Expr expr : super.getArgs() ) { try { NodeValue nv = expr.eval(binding, env) ; return nv ; } catch (ExprEvalException ex) {} } throw new ExprEvalException("COALESCE: no value") ; }
@Override public NodeValue exec(NodeValue nv) { if ( ! nv.isInteger() ) throw new ExprEvalException("Not an integer") ; int x = nv.getInteger().intValue() ; Lib.sleep(x) ; return NodeValue.TRUE ; } }
@Override public final NodeValue exec(List<NodeValue> args) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("Function '"+Utils.className(this)+" Null args list") ; if ( args.size() != 0 ) throw new ExprEvalException("Function '"+Utils.className(this)+" Wanted 0, got "+args.size()) ; return exec() ; }
public void build(String uri, ExprList args) { if ( args.size() != 3 && args.size() != 2 ) throw new ExprEvalException("matches: Wrong number of arguments: Wanted 2 or 3, got "+args.size()) ; myArgs = args ; }
public static NodeValue strDatatype(NodeValue v1, NodeValue v2) { if ( !v1.isString() ) throw new ExprEvalException("Not a string (arg 1): " + v1) ; if ( !v2.isIRI() ) throw new ExprEvalException("Not an IRI (arg 2): " + v2) ; String lex = v1.asString() ; Node dt = v2.asNode() ; // Check? Node n = NodeFactory.createLiteral(lex, null, NodeFactory.getType(dt.getURI())) ; return NodeValue.makeNode(n) ; }
public static NodeValue strDatatype(NodeValue v1, NodeValue v2) { if ( ! v1.isString() ) throw new ExprEvalException("Not a string (arg 1): "+v1) ; if ( ! v2.isIRI() ) throw new ExprEvalException("Not an IRI (arg 2): "+v2) ; String lex = v1.asString() ; Node dt = v2.asNode() ; // Check? Node n = Node.createLiteral(lex, null, Node.getType(dt.getURI())) ; return NodeValue.makeNode(n) ; }
@Override public NodeValue exec(NodeValue v) { Node n = v.asNode() ; if ( ! n.isURI() ) throw new ExprEvalException("Not a URI: "+FmtUtils.stringForNode(n)) ; String str = n.getNameSpace() ; return NodeValue.makeString(str) ; } }
@Override public NodeValue exec(NodeValue v) { Node n = v.asNode() ; if ( ! n.isURI() ) throw new ExprEvalException("Not a URI: "+FmtUtils.stringForNode(n)) ; String str = n.getLocalName() ; return NodeValue.makeString(str) ; } }
public static NodeValue dtGetDay(NodeValue nv) { if ( nv.isDateTime() || nv.isDate() || nv.isGMonthDay() || nv.isGDay() ) { DateTimeStruct dts = parseAnyDT(nv) ; return NodeValue.makeNode(dts.day, XSDDatatype.XSDinteger) ; } throw new ExprEvalException("Not a month datatype") ; }
public static NodeValue dtGetDay(NodeValue nv) { if ( nv.isDateTime() || nv.isDate() || nv.isGMonthDay() || nv.isGDay() ) { DateTimeStruct dts = parseAnyDT(nv) ; return NodeValue.makeNode(dts.day, XSDDatatype.XSDinteger) ; } throw new ExprEvalException("Not a month datatype") ; }
private static DateTimeStruct parseTime(NodeValue nv) { String lex = nv.getNode().getLiteralLexicalForm() ; if ( nv.isDateTime() ) return DateTimeStruct.parseDateTime(lex) ; else if ( nv.isTime() ) return DateTimeStruct.parseTime(lex) ; else throw new ExprEvalException("Not a datatype for time") ; }
public static NodeValue dtGetMonth(NodeValue nv) { if ( nv.isDateTime() || nv.isDate() || nv.isGYearMonth() || nv.isGMonth() || nv.isGMonthDay() ) { DateTimeStruct dts = parseAnyDT(nv) ; return NodeValue.makeNode(dts.month, XSDDatatype.XSDinteger) ; } throw new ExprEvalException("Not a month datatype") ; }
public static NodeValue dtGetMonth(NodeValue nv) { if ( nv.isDateTime() || nv.isDate() || nv.isGYearMonth() || nv.isGMonth() || nv.isGMonthDay() ) { DateTimeStruct dts = parseAnyDT(nv) ; return NodeValue.makeNode(dts.month, XSDDatatype.XSDinteger) ; } throw new ExprEvalException("Not a month datatype") ; }
public static String str(Node node) { if ( node.isLiteral() ) return node.getLiteral().getLexicalForm() ; if ( node.isURI() ) return node.getURI() ; // if ( node.isBlank() ) return node.getBlankNodeId().getLabelString() ; // if ( node.isBlank() ) return "" ; if ( node.isBlank() ) NodeValue.raise(new ExprTypeException("Blank node: "+node)) ; NodeValue.raise(new ExprEvalException("Not a string: "+node)) ; return "[undef]" ; }