Package org.apache.clerezza.rdf.core.sparql.query

Examples of org.apache.clerezza.rdf.core.sparql.query.Variable


        BuiltInCall iriBuiltInCall = new BuiltInCall("IRI", iriArgumentExpressions);

        if (variableUriResource instanceof VariableAtom) {
            String variableName = ((VariableAtom) variableUriResource).getVariableName();
            Variable variable = new Variable(variableName);

            List<Expression> bindArgumentExpressions = new ArrayList<Expression>();
            bindArgumentExpressions.add(iriBuiltInCall);
            bindArgumentExpressions.add(variable);
View Full Code Here


    public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {

        org.apache.stanbol.rules.manager.atoms.VariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.VariableAtom) ruleAtom;

        String variableName = tmp.getVariableName();
        Variable variable = new Variable(variableName);

        return (T) new ClerezzaSparqlObject(variable);
    }
View Full Code Here

        if (number.startsWith("\"") && number.endsWith("\"")) {
            number = number.substring(1, number.length() - 1);
        }

        if (number.startsWith(Symbols.variablesPrefix)) {
            exp = new Variable(number.replace(Symbols.variablesPrefix, ""));
        } else {
            exp = new LiteralExpression(LiteralFactory.getInstance().createTypedLiteral(number));
        }

        return (T) new ClerezzaSparqlObject(exp);
View Full Code Here

        if (string.startsWith("\"") && string.endsWith("\"")) {
            string = string.substring(1, string.length() - 1);
        }

        if (string.startsWith(Symbols.variablesPrefix)) {
            exp = new Variable(string.replace(Symbols.variablesPrefix, ""));
        } else {
            exp = new LiteralExpression(new PlainLiteralImpl(string));
        }

        return (T) new ClerezzaSparqlObject(exp);
View Full Code Here

                                         UnsupportedTypeForExportException {

        org.apache.stanbol.rules.manager.atoms.StringVariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.StringVariableAtom) ruleAtom;

        String variableName = tmp.getVariableName();
        Variable variable = new Variable(variableName);

        return (T) new ClerezzaSparqlObject(variable);
    }
View Full Code Here

        Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
        Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
        SelectQuery selectQuery = (SelectQuery) q;
        Assert.assertTrue(selectQuery.getSelection().get(0)
                .equals(new Variable(variable)));
        Assert.assertTrue(selectQuery.getDataSet().getDefaultGraphs().toArray()[0]
                .equals(new UriRef(defaultGraph)));

        GraphPattern gp = (GraphPattern) selectQuery.getQueryPattern()
                .getGraphPatterns().toArray()[0];
        Assert.assertTrue(BasicGraphPattern.class.isAssignableFrom(gp.getClass()));
        BasicGraphPattern bgp = (BasicGraphPattern) gp;

        Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
        Assert.assertTrue(triplePatterns.size()==1);

        ResourceOrVariable s = new ResourceOrVariable(new UriRef(subject));
        UriRefOrVariable p = new UriRefOrVariable(new UriRef(predicate));
        ResourceOrVariable o = new ResourceOrVariable(new Variable(variable));

        Assert.assertTrue(triplePatterns.contains(
                new SimpleTriplePattern(s, p, o)));
    }
View Full Code Here

        SelectQuery q = (SelectQuery) QueryParser.getInstance().parse(
                "SELECT ?a ?b WHERE {?a ?x ?b}");
        Set<Variable> selectionSet = new HashSet<Variable>(
                q.getSelection());
        Set<Variable> expected = new HashSet<Variable>();
        expected.add(new Variable("a"));
        expected.add(new Variable("b"));
        Assert.assertEquals(expected, selectionSet);
        Assert.assertFalse(q.isSelectAll());

    }
View Full Code Here

        SelectQuery q = (SelectQuery) QueryParser.getInstance().parse(
                "SELECT * WHERE {?a ?x ?b}");
        Set<Variable> selectionSet = new HashSet<Variable>(
                q.getSelection());
        Set<Variable> expected = new HashSet<Variable>();
        expected.add(new Variable("a"));
        expected.add(new Variable("b"));
        expected.add(new Variable("x"));
        Assert.assertEquals(expected, selectionSet);
        Assert.assertTrue(q.isSelectAll());

    }
View Full Code Here

        Set<TriplePattern> triplePatterns = bgp.getTriplePatterns();
        Assert.assertTrue(triplePatterns.size()==2);

        Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(
                new Variable("a"), new Variable("x"),
                new PlainLiteralImpl("tiger"))));

        Assert.assertTrue(triplePatterns.contains(new SimpleTriplePattern(
                new Variable("a"), new Variable("x"),
                new PlainLiteralImpl("lion", new Language("en")))));
    }
View Full Code Here

                "SELECT * WHERE {?a ?x ?b} ORDER BY DESC(?b)");

        List<OrderCondition> oc = ((QueryWithSolutionModifier) q).getOrderConditions();
        Assert.assertTrue(oc.size()==1);
        Assert.assertFalse(oc.get(0).isAscending());
        Variable b = new Variable("b");
        Assert.assertEquals(b, oc.get(0).getExpression());
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.sparql.query.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.