@Test(expected = MalformedQueryException.class) public void isConstruct_false_malformed() throws MalformedQueryException { assertFalse( QueryInvestigator.isConstruct("not sparql") ); }
public static boolean isConstruct(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseQuery(sparql, null); return Pattern.matches("[\\s\\S]*?construct\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException queryE) { try { PARSER.parseUpdate(sparql, null); return false; } catch(final MalformedQueryException updateE) { throw queryE; } } }
QueryInvestigator { public static boolean isConstruct(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseQuery(sparql, null); return Pattern.matches("[\\s\\S]*?construct\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException queryE) { try { PARSER.parseUpdate(sparql, null); return false; } catch(final MalformedQueryException updateE) { throw queryE; } } } }
QueryInvestigator { public static boolean isConstruct(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseQuery(sparql, null); return Pattern.matches("[\\s\\S]*?construct\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException queryE) { try { PARSER.parseUpdate(sparql, null); return false; } catch(final MalformedQueryException updateE) { throw queryE; } } } private  QueryInvestigator(); }
QueryInvestigator { public static boolean isConstruct(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseQuery(sparql, null); return Pattern.matches("[\\s\\S]*?construct\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException queryE) { try { PARSER.parseUpdate(sparql, null); return false; } catch(final MalformedQueryException updateE) { throw queryE; } } } private  QueryInvestigator(); static boolean isConstruct(final String sparql); static boolean isInsertWhere(final String sparql); }
QueryInvestigator { public static boolean isConstruct(final String sparql) throws MalformedQueryException { requireNonNull(sparql); try { PARSER.parseQuery(sparql, null); return Pattern.matches("[\\s\\S]*?construct\\s*?\\{[\\s\\S]*?\\}[\\s\\S]*?where\\s*\\{[\\s\\S]*?\\}", sparql.toLowerCase()); } catch(final MalformedQueryException queryE) { try { PARSER.parseUpdate(sparql, null); return false; } catch(final MalformedQueryException updateE) { throw queryE; } } } private  QueryInvestigator(); static boolean isConstruct(final String sparql); static boolean isInsertWhere(final String sparql);  }