/** * The return value of this class is not comparable, so always throw an exception. * @return never returns a value. * @throws QueryException To indicate that this class cannot be compared. */ protected ComparableExpression resolveComparable() throws QueryException { throw new QueryException("Type error: datatypes are IRIs which cannot be compared for anything but equality"); }
/** * Resolve this variable in its current context * @return An expression value wrapping the data bound to this point * @throws QueryException Indicates an error getting data out of the context, or globalizing. */ public RDFTerm resolve() throws QueryException { long gNode = getLocalContext().getColumnValue(varIndex); Value node; try { node = getContextOwner().getCurrentContext().globalize(gNode); } catch (QueryException qe) { throw new QueryException("Unable to globalize variable " + name + " from id <" + gNode + ">", qe.getCause()); } return convertToExpr(node); }
/** @see org.mulgara.query.filter.value.AbstractAccessorFn#getType() */ public IRI getType() throws QueryException { throw new QueryException("Invalid to get a type IRI on an IRI."); }
/** @see org.mulgara.query.filter.value.AbstractAccessorFn#getLexical() */ public String getLexical() throws QueryException { throw new QueryException("Invalid to get lexical information on an IRI."); }
/** @see org.mulgara.query.filter.value.AbstractAccessorFn#getLang() */ public SimpleLiteral getLang() throws QueryException { throw new QueryException("Invalid to get a language on an IRI."); }
/** @see org.mulgara.query.filter.value.AbstractAccessorFn#test(org.mulgara.query.filter.Context) */ public boolean test(Context context) throws QueryException { throw new QueryException("Invalid to get an effective boolean value on an IRI."); }
public boolean ebv(String data) throws QueryException { throw new QueryException("Unable to convert a date to a boolean"); } public Object toData(String r) { return DateTime.parseDate(r); }
/**@see org.mulgara.query.filter.Context#getColumnValue(int) */ public long getColumnValue(int columnNumber) throws QueryException { if (columnNumber >= columnNames.size()) throw new QueryException("Unexpected column: " + columnNumber); Value v = rows[rowNumber][columnNumber]; if (v == null) throw new QueryException("Unbound column: " + columnNumber); return localizer.get(v); }
/** @see org.mulgara.query.filter.Context#globalize(long) */ public Value globalize(long node) throws QueryException { Value n = globalizer.get(node); if (n == null) throw new QueryException("Unable to globalize id <" + node + ">"); return n != Null.NULL ? n : null; }
/** @see org.mulgara.query.filter.Context#isBound(int) */ public boolean isBound(int columnNumber) throws QueryException { if (columnNumber >= columnNames.size()) throw new QueryException("Unexpected column: " + columnNumber); return rows[rowNumber][columnNumber] != null; }
public int compare(Object left, Object right) throws QueryException { if (!(right instanceof Boolean)) throw new QueryException("Type Error: Cannot compare a boolean to a: " + right.getClass()); return ((Boolean)left).compareTo((Boolean)right); } public ValueLiteral newLiteral(Object data) { return new Bool((Boolean)data); }
public int compare(Object left, Object right) throws QueryException { if (!(right instanceof Date)) throw new QueryException("Type Error: Cannot compare a Date to a: " + right.getClass()); return ((Date)left).compareTo((Date)right); } public ValueLiteral newLiteral(Object data) { return new DateTime((Date)data); }
public int compare(Object left, Object right) throws QueryException { if (!(right instanceof String)) throw new QueryException("Type Error: Cannot compare a String to a: " + right.getClass()); return ((String)left).compareTo((String)right); } public ValueLiteral newLiteral(Object data) { return new TypedLiteral((String)data, SimpleLiteral.STRING_TYPE.getValue()); }
public int compare(Object left, Object right) throws QueryException { if (!(right instanceof Number)) throw new QueryException("Type Error: Cannot compare a double to a: " + right.getClass()); return ((Double)left).compareTo(((Number)right).doubleValue()); } public ValueLiteral newLiteral(Object data) { return new NumericLiteral((Double)data); }
public int compare(Object left, Object right) throws QueryException { if (!(right instanceof Number)) throw new QueryException("Type Error: Cannot compare a decimal number to a: " + right.getClass()); Long lleft = ((Number)left).longValue(); return lleft.compareTo(((Number)right).longValue()); } public ValueLiteral newLiteral(Object data) { return new NumericLiteral((Number)data); }
public int compare(Object left, Object right) throws QueryException { Float fleft = (Float)left; if (!(right instanceof Number)) throw new QueryException("Type Error: Cannot compare a float to a: " + right.getClass()); // if right has more precision, then promote lfloat, and compare the other way around if (right instanceof Double) return -((Double)right).compareTo(fleft.doubleValue()); return fleft.compareTo(((Number)right).floatValue()); } public ValueLiteral newLiteral(Object data) { return new NumericLiteral((Float)data); }
private void assertExternallyManagedXA() throws QueryException { if (transactionFactory == null) { transactionFactory = externalFactory = transactionManager.getExternalFactory(); } else if (externalFactory == null) { throw new QueryException("Attempt to use external transaction control in internally managed session"); } }
/** * Resolve this variable in its current context * @return An expression value wrapping the data bound to this point * @throws QueryException Indicates an error getting data out of the context, or globalizing. */ public ComparableExpression resolveComparable() throws QueryException { RDFTerm v = resolve(); if (!(v instanceof ComparableExpression)) throw new QueryException("Type Error: Cannot compare against a: " + v.getClass().getSimpleName()); return (ComparableExpression)v; }
/** * Tests if a given column is bound in the current context. * @return <code>true</code> iff the column exists and is bound. */ public boolean isBound(int columnNumber) throws QueryException { try { return columnNumber != NOT_BOUND && tuples.getColumnValue(columnNumber) != Tuples.UNBOUND; } catch (Exception te) { // TuplesException throw new QueryException("Error resolving column", te); } }
public void close() throws QueryException { logger.debug("Closing session"); try { transactionManager.closingSession(this); transactionFactory = null; } catch (MulgaraTransactionException em2) { logger.error("Error force-closing session", em2); throw new QueryException("Error force-closing session.", em2); } }