public static String toLexicalForm(NodeValue nodeValue) { return nodeValue.asUnquotedString(); }
@Override public String toString() { return nv.asUnquotedString(); }
public String _serialize(NodeValue nodeValue) { if(nodeValue.equals(NodeValue.nvNothing)) { return "NULL "; } // TODO Handle this correctly String result = nodeValue.asUnquotedString(); return result; }
@Override public NodeValue eval(List<NodeValue> args) { String str = ""; for(NodeValue arg : args) { str += arg.asUnquotedString(); } return NodeValue.makeString(str); } }
public static String _deriveRegex(NodeValue expr) { // return Pattern.quote(expr.asUnquotedString()); return RegexUtils.escape(expr.asUnquotedString()); }
public NodeValue exec(NodeValue value, NodeValue lang) { String v = value.asUnquotedString(); Node tmp; if(lang == null) { tmp = NodeFactory.createLiteral(v); } else { String l = lang == null ? null : lang.asUnquotedString(); tmp = NodeFactory.createLiteral(v, l, false); } NodeValue result = NodeValue.makeNode(tmp); return result; }
@Override public NodeValue exec(NodeValue value, NodeValue datatype) { String v = value.asUnquotedString(); String d = datatype.asUnquotedString(); RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(d); Node node = NodeFactory.createLiteral(v, dt); NodeValue result = NodeValue.makeNode(node); return result; } }
public String extractPrefix(Expr expr) { if(expr instanceof E_StrConcatPermissive || expr instanceof E_StrConcat) { ExprFunction fn = expr.getFunction(); List<Expr> args = fn.getArgs(); if(args.size() == 0) { logger.warn("Zero argument concat expression detected: " + expr); } else { Expr first = args.get(0); if(first.isConstant()) { String value = first.getConstant().asUnquotedString(); return value; } } } return null; }
@Override public NodeValue exec(NodeValue value, NodeValue size) { String v = value.asUnquotedString(); int n = NodeValueUtils.getInteger(size); String padded = StringUtils.rightPad(v, n); NodeValue result = NodeValue.makeString(padded); return result; } }
public static String derivePrefixConcat(ExprFunction concat) { // TODO If all arguments are constant, we could infer a constant constraint String prefix = ""; for(Expr arg : concat.getArgs()) { if(arg.isConstant()) { prefix += arg.getConstant().asUnquotedString(); } else { break; } } return prefix; }
public static String toTemplateCore(List<Expr> exprs) { StringBuilder b = new StringBuilder(); for(Expr expr : exprs) { if(expr.isVariable()) { String varName = expr.getVarName(); String escapedVarName = escapeForTemplate(varName); b.append("{" + escapedVarName + "}"); } else if(expr.isConstant()) { String str = expr.getConstant().asUnquotedString(); String escapedStr = escapeForTemplate(str); b.append(escapedStr); } else { throw new RuntimeException("Unexpected expression: " + expr); } } String result = b.toString(); return result; }
public static String toTemplateCore(List<Expr> exprs) { StringBuilder b = new StringBuilder(); for(Expr expr : exprs) { if(expr.isVariable()) { String varName = expr.getVarName(); String escapedVarName = escapeForTemplate(varName); b.append("{" + escapedVarName + "}"); } else if(expr.isConstant()) { String str = expr.getConstant().asUnquotedString(); String escapedStr = escapeForTemplate(str); b.append(escapedStr); } else { throw new RuntimeException("Unexpected expression: " + expr); } } String result = b.toString(); return result; }
String sa = ea.getConstant().asUnquotedString(); String sb = eb.getConstant().asUnquotedString();
public static StartsWithConstraint deriveConstraintConcat(ExprFunction concat) { // TODO If all arguments are constant, we could infer a constant constraint String prefix = ""; for(Expr arg : concat.getArgs()) { if(arg.isConstant()) { prefix += arg.getConstant().asUnquotedString(); } else { break; } } return new StartsWithConstraint(prefix); }
/** * TODO: IsNumeric implies not null * */ @Override public E_RdfTerm transform(Expr orig, E_RdfTerm a) { String subType = a.getDatatype().getConstant().asUnquotedString(); boolean isDecimal = typeModel.isSuperTypeOf(XSD.decimal.toString(), subType); E_RdfTerm result; if(isDecimal) { result = E_RdfTerm.TRUE; } else { result = E_RdfTerm.FALSE; } return result; }
@Override public String apply(NodeValue nv) { String result = null; if(nv == null) { } else if(nv.isString()) { result = nv.asUnquotedString(); } else if(nv.isLiteral()) { Node n = nv.asNode(); if(n.isLiteral()) { result = n.getLiteralLexicalForm(); } } return result; }
public static RestrictionImpl deriveRestrictionConcat(ExprFunction concat) { // TODO If all arguments are constant, we could infer a constant constraint String prefix = ""; for(Expr arg : concat.getArgs()) { if(arg.isConstant()) { prefix += arg.getConstant().asUnquotedString(); } else { break; } } RestrictionImpl result = new RestrictionImpl(); result.stateUriPrefixes(new org.aksw.jena_sparql_api.views.PrefixSet(prefix)); return result; };
public static RestrictionImpl deriveRestrictionConcat(ExprFunction concat) { // TODO If all arguments are constant, we could infer a constant constraint String prefix = ""; for(Expr arg : concat.getArgs()) { if(arg.isConstant()) { prefix += arg.getConstant().asUnquotedString(); } else { break; } } RestrictionImpl result = new RestrictionImpl(); result.stateUriPrefixes(new PrefixSet(prefix)); return result; };
String datatypeStr = nodeValue.asUnquotedString();
/** * TODO: IsNumeric implies not null * */ @Override public E_RdfTerm transform(Expr orig, E_RdfTerm a) { String subType = a.getDatatype().getConstant().asUnquotedString(); boolean isDecimal = typeModel.isSuperTypeOf(XSD.decimal.toString(), subType); boolean isFloat = typeModel.isSuperTypeOf(XSD.xfloat.toString(), subType); boolean isDouble = typeModel.isSuperTypeOf(XSD.xdouble.toString(), subType); boolean isNumeric = isDecimal || isFloat || isDouble; E_RdfTerm result; if(isNumeric) { result = E_RdfTerm.TRUE; } else { result = E_RdfTerm.FALSE; } return result; }