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);
}
}
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");
}
}
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();
}
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;
}
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);
}
}
Aggregations