public static NodeValue strReplace(NodeValue nvStr, NodeValue nvPattern, NodeValue nvReplacement, NodeValue nvFlags) { String pat = checkAndGetStringLiteral("replace", nvPattern).getLiteralLexicalForm(); String flagsStr = null; if ( nvFlags != null ) flagsStr = checkAndGetStringLiteral("replace", nvFlags).getLiteralLexicalForm(); return strReplace(nvStr, RegexJava.makePattern("replace", pat, flagsStr), nvReplacement); }
public static NodeValue strlen(NodeValue nvString) { Node n = checkAndGetStringLiteral("strlen", nvString) ; String str = n.getLiteralLexicalForm(); int len = str.codePointCount(0, str.length()) ; return NodeValue.makeInteger(len) ; }
public static NodeValue strUpperCase(NodeValue string) { Node n = checkAndGetStringLiteral("ucase", string) ; String lex = n.getLiteralLexicalForm() ; String lex2 = lex.toUpperCase() ; return calcReturn(lex2, string.asNode()) ; }
public static NodeValue strReplace(NodeValue nvStr, Pattern pattern, NodeValue nvReplacement) { String n = checkAndGetStringLiteral("replace", nvStr).getLiteralLexicalForm() ; String rep = checkAndGetStringLiteral("replace", nvReplacement).getLiteralLexicalForm() ; String x = replaceAll(pattern.matcher(n), rep) ; if ( x == null ) // No replacement. return nvStr ; return calcReturn(x, nvStr.asNode()) ; }
public static NodeValue strLowerCase(NodeValue string) { Node n = checkAndGetStringLiteral("lcase", string) ; String lex = n.getLiteralLexicalForm() ; String lex2 = lex.toLowerCase() ; return calcReturn(lex2, string.asNode()) ; }
@Override public NodeValue eval(List<NodeValue> args) { Node arg = NodeFunctions.checkAndGetStringLiteral("REGEX", args.get(0)) ; NodeValue vPattern = args.get(1) ; NodeValue vFlags = ( args.size() == 2 ? null : args.get(2) ) ; RegexEngine regex = regexEngine ; if ( regex == null ) { // Execution time regex compile (not a constant pattern). try { regex = makeRegexEngine(vPattern, vFlags) ; } catch (ExprEvalException ex) { // Avoid multiple logging of the same message (at least if adjacent) String m = ex.getMessage(); if ( m != null && ! m.equals(currentFailMessage) ) Log.warn(this, m); currentFailMessage = m; // This becomes an eval error, the FILTER is false and the current row rejected. throw ex; } } boolean b = regex.match(arg.getLiteralLexicalForm()) ; return b ? NodeValue.TRUE : NodeValue.FALSE ; }
Node n1 = checkAndGetStringLiteral(label, arg1) ; Node n2 = checkAndGetStringLiteral(label, arg2) ; String lang1 = n1.getLiteralLanguage() ; String lang2 = n2.getLiteralLanguage() ;
Node n = checkAndGetStringLiteral("CONCAT", nv) ; String lang1 = n.getLiteralLanguage() ; if ( !lang1.equals("") ) {
public static NodeValue substring(NodeValue nvString, NodeValue nvStart, NodeValue nvLength) { Node n = checkAndGetStringLiteral("substring", nvString) ; RDFDatatype dt = n.getLiteralDatatype() ; String lang = n.getLiteralLanguage() ;
@Test public void testCheckAndGetStringLiteral2() { NodeValue nv = NodeValue.makeNode("abc", XSDDatatype.XSDnormalizedString) ; Node n = NodeFunctions.checkAndGetStringLiteral("Test", nv); assertEquals( "abc", n.getLiteralLexicalForm()); }
@Test public void testCheckAndGetStringLiteral1() { NodeValue nv = NodeValue.makeNode("abc", XSDDatatype.XSDstring) ; Node n = NodeFunctions.checkAndGetStringLiteral("Test", nv); assertEquals( "abc", n.getLiteralLexicalForm()); }
@Test public void testCheckAndGetStringLiteral3() { NodeValue nv = NodeValue.makeString("abc") ; Node n = NodeFunctions.checkAndGetStringLiteral("Test", nv); assertEquals( "abc", n.getLiteralLexicalForm()); }
@Test(expected=ExprEvalException.class) public void testCheckAndGetStringLiteral4() { // The form "abc"^^rdf:langString (no lang tag) is not derived from xsd:string. NodeValue nv = NodeValue.makeNode("abc", RDF.dtLangString) ; Node n = NodeFunctions.checkAndGetStringLiteral("Test", nv); assertEquals( "abc", n.getLiteralLexicalForm()); }