@Test public void formatQuery() throws Exception { final StreamsQuery query = new StreamsQuery( UUID.fromString("da55cea5-c21c-46a5-ab79-5433eef4efaa"), "SELECT * WHERE { ?a ?b ?c . }", true, false); final String formatted = StreamsQueryFormatter.format(query); final String expected = " Query ID: da55cea5-c21c-46a5-ab79-5433eef4efaa\n" + "Is Active: true\n" + "Is Insert: false\n" + " SPARQL: select ?a ?b ?c\n" + " where {\n" + " ?a ?b ?c.\n" + " }\n"; assertEquals(expected, formatted); }
public static String format(final StreamsQuery query) throws Exception { requireNonNull(query); final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(query.getSparql(), null); final String prettySparql = new SPARQLQueryRenderer().render(parsedQuery); final String[] lines = prettySparql.split("\n"); query.getQueryId(); query.isActive(); String.format(" QueryId: %s", query.getQueryId()); final StringBuilder builder = new StringBuilder(); builder.append(" Query ID: ").append( query.getQueryId() ) .append("\n"); builder.append("Is Active: ").append( query.isActive() ).append("\n"); builder.append("Is Insert: ").append( query.isInsert() ).append("\n"); builder.append(" SPARQL: ").append( lines[0] ).append("\n"); for(int i = 1; i < lines.length; i++) { builder.append(" ").append(lines[i]).append("\n"); } return builder.toString(); }
StreamsQueryFormatter { public static String format(final StreamsQuery query) throws Exception { requireNonNull(query); final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(query.getSparql(), null); final String prettySparql = new SPARQLQueryRenderer().render(parsedQuery); final String[] lines = prettySparql.split("\n"); query.getQueryId(); query.isActive(); String.format(" QueryId: %s", query.getQueryId()); final StringBuilder builder = new StringBuilder(); builder.append(" Query ID: ").append( query.getQueryId() ) .append("\n"); builder.append("Is Active: ").append( query.isActive() ).append("\n"); builder.append("Is Insert: ").append( query.isInsert() ).append("\n"); builder.append(" SPARQL: ").append( lines[0] ).append("\n"); for(int i = 1; i < lines.length; i++) { builder.append(" ").append(lines[i]).append("\n"); } return builder.toString(); } }
StreamsQueryFormatter { public static String format(final StreamsQuery query) throws Exception { requireNonNull(query); final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(query.getSparql(), null); final String prettySparql = new SPARQLQueryRenderer().render(parsedQuery); final String[] lines = prettySparql.split("\n"); query.getQueryId(); query.isActive(); String.format(" QueryId: %s", query.getQueryId()); final StringBuilder builder = new StringBuilder(); builder.append(" Query ID: ").append( query.getQueryId() ) .append("\n"); builder.append("Is Active: ").append( query.isActive() ).append("\n"); builder.append("Is Insert: ").append( query.isInsert() ).append("\n"); builder.append(" SPARQL: ").append( lines[0] ).append("\n"); for(int i = 1; i < lines.length; i++) { builder.append(" ").append(lines[i]).append("\n"); } return builder.toString(); }  }
StreamsQueryFormatter { public static String format(final StreamsQuery query) throws Exception { requireNonNull(query); final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(query.getSparql(), null); final String prettySparql = new SPARQLQueryRenderer().render(parsedQuery); final String[] lines = prettySparql.split("\n"); query.getQueryId(); query.isActive(); String.format(" QueryId: %s", query.getQueryId()); final StringBuilder builder = new StringBuilder(); builder.append(" Query ID: ").append( query.getQueryId() ) .append("\n"); builder.append("Is Active: ").append( query.isActive() ).append("\n"); builder.append("Is Insert: ").append( query.isInsert() ).append("\n"); builder.append(" SPARQL: ").append( lines[0] ).append("\n"); for(int i = 1; i < lines.length; i++) { builder.append(" ").append(lines[i]).append("\n"); } return builder.toString(); }  static String format(final StreamsQuery query); static String format(final Collection<StreamsQuery> queries); }
StreamsQueryFormatter { public static String format(final StreamsQuery query) throws Exception { requireNonNull(query); final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(query.getSparql(), null); final String prettySparql = new SPARQLQueryRenderer().render(parsedQuery); final String[] lines = prettySparql.split("\n"); query.getQueryId(); query.isActive(); String.format(" QueryId: %s", query.getQueryId()); final StringBuilder builder = new StringBuilder(); builder.append(" Query ID: ").append( query.getQueryId() ) .append("\n"); builder.append("Is Active: ").append( query.isActive() ).append("\n"); builder.append("Is Insert: ").append( query.isInsert() ).append("\n"); builder.append(" SPARQL: ").append( lines[0] ).append("\n"); for(int i = 1; i < lines.length; i++) { builder.append(" ").append(lines[i]).append("\n"); } return builder.toString(); }  static String format(final StreamsQuery query); static String format(final Collection<StreamsQuery> queries);  }