public static void addConstantConstraint(Map<Var, NodeValue> map, Var var, NodeValue nodeValue) { if (map.containsKey(var)) { NodeValue oldValue = map.get(var); if (oldValue != null && !oldValue.equals(nodeValue)) { map.put(var, null); } } else { map.put(var, nodeValue); } }
/* * See http://www.w3.org/TR/rdf-sparql-query paragraph 11.4.12 * * "(LANGMATCHES) returns true if language-tag (first argument) matches language-range (second argument) * per the basic filtering scheme defined in [RFC4647] section 3.3.1. language-range is a basic language * range per Matching of Language Tags [RFC4647] section 2.1. A language-range of "*" matches any non-empty * language-tag string." * * @see http://www.w3.org/TR/rdf-sparql-query */ private void convertLangMatches(E_LangMatches expr) { logger.debug("convertLangMatches " + expr.toString()); expr.getArg1().visit(this); expr.getArg2().visit(this); Expression e2 = expression.pop(); Expression e1 = expression.pop(); if (e1 instanceof ConstantEx && e2 instanceof ConstantEx) { ConstantEx lang1 = (ConstantEx) e1; ConstantEx lang2 = (ConstantEx) e2; NodeValue nv1 = NodeValue.makeString(lang1.getNode().getLiteral().getLexicalForm()); NodeValue nv2 = NodeValue.makeString(lang2.getNode().getLiteral().getLexicalForm()); NodeValue match = NodeFunctions.langMatches(nv1, nv2); expression.push(match.equals(NodeValue.TRUE) ? Expression.TRUE : Expression.FALSE); } else { expression.push(Expression.FALSE); } }