public static String stringLiteral(Node literal) { if ( ! isStringLiteral(literal) ) return null ; return literal.getLiteralLexicalForm() ; }
public static NodeValue strEndsWith(NodeValue string, NodeValue match) { check2("strEnds", string, match) ; String lex1 = string.asNode().getLiteralLexicalForm() ; String lex2 = match.asNode().getLiteralLexicalForm() ; return NodeValue.booleanReturn(lex1.endsWith(lex2)) ; }
public static NodeValue strReplace(NodeValue nvStr, NodeValue nvPattern, NodeValue nvReplacement, NodeValue nvFlags) { String pat = checkAndGetStringLiteral("replace", nvPattern).getLiteralLexicalForm() ; int flags = 0 ; if ( nvFlags != null ) { String flagsStr = checkAndGetStringLiteral("replace", nvFlags).getLiteralLexicalForm() ; flags = RegexJava.makeMask(flagsStr) ; } return strReplace(nvStr, Pattern.compile(pat, flags), nvReplacement) ; }
public static NodeValue strStartsWith(NodeValue string, NodeValue match) { check2("strStarts", string, match) ; String lex1 = string.asNode().getLiteralLexicalForm() ; String lex2 = match.asNode().getLiteralLexicalForm() ; return NodeValue.booleanReturn(lex1.startsWith(lex2)) ; }
@Override public String stringValue(Node node) { if(node.isLiteral()){ //we do not want '"example"@en' but 'example' return node.getLiteralLexicalForm(); } else { return node.toString(); } }
@Override public String stringValue(Node node) { if(node.isLiteral()){ //we do not want '"example"@en' but 'example' return node.getLiteralLexicalForm(); } else { return node.toString(); } }
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 strLowerCase(NodeValue string) { Node n = checkAndGetStringLiteral("lcase", string) ; String lex = n.getLiteralLexicalForm() ; String lex2 = lex.toLowerCase() ; return calcReturn(lex2, string.asNode()) ; }
protected Node stripSign(Node node) { if ( ! node.isLiteral() ) return node ; String lex = node.getLiteralLexicalForm() ; String lang = node.getLiteralLanguage() ; RDFDatatype dt = node.getLiteralDatatype() ; if ( ! lex.startsWith("-") && ! lex.startsWith("+") ) throw new ARQInternalErrorException("Literal does not start with a sign: "+lex) ; lex = lex.substring(1) ; return Node.createLiteral(lex, lang, dt) ; }
/** * Return the lexical form of a literal node, error for other node types */ protected String getString(Node n, RuleContext context) { if (n.isLiteral()) { return n.getLiteralLexicalForm(); } else { throw new BuiltinException(this, context, getName() + " takes only literal arguments"); } }
public static NodeValue strLowerCase(NodeValue string) { Node n = checkAndGetString("lcase", string) ; String lex = n.getLiteralLexicalForm() ; Node n2 = Node.createLiteral(lex.toLowerCase(), n.getLiteralLanguage(), n.getLiteralDatatype()) ; return NodeValue.makeNode(n2) ; }
public static NodeValue strUpperCase(NodeValue string) { Node n = checkAndGetString("ucase", string) ; String lex = n.getLiteralLexicalForm() ; Node n2 = Node.createLiteral(lex.toUpperCase(), n.getLiteralLanguage(), n.getLiteralDatatype()) ; return NodeValue.makeNode(n2) ; }
protected Expr asExprNoSign(Node n) { String lex = n.getLiteralLexicalForm() ; String lang = n.getLiteralLanguage() ; String dtURI = n.getLiteralDatatypeURI() ; n = createLiteral(lex, lang, dtURI) ; return ExprUtils.nodeToExpr(n) ; }
protected Expr asExprNoSign(Node n) { String lex = n.getLiteralLexicalForm() ; String lang = n.getLiteralLanguage() ; String dtURI = n.getLiteralDatatypeURI() ; n = createLiteral(lex, lang, dtURI) ; return ExprUtils.nodeToExpr(n) ; }
private String getModelName( Statement s ) { Node o = s.getObject().asNode(); return o.isLiteral() ? o.getLiteralLexicalForm(): o.getURI(); }
public static boolean checkLiteral(Node node, ErrorHandler handler, long line, long col) { if ( ! node.isLiteral() ) { handler.error("Not a literal: "+node, line, col) ; return false ; } return checkLiteral(node.getLiteralLexicalForm(), node.getLiteralLanguage(), node.getLiteralDatatype(), handler, line, col) ; }
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 ; }
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") ; }
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") ; }
private boolean getBoolean( Resource root, Property p, boolean ifAbsent ) { RDFNode r = getUnique( root, p ); return r == null ? ifAbsent : r.isLiteral() ? booleanSpelling( r.asNode().getLiteralLexicalForm() ) : r.isURIResource() ? booleanSpelling( r.asNode().getLocalName() ) : false ; }