Search in sources :

Example 1 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class N3IndentedWriter method print.

public void print(String s) {
    try {
        writer.write(s);
        column += s.length();
    } catch (java.io.IOException ex) {
        throw new JenaException(ex);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) java.io(java.io)

Example 2 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class N3JenaWriterCommon method write.

/** Write the model out in N3, encoded in in UTF-8
	 * @see #write(Model,Writer,String)
	 */
@Override
public synchronized void write(Model model, OutputStream output, String base) {
    try {
        Writer w = new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));
        write(model, w, base);
        try {
            w.flush();
        } catch (IOException ioEx) {
            throw new JenaException(ioEx);
        }
    } catch (java.io.UnsupportedEncodingException ex) {
        System.err.println("Failed to create UTF-8 writer");
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) java.io(java.io)

Example 3 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class N3JenaWriterCommon method rdfListIterator.

protected Iterator<RDFNode> rdfListIterator(Resource r) {
    List<RDFNode> list = new ArrayList<>();
    for (; !r.equals(RDF.nil); ) {
        StmtIterator sIter = r.getModel().listStatements(r, RDF.first, (RDFNode) null);
        list.add(sIter.nextStatement().getObject());
        if (sIter.hasNext())
            // @@ need to cope with this (unusual) case
            throw new JenaException("N3: Multi valued list item");
        sIter = r.getModel().listStatements(r, RDF.rest, (RDFNode) null);
        r = (Resource) sIter.nextStatement().getObject();
        if (sIter.hasNext())
            throw new JenaException("N3: List has two tails");
    }
    return list.iterator();
}
Also used : JenaException(org.apache.jena.shared.JenaException)

Example 4 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class N3JenaWriterPP method testOneRefBNode.

protected boolean testOneRefBNode(RDFNode n) {
    if (!(n instanceof Resource))
        return false;
    Resource obj = (Resource) n;
    if (!obj.isAnon())
        return false;
    // In a list - done as list, not as embedded bNode.
    if (rdfListsAll.contains(obj))
        // RDF list (head or element)
        return false;
    StmtIterator pointsToIter = obj.getModel().listStatements(null, null, obj);
    if (!pointsToIter.hasNext())
        // Corrupt graph!
        throw new JenaException("N3: found object with no arcs!");
    pointsToIter.nextStatement();
    if (pointsToIter.hasNext())
        return false;
    if (N3JenaWriter.DEBUG)
        out.println("# OneRef: " + formatResource(obj));
    return true;
}
Also used : JenaException(org.apache.jena.shared.JenaException)

Example 5 with JenaException

use of org.apache.jena.shared.JenaException in project jena by apache.

the class AssemblerHelp method runAnyAssemblerConstructor.

private static void runAnyAssemblerConstructor(AssemblerGroup group, Statement s, Class<?> c) {
    try {
        Resource type = s.getSubject();
        Constructor<?> con = getResourcedConstructor(c);
        if (con == null)
            establish(group, type, c.newInstance());
        else
            establish(group, type, con.newInstance(s.getSubject()));
    } catch (Exception e) {
        throw new JenaException(e);
    }
}
Also used : JenaException(org.apache.jena.shared.JenaException) BadDescriptionMultipleRootsException(org.apache.jena.shared.BadDescriptionMultipleRootsException) BadDescriptionNoRootException(org.apache.jena.shared.BadDescriptionNoRootException) AmbiguousSpecificTypeException(org.apache.jena.assembler.exceptions.AmbiguousSpecificTypeException) JenaException(org.apache.jena.shared.JenaException)

Aggregations

JenaException (org.apache.jena.shared.JenaException)70 Model (org.apache.jena.rdf.model.Model)12 RDFReader (org.apache.jena.rdf.model.RDFReader)8 IOException (java.io.IOException)7 QueryException (org.apache.jena.query.QueryException)5 QueryParseException (org.apache.jena.query.QueryParseException)5 java.io (java.io)4 InputStream (java.io.InputStream)4 Reader (java.io.Reader)4 StringReader (java.io.StringReader)4 Graph (org.apache.jena.graph.Graph)4 ServletOutputStream (javax.servlet.ServletOutputStream)3 CmdException (jena.cmd.CmdException)3 AmbiguousSpecificTypeException (org.apache.jena.assembler.exceptions.AmbiguousSpecificTypeException)3 MediaType (org.apache.jena.atlas.web.MediaType)3 Triple (org.apache.jena.graph.Triple)3 BadDescriptionMultipleRootsException (org.apache.jena.shared.BadDescriptionMultipleRootsException)3 BadDescriptionNoRootException (org.apache.jena.shared.BadDescriptionNoRootException)3 ARQParser (org.apache.jena.sparql.lang.arq.ARQParser)3 FileNotFoundException (java.io.FileNotFoundException)2