Java Code Examples for org.eclipse.rdf4j.query.algebra.Regex#replaceWith()

The following examples show how to use org.eclipse.rdf4j.query.algebra.Regex#replaceWith() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegexAsStringFunctionOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void strendsCandidate(Regex node, String regex) {
	final String potential = regex.substring(0, regex.length() - 1);
	if (plain(potential)) {
		ValueConstant vc = new ValueConstant(vf.createLiteral(potential));
		node.replaceWith(new FunctionCall(FN.ENDS_WITH.stringValue(), node.getArg(), vc));
	}
}
 
Example 2
Source File: RegexAsStringFunctionOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void strstartsCandidate(Regex node, String regex) {
	final String potential = regex.substring(1, regex.length());
	if (plain(potential)) {
		ValueConstant vc = new ValueConstant(vf.createLiteral(potential));
		node.replaceWith(new FunctionCall(FN.STARTS_WITH.stringValue(), node.getArg(), vc));
	}
}
 
Example 3
Source File: RegexAsStringFunctionOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void equalsCandidate(Regex node, String regex) {
	final String potential = regex.substring(1, regex.length() - 1);
	if (plain(potential)) {
		ValueConstant vc = new ValueConstant(vf.createLiteral(potential));
		node.replaceWith(new Compare(node.getArg(), vc, Compare.CompareOp.EQ));
	}
}
 
Example 4
Source File: RegexAsStringFunctionOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void containsCandidate(Regex node, String potential) {
	if (plain(potential)) {
		node.replaceWith(new FunctionCall(FN.CONTAINS.stringValue(), node.getArg(), node.getPatternArg()));
	}
}