Skip to content

Commit 0e17889

Browse files
committed
feat: include start regex conditions
Signed-off-by: Otavio Santana <[email protected]>
1 parent f6a4d37 commit 0e17889

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

jnosql-oracle-nosql/src/main/java/org/eclipse/jnosql/databases/oracle/communication/OracleNoSqlLikeConverter.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,29 @@ String convert(Object value) {
5050
}
5151
return out.toString();
5252
}
53+
54+
/** Contains: equivalent to SQL LIKE %term% */
55+
String contains(String term) {
56+
return ".*" + escape(term) + ".*";
57+
}
58+
59+
/** Starts with: equivalent to SQL LIKE term% */
60+
String startsWith(String term) {
61+
return escape(term) + ".*";
62+
}
63+
64+
/** Ends with: equivalent to SQL LIKE %term */
65+
String endsWith(String term) {
66+
return ".*" + escape(term);
67+
}
68+
69+
70+
private String escape(String s) {
71+
StringBuilder out = new StringBuilder(s.length());
72+
for (char c : s.toCharArray()) {
73+
if (META.contains(c)) out.append('\\');
74+
out.append(c);
75+
}
76+
return out.toString();
77+
}
5378
}

0 commit comments

Comments
 (0)