PofNodesMetadata { public static POFMetadata retrieve(ASTQueryContainer ast) throws VisitorException, MalformedQueryException { final POFMetadata meta = new POFMetadata(); RetrievePofASTMetadata retrieve = new RetrievePofASTMetadata(); List<ASTPrefixDecl> prefixDeclList = ast.getPrefixDeclList(); final Map<String, String> prefixes = new LinkedHashMap<String, String>(); for (ASTPrefixDecl prefixDecl : prefixDeclList) { String prefix = prefixDecl.getPrefix(); String iri = prefixDecl.getIRI().getValue(); prefixes.put(prefix, iri); } retrieve.visit(ast, prefixes); meta.pofNode = retrieve.pofNode; meta.pofClassAttribute = retrieve.pofClassAttribute; return meta; } private  PofNodesMetadata(); static POFMetadata retrieve(ASTQueryContainer ast);  }
@Test public void testClassAttribute() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "SELECT * { ?s a < }"; ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertCursor(meta.pofClassAttribute, 0, 0, 15, 15); }
@Test public void testClassAttribute2() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "prefix rdf: <http: ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertCursor(meta.pofClassAttribute, 0, 0, 54, 61); }
@Test public void testClassAttribute3() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "prefix rdf: <http: ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertCursor(meta.pofClassAttribute, 1, 1, 10, 17); }
@Test public void testClassAttribute4() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "prefix rdf: <http: ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertCursor(meta.pofClassAttribute, 1, 1, 10, 17); }
@Test public void testClassAttribute5() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "SELECT * {\n ?s ?p [ ?p1 <Person>, < ] }"; ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertTrue(meta.pofClassAttribute == null); }
@Test public void testPOFQName() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "prefix rdf: <http: ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertMetadata(meta.pofNode, SyntaxTreeBuilder.Qname, "http: assertFalse(meta.pofNode.getMetadata().containsKey(SyntaxTreeBuilder.BeginLine)); }
@Test public void testPOFQName2() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "prefix rdf: <http: ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertMetadata(meta.pofNode, SyntaxTreeBuilder.Qname, "http: assertCursor(meta.pofClassAttribute, 1, 1, 5, 5); }
@Test public void testPOFkeyword() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "SELECT * {\n ?s a rdf< }"; ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertMetadata(meta.pofNode, SyntaxTreeBuilder.Keyword, "rdf"); assertCursor(meta.pofNode, 1, 1, 7, 9); assertCursor(meta.pofClassAttribute, 1, 1, 5, 5); }
@Test public void testPOFkeyword2() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "SELECT * {\n ?s a [ <type> rdf< ] }"; ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertMetadata(meta.pofNode, SyntaxTreeBuilder.Keyword, "rdf"); assertCursor(meta.pofNode, 1, 1, 16, 18); assertCursor(meta.pofClassAttribute, 1, 1, 9, 14); }
@Test public void testPOFkeyword3() throws TokenMgrError, ParseException, MalformedQueryException, VisitorException { final String q = "SELECT * {\n ?s a <Person> ; <type> rdf< }"; ast = SyntaxTreeBuilder.parseQuery(q); POFMetadata meta = PofNodesMetadata.retrieve(ast); assertMetadata(meta.pofNode, SyntaxTreeBuilder.Keyword, "rdf"); assertCursor(meta.pofNode, 1, 1, 25, 27); assertCursor(meta.pofClassAttribute, 1, 1, 18, 23); }