/** Parse a string to obtain a list of SPARQL expressions */ public static ExprList parseExprList(String s, PrefixMapping pmap) { Item item = parse(s, pmap) ; return BuilderExpr.buildExprOrExprList(item) ; }
/** Parse a string, and obtain a graph */ public static DatasetGraph parseDatasetGraph(String string, PrefixMapping pmap) { Item item = parse(string, pmap) ; return BuilderGraph.buildDataset(item) ; }
/** Parse a string and obtain a SPARQL algebra table */ public static Table parseTable(String s, PrefixMapping pmap) { Item item = parse(s, pmap) ; return BuilderTable.build(item) ; }
private Item parse(String str) { Item item = SSE.parse(str) ; return item ; }
/** Parse a string, and obtain a graph */ public static Graph parseGraph(String string, PrefixMapping pmap) { Item item = parse(string, pmap) ; return BuilderGraph.buildGraph(item) ; }
static public Op parse(String string, PrefixMapping pmap) { Item item = SSE.parse(string, pmap) ; return parse(item) ; }
/** Parse from an input stream and obtain an SSE item expression */ public static Item parse(InputStream in, PrefixMapping pmap) { Reader reader = FileUtils.asBufferedUTF8(in) ; return parse(reader, pmap) ; }
/** Parse a string to obtain a path */ public static Path parsePath(String str, PrefixMapping pmap) { Item item = parse(str, pmap) ; if ( !item.isList() ) throw new ARQException("Not a list: "+str) ; return BuilderPath.buildPath(item) ; }
private static Binding binding(String bindingStr) { if ( bindingStr == null || bindingStr.matches("\\s*\\(\\s*\\)\\s*") ) return null ; Item item = SSE.parse("(binding "+bindingStr+")") ; Binding binding = BuilderBinding.build(item) ; return binding ; } }
private static Binding build(String string) { Item item = SSE.parse("(binding "+string+")") ; return BuilderBinding.build(item) ; }
private static Binding build(String string) { Item item = SSE.parse("(binding "+string+")") ; return BuilderBinding.build(item) ; }
/** Parse a string to obtain a Quad */ public static Quad parseQuad(String s, PrefixMapping pmap) { Item item = parse(s, pmap) ; if ( !item.isList() ) throw new ARQException("Not a list: "+s) ; return BuilderGraph.buildQuad(item.getList()) ; }
/** Parse a string to obtain a Triple */ public static Triple parseTriple(String str, PrefixMapping pmap) { Item item = parse(str, pmap) ; if ( !item.isList() ) throw new ARQException("Not a list: "+str) ; return BuilderGraph.buildTriple(item.getList()) ; }
public static StatsMatcher matcher(String... str) { String s1 = "(prefix ((: <http://example/>))\n(stats " ; String s2 = "))" ; String x = StrUtils.strjoinNL(str) ; Item item = SSE.parse(s1+x+s2) ; return new StatsMatcher(item) ; }
@Test public void testBase_07() { Item r = SSE.parse("(<http://example/xyz> <http://EXAMPLE/other#foo>)", null) ; testItem("(base <http://EXAMPLE/other#> ((base <http://example/> <xyz>) <#foo>))", r) ; }
@Test public void testForm_01() { // Special form of nothing. Item item = SSE.parse("(prefix ((ex: <http://example/>)))") ; assertNull(item) ; }
@Test public void testBase_04() { Item r = SSE.parse("(1 <http://example/xyz>)", null) ; testItem("(1 (base <http://example/> <xyz>))", r) ; }
@Test public void testPrefix_05() { Item r = SSE.parse("(<http://example/abc>)" , null) ; testItem("(prefix ((ex: <http://example/>)) ( (prefix ((x: <http://EXAMPLE/>)) ex:abc) ))", r); }
@Test public void testNum_01() { Item item = SSE.parse("1") ; assertEquals(1, item.getInt()) ; }
@Test public void testNum_02() { Item item = SSE.parse("3") ; assertEquals(3d, item.getDouble(), 0) ; }