GraphRenderer(Graph graph, boolean enableFolding) { this.disableFolding = !enableFolding; this.graph = graph; this.base = graph.getBase(); this.namespaces = graph.getNamespaces(); this.builder = new StringBuilder(); this.utils = new TurtleValueUtils((URI)base,namespaces); this.indenter = new IndentUtils(1); }
public List<String> extract(String item) { List<String> result = doChaining(new IndentUtils(), item); if(LOGGER.isDebugEnabled()) { debug(new IndentUtils(),"Extraction completed:\n-Data:\n%s\n-Result: %s",item,result); } return result; }
@Test public void testIndentUtils$positiveLevel() throws Exception { String tabs = "\t\t\t\t\t"; for(int i=0;i<tabs.length();i++) { IndentUtils sut=new IndentUtils(i+1); assertThat(sut.indent(),equalTo(tabs.substring(0,i+1))); } }
@Test public void testIncrease() throws Exception { IndentUtils sut=new IndentUtils(); sut.increase(); assertThat(sut.indent(),equalTo(SINGLE_TAB)); }
@Test public void testIndentUtils$noLevel() throws Exception { IndentUtils sut=new IndentUtils(); assertThat(sut.indent(),isEmptyString()); }
@Test public void testIndentUtils$negativeLevel() throws Exception { IndentUtils sut=new IndentUtils(-1); assertThat(sut.indent(),isEmptyString()); }
@Test public void testDecrease$greaterThanZero() throws Exception { IndentUtils sut=new IndentUtils(); sut.increase(); sut.increase(); assertThat(sut.indent(),equalTo(DOUBLE_TAB)); sut.decrease(); assertThat(sut.indent(),equalTo(SINGLE_TAB)); }
String query(String query) { LOGGER.info("Using JENA:"); Query q=QueryFactory.create(query); LOGGER.info("-- Query:\n"+q); LOGGER.info("-- Base: "+q.getBaseURI()); LOGGER.info("-- Prefixes: "+q.getPrefixMapping()); LOGGER.info("-- Variables: "+q.getProjectVars()); Set<Var> variables=new HashSet<Var>(q.getProjectVars()); for(Entry<Var, Expr> entry:q.getProject().getExprs().entrySet()) { Var shadowing = entry.getKey(); VariableShadowingDetector detector = new VariableShadowingDetector(new IndentUtils(),shadowing); entry.getValue().visit(detector); if(detector.isShadowing()) { variables.remove(shadowing); variables.add(detector.getShadowed()); } } LOGGER.info("-- Graph URIS: "+q.getGraphURIs()); LOGGER.info("-- Named graphd URIS: "+q.getNamedGraphURIs()); List<String> search=q.getNamedGraphURIs(); q.getQueryPattern().visit(new ElementVisitorImplementation(search,variables)); return null; }
@Test public void testDecrease$neverLessThanZero() throws Exception { IndentUtils sut=new IndentUtils(); sut.increase(); sut.increase(); assertThat(sut.indent(),equalTo(DOUBLE_TAB)); sut.decrease(); sut.decrease(); sut.decrease(); assertThat(sut.indent(),isEmptyString()); }