Package com.hp.hpl.jena.sparql

Examples of com.hp.hpl.jena.sparql.ARQException


     */
    public static Dataset assemble(Model model)
    {
        Resource r = GraphUtils.findRootByType(model, DatasetAssembler.getType()) ;
        if ( r == null )
            throw new ARQException("No root found for type <"+DatasetAssembler.getType()+">") ;
       
        return assemble(r) ;
    }
View Full Code Here


   
    private static List<Var> vars(CSVParser parser) {
        final List<Var> vars = new ArrayList<Var>();
        List<String> varNames = parser.parse1() ;
        if ( varNames == null )
            throw new ARQException("SPARQL CSV Results malformed, input is empty");
        for ( String vn : varNames ) {
            vars.add(Var.alloc(vn)) ;
        }
        return vars ;
    }
View Full Code Here

    public static boolean booleanFromCSV(InputStream in)
    {
        CSVParser parser = CSVParser.create(in) ;
        final List<Var> vars = vars(parser) ;
        if ( vars.size() != 1 ) {
            throw new ARQException("CSV Boolean Results malformed: variables line='"+vars+"'") ;
        }
        if ( ! vars.get(0).getName().equals("_askResult")) {
            FmtLog.warn(log, "Boolean result variable is '%s', not '_askResult'", vars.get(0).getName()) ;
        }
       
       
        List<String> line = parser.parse1() ;
        if ( line.size() != 1 ) {
            throw new ARQException("CSV Boolean Results malformed: data line='"+line+"'") ;
        }
        String str = line.get(0) ;
        boolean b ;
        if ( str.equalsIgnoreCase("true") || str.equalsIgnoreCase("yes") )
            b = true ;
        else if (str.equalsIgnoreCase("false") || str.equalsIgnoreCase("no"))
            b = false;
        else {
            throw new ARQException("CSV Boolean Results malformed, expected one of - true yes false no - but got " + str);
            }
       
        List<String> line2 = parser.parse1() ;
        if ( line2 != null ) {
            FmtLog.warn(log, "Extra rows: first is "+line2) ;
View Full Code Here

        {
            if ( components.get(i) != null )
                indexes[idx++] = i ;
        }
        if ( triples.size() != idx )
            throw new ARQException(String.format("Inconsistency: number of triples (%d) does not equal to number of indexes processed (%d)", triples.size(), idx)) ;
       
        ReorderProc proc = new ReorderProcIndexes(indexes) ;
       
        return proc ;
    }
View Full Code Here

    }
   
    public static Object build(String assemblerFile, Resource type)
    {
        if ( assemblerFile == null )
            throw new ARQException("No assembler file") ;
        Model spec = null ;
        try {
            spec = RDFDataMgr.loadModel(assemblerFile) ;
        } catch (Exception ex)
        { throw new ARQException("Failed reading assembler description: "+ex.getMessage()) ; }

        Resource root = null ;
        try {
            root = GraphUtils.findRootByType(spec, type) ;
            if ( root == null )
                return null ;
           
        } catch (TypeNotUniqueException ex)
        { throw new ARQException("Multiple types for: "+DatasetAssemblerVocab.tDataset) ; }
        return Assembler.general.open(root) ;
    }
View Full Code Here

     * that one RDFNode
     */
    public static RDFNode getExactlyOne(String qs, Dataset ds) {
        Query q = QueryFactory.create(qs) ;
        if ( q.getResultVars().size() != 1 )
            throw new ARQException("getExactlyOne: Must have exactly one result columns") ;
        String varname = q.getResultVars().get(0) ;
        QueryExecution qExec = QueryExecutionFactory.create(q, ds) ;
        return getExactlyOne(qExec, varname) ;
    }
View Full Code Here

    public static RDFNode getExactlyOne(QueryExecution qExec, String varname) {
        try {
            ResultSet rs = qExec.execSelect() ;

            if ( !rs.hasNext() )
                throw new ARQException("Not found: var ?" + varname) ;

            QuerySolution qs = rs.nextSolution() ;
            RDFNode r = qs.get(varname) ;
            if ( rs.hasNext() )
                throw new ARQException("More than one: var ?" + varname) ;
            return r ;
        }
        finally {
            qExec.close() ;
        }
View Full Code Here

            RDFNode r = qs.get(varname) ;
            if ( rs.hasNext() ) {
                QuerySolution qs2 = rs.next() ;
                RDFNode r2 = qs2.get(varname) ;
                if ( rs.hasNext() )
                    throw new ARQException("More than one: var ?" + varname + " -> " + r + ", " + r2 + ", ...") ;
                else
                    throw new ARQException("Found two matches: var ?" + varname + " -> " + r + ", " + r2) ;
            }
            return r ;
        }
        finally {
            qExec.close() ;
View Full Code Here

        if ( rFmt.equals(ResultsFormat.FMT_RDF_NT) )
        {
            outputAsRDF(outStream, "N-TRIPLES", resultSet) ;
            return ;
        }
        throw new ARQException("Unknown ResultSet format: "+rFmt);
    }
View Full Code Here

    /** 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()) ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.ARQException

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.