public int getColumnIndex(Variable column) throws TuplesException { if (column.equals(subject)) { return 0; } else if (column.equals(predicate)) { return 1; } else if (column.equals(object)) { return 2; } else { throw new TuplesException("Variable " + column + " not valid on Statements"); } }
public void beforeFirst(long[] prefix, int suffixTruncation) throws TuplesException { if (prefix.length == 0 && suffixTruncation == 0) { answer.beforeFirst(); } else { throw new TuplesException( "LocalizedTuples.beforeFirst not implemented for prefix length " + prefix.length + " and suffix length " + suffixTruncation); } }
public int getRowCardinality() throws TuplesException { if (getRowCount() > 1) { return Cursor.MANY; } switch ((int) getRowCount()) { case 0: return Cursor.ZERO; case 1: return Cursor.ONE; default: throw new TuplesException("Illegal row count: " + getRowCount()); } }
/** * Close this {@link Query}, and the underlying {@link Answer} objects. */ public void close() throws TuplesException { answer.close(); answer = null; if (mutableVariableList != null) { for (SelectElement v: mutableVariableList) { if (v instanceof AggregateFunction) { ((AggregateFunction)v).getQuery().close(); } } } }
public Constraint rewrite(ConstraintElement newModel, Constraint constraint) throws Exception { return new ConstraintImpl(constraint.getElement(0), constraint.getElement(1), constraint.getElement(2), newModel); } }),
public Object getObject(String columnName) throws TuplesException { return getObject(getColumnIndex(new Variable(columnName))); }
/** * @param columnName a column name; note that because the unconstrained * {@link Answer} has no columns, there's no valid value for this * @return never * @throws TuplesException always, because there is no valid * <var>column</var> parameter */ public Object getObject(String columnName) throws TuplesException { throw new TuplesException("No column named " + columnName); }
public Tuples resolve(QueryEvaluationContext context, ModelExpression modelExpr, ConstraintExpression constraintExpr) throws Exception { ConstraintIn constraint = (ConstraintIn)constraintExpr; ModelExpression graph; if (constraint.getGraph() instanceof URIReferenceImpl) { graph = new ModelResource(((URIReferenceImpl)constraint.getGraph())); } else { assert constraint.getGraph() instanceof Variable; graph = new ModelVariable((Variable)constraint.getGraph()); } return ConstraintOperations.resolveConstraintExpression(context, graph, constraint.getConstraintParam()); } }),
/** * Return true if the variables of a ModelVariable are equal. * @param object ModelVariable to test equality. * @return true if the variables of a ModelVariable are equal. */ public boolean equals(Object object) { if (object == null) return false; if (object == this) return true; if (!(object instanceof ModelVariable)) return false; ModelVariable modelVar = (ModelVariable)object; return variable.equals(modelVar.variable); }
/** * Get a constraint element by index. * * @param index The constraint element to retrieve, from 0 to 3. * @return The constraint element referred to by index. */ public ConstraintElement getElement(int index) { return unanchoredConstraint.getElement(index); }
/** * The text representation of the URI. * @return the text representation of the URI. */ public String toString() { return variable.toString(); }
/** * A count looks like <code>count()</code> surrounding the query it wraps. * * @return RETURNED VALUE TO DO */ public String toString() { return "count(" + getQuery() + ")"; } }
/** * @see org.mulgara.connection.Connection#execute(org.mulgara.query.Query) */ public Answer execute(Query cmd) throws QueryException, TuplesException { return (Answer)cmd.execute(this); }
/** * @return {@inheritDoc} */ public Object clone() { return new UnconstrainedAnswer(row); }
/** * Get all constraints which are variables. For back-compatibility, this * method currently ignores the fourth element of the triple. * * @return A set containing all variable constraints. */ public Set<Variable> getVariables() { return transConstraint.getVariables(); }
public int getRowCardinality() throws TuplesException { switch ((int)getRowCount()) { case 0: return Cursor.ZERO; case 1: return Cursor.ONE; default: return Cursor.MANY; } }
/** * Unconstrained has no columns that can be unbound. * * @throws TuplesException always, because there's no possible valid value * for the <var>column</var> parameter */ public boolean isColumnEverUnbound(int column) throws TuplesException { throw new TuplesException("No such column " + column); }
public boolean isColumnEverUnbound(int column) throws TuplesException { try { return columnEverUnbound[column]; } catch (ArrayIndexOutOfBoundsException e) { throw new TuplesException("No such column " + column, e); } }