use of org.apache.jena.shared.JenaException in project jena by apache.
the class TestReifier method getGraph.
@Override
public Graph getGraph() {
try {
Constructor<?> cons = getConstructor(graphClass, new Class[] {});
if (cons != null)
return (Graph) cons.newInstance();
Constructor<?> cons2 = getConstructor(graphClass, new Class[] { this.getClass() });
if (cons2 != null)
return (Graph) cons2.newInstance(this);
throw new JenaException("no suitable graph constructor found for " + graphClass);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new JenaException(e);
}
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class DatasetGraphAccessorHTTP method target.
protected final String target(Node name) {
if (!name.isURI())
throw new JenaException("Not a URI: " + name);
String guri = name.getURI();
// Encode
guri = IRILib.encodeUriComponent(guri);
return remote + "?" + HttpNames.paramGraph + "=" + guri;
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class TransactionHandlerContractTest method testExecuteInTransactionCatchesThrowable.
@SuppressWarnings("deprecation")
@ContractTest
public void testExecuteInTransactionCatchesThrowable() {
TransactionHandler th = getTransactionHandlerProducer().newInstance();
if (th.transactionsSupported()) {
Command cmd = new Command() {
@Override
public Object execute() throws Error {
throw new Error();
}
};
try {
th.executeInTransaction(cmd);
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.execute(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.calculate(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
}
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class GraphHelper method getGraph.
/**
* Answer an instance of <code>graphClass</code>. If <code>graphClass</code>
* has a constructor that takes a <code>ReificationStyle</code> argument,
* then that constructor is run on <code>style</code> to get the instance.
* Otherwise, if it has a # constructor that takes an argument of
* <code>wrap</code>'s class before the <code>ReificationStyle</code>, that
* constructor is used; this allows non-static inner classes to be used for
* <code>graphClass</code>, with <code>wrap</code> being the outer class
* instance. If no suitable constructor exists, a JenaException is thrown.
*
* @param wrap
* the outer class instance if graphClass is an inner class
* @param graphClass
* a class implementing Graph
* @return an instance of graphClass with the given style
* @throws RuntimeException
* or JenaException if construction fails
*/
public static Graph getGraph(Object wrap, Class<? extends Graph> graphClass) {
try {
Constructor<?> cons = getConstructor(graphClass, new Class[] {});
if (cons != null)
return (Graph) cons.newInstance(new Object[] {});
Constructor<?> cons2 = getConstructor(graphClass, new Class[] { wrap.getClass() });
if (cons2 != null)
return (Graph) cons2.newInstance(new Object[] { wrap });
throw new JenaException("no suitable graph constructor found for " + graphClass);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new JenaException(e);
}
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class LockMRSWLite method leaveCriticalSection.
@Override
public synchronized void leaveCriticalSection() {
if (count == 0)
throw new JenaException("Bad lock release - don't appear to be in a critical section");
if (count < 0) {
mrswLock.writeLock().unlock();
count = 0;
return;
} else {
mrswLock.readLock().unlock();
count--;
}
}
Aggregations