void setTerm(Term term) { if (this.term != null) throw new OntopiaRuntimeException("Cannot set parent term on variant more than once." + this + " " + this.term + " " + term); this.term = term; }
@Test public void testInvalidTM() throws IOException { try { readTopicMap(testdataDirectory, "errors", "badxtm.xtm"); Assert.fail("Invalid topic map was allowed to load"); } catch (OntopiaRuntimeException e) { Assert.assertTrue("Error not from XTM validation: " + e.getCause(), e.getCause() instanceof SAXParseException); } }
private static void checkProduct() { System.out.println(getInfo()); try { check(); System.out.println("Success: All required classes found."); } catch (OntopiaRuntimeException e) { System.err.println(e.getMessage()); } }
@Test public void testNothing() throws IOException { try { readTopicMap("various", "nothing.xtm"); Assert.fail("reading XML document with no topic map did not throw exception"); } catch (InvalidTopicMapException e) { } catch (net.ontopia.utils.OntopiaRuntimeException e) { if (!(e.getCause() instanceof org.xml.sax.SAXParseException)) throw e; } }
@Override public void _p_setTransaction(TransactionIF txn) { if (this.txn != null) throw new OntopiaRuntimeException("Cannot change the transaction of a persistent object."); this.txn = txn; }
public void testWithoutFulltextIndex() throws IOException, InvalidQueryException { load("int-occs.ltm", false); try { findNothing("value-like($foo, \"foo\")?"); fail("Value-like on a topicmap without a fulltext index should fail, but didn't"); } catch (OntopiaRuntimeException e) { if (!(e.getCause() instanceof OntopiaUnsupportedException)) { fail("Value-like on a topicmap without a fulltext index threw wrong exception"); } // expected } }
public void setReadOnly(boolean readonly) { if (readonlySet) throw new OntopiaRuntimeException("Readonly flag has already been set."); this.readonly = readonly; this.readonlySet = true; }
public static byte[][] getBytes(String[] s) { try { byte[][] b = new byte[s.length][]; for (int i=0; i < s.length; i++) { b[i] = s[i].getBytes("UTF-8"); } return b; } catch (UnsupportedEncodingException e) { throw new OntopiaRuntimeException(e); } }
public void close() { if (conn != null) { try { conn.close(); } catch (SQLException t) { throw new OntopiaRuntimeException(t); } conn = null; } }
private ActionInGroup getAction(String actionName) { ActionInGroup action = (ActionInGroup) currentActions.get(actionName); if (action == null) throw new OntopiaRuntimeException("Action " + actionName +" not found."); return action; }
public static byte[] getBytes(String s) { try { return s.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new OntopiaRuntimeException(e); } }
public void close() { try { if (in != null) in.close(); } catch (IOException e) { throw new OntopiaRuntimeException(e); } } }
public ChangeType getChangeType() { try { // if the primary key is null, then obviously the row has been // deleted if (rs.getObject(1) == null) return ChangeType.DELETE; // otherwise it's an update return ChangeType.UPDATE; } catch (SQLException e) { throw new OntopiaRuntimeException(e); } }
@Override public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { // Ignore throw new OntopiaRuntimeException(e); } }
protected void checkExistingName(String name) throws RuntimeException { if (params != null && params.containsKey(name)) throw new OntopiaRuntimeException("Parameter with name '" + name + "' already exists."); if (variables != null && variables.containsKey(name)) throw new OntopiaRuntimeException("Variable with name '" + name + "' already exists."); }
@Override public Object getValue() { try { return rs.getString(1); } catch (SQLException e) { throw new OntopiaRuntimeException(e); } }
protected void flush(Writer writer) { try { writer.flush(); } catch (IOException e) { throw new OntopiaRuntimeException(e); } }
@Override public Object mapRow(QueryResultIF result, int rowno) { if (rowno == 1) throw new OntopiaRuntimeException(MSG_QUERY_PRODUCED_MORE_THAN_ONE_ROW); return new Object(); } }, params);
@Override public boolean next() { if (rs == null) return false; try { return rs.next(); } catch (SQLException e) { throw new OntopiaRuntimeException(e); } }
@Override public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { // Ignore throw new OntopiaRuntimeException(e); } }