public static Node toNode(NodeValue nv) { if ( nv == null ) return null ; return nv.asNode() ; }
@Override public boolean equals(Object other) { // This is the equality condition Jena uses - lang tags are different by case. if ( this == other ) return true ; if ( ! ( other instanceof NodeValue ) ) return false ; NodeValue nv = (NodeValue)other ; return asNode().equals(nv.asNode()) ; // Not NodeFunctions.sameTerm (which smooshes language tags by case) }
@Override public int hashCode() { return asNode().hashCode() ; }
/** * {@inheritDoc} */ @Override public NodeValue exec(NodeValue v) { return NodeValue.makeString(SemanticElement.removePrefix(v.asNode())); }
/** * {@inheritDoc} */ @Override public NodeValue exec(NodeValue v) { Node n = v.asNode(); return NodeValue.makeNode(Quadruple.removeMetaInformation(n)); }
private static Op subst(Op subOp, Var var, NodeValue nv) { Op op = Substitute.substitute(subOp, var, nv.asNode()); return OpAssign.assign(op, var, nv); }
@Override public Expr applyNodeTransform(NodeTransform transform) { Node n = asNode() ; n = transform.convert(n) ; return makeNode(n) ; }
public static NodeValue strLowerCase(NodeValue string) { Node n = checkAndGetStringLiteral("lcase", string) ; String lex = n.getLiteralLexicalForm() ; String lex2 = lex.toLowerCase() ; return calcReturn(lex2, string.asNode()) ; }
public final String asQuotedString(SerializationContext context) { // If possible, make a node and use that as the formatted output. if ( node == null ) node = asNode() ; if ( node != null ) return FmtUtils.stringForNode(node, context) ; return toString() ; }
@Override protected NodeValue cast(String s, NodeValue nv, XSDDatatype castType) { // Plain cast. if ( nv.isString() || NodeUtils.hasLang(nv.asNode()) ) return super.cast(s, nv, castType) ; return XSDFuncOp.dateTimeCast(nv, castType) ; } }
public final String asQuotedString(SerializationContext context) { // If possible, make a node and use that as the formatted output. if ( node == null ) node = asNode() ; if ( node != null ) return FmtUtils.stringForNode(node, context) ; return toString() ; }
@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.isBlank() ) throw new ExprEvalException("bnode: not a blank node") ; NodeValue nv = NodeValue.makeString(n.getBlankNodeId().getLabelString()) ; return nv ; } }
private static NodeValue fixupDate(NodeValue nv) { DateTimeStruct dts = DateTimeStruct.parseDate(nv.asNode().getLiteralLexicalForm()) ; if ( dts.timezone != null ) return null ; dts.timezone = defaultTimezone ; nv = NodeValue.makeDate(dts.toString()) ; if ( ! nv.isDate() ) throw new ARQInternalErrorException("Failed to reform an xsd:date") ; return nv ; }
@Override public NodeValue eval(NodeValue x, NodeValue y) { if ( ! x.isString() ) throw new ExprEvalException("cast: arg 2 is not a string: "+x) ; if ( ! y.isIRI() ) throw new ExprEvalException("cast: arg 2 is not a URI: "+y) ; String lex = x.getString() ; y.asNode().getURI() ; throw new ARQNotImplemented() ; }
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 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]" ; }