@Test public void isInsert_false_notAnInsert() throws Exception { final String sparql = "PREFIX dc: <http: "PREFIX xsd: <http: "DELETE { " + "?book ?p ?v " + "} WHERE { " + "?book dc:date ?date . " + "FILTER ( ?date < \"2000-01-01T00:00:00\"^^xsd:dateTime ) " + "?book ?p ?v " + "}"; assertFalse( QueryInvestigator.isInsertWhere(sparql) ); }
public static boolean isInsertWhere(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseUpdate(sparql, null); return Pattern.matches("[\\s\\S]*?insert\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException updateE) { try { PARSER.parseQuery(sparql, null); return false; } catch(final MalformedQueryException queryE) { throw updateE; } } }
QueryInvestigator { public static boolean isInsertWhere(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseUpdate(sparql, null); return Pattern.matches("[\\s\\S]*?insert\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException updateE) { try { PARSER.parseQuery(sparql, null); return false; } catch(final MalformedQueryException queryE) { throw updateE; } } } }
QueryInvestigator { public static boolean isInsertWhere(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseUpdate(sparql, null); return Pattern.matches("[\\s\\S]*?insert\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException updateE) { try { PARSER.parseQuery(sparql, null); return false; } catch(final MalformedQueryException queryE) { throw updateE; } } } private  QueryInvestigator(); }
QueryInvestigator { public static boolean isInsertWhere(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseUpdate(sparql, null); return Pattern.matches("[\\s\\S]*?insert\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException updateE) { try { PARSER.parseQuery(sparql, null); return false; } catch(final MalformedQueryException queryE) { throw updateE; } } } private  QueryInvestigator(); static boolean isConstruct(final String sparql); static boolean isInsertWhere(final String sparql); }
QueryInvestigator { public static boolean isInsertWhere(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseUpdate(sparql, null); return Pattern.matches("[\\s\\S]*?insert\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException updateE) { try { PARSER.parseQuery(sparql, null); return false; } catch(final MalformedQueryException queryE) { throw updateE; } } } private  QueryInvestigator(); static boolean isConstruct(final String sparql); static boolean isInsertWhere(final String sparql);  }