use of javax.jcr.query.InvalidQueryException in project jackrabbit by apache.
the class QueryObjectModelFactoryImpl method createQuery.
/**
* Creates a query with one or more selectors.
* <p>
* If <code>source</code> is a selector, that selector is the <i>default
* selector</i> of the query. Otherwise the query does not have a default
* selector.
*
* @param source the node-tuple source; non-null
* @param constraint the constraint, or null if none
* @param orderings zero or more orderings; null is equivalent to a
* zero-length array
* @param columns the columns; null is equivalent to a zero-length array
* @return the query; non-null
* @throws javax.jcr.query.InvalidQueryException
* if the query is invalid
* @throws javax.jcr.RepositoryException if the operation otherwise fails
*/
public QueryObjectModel createQuery(Source source, Constraint constraint, Ordering[] orderings, Column[] columns) throws InvalidQueryException, RepositoryException {
if (source == null) {
throw new InvalidQueryException("source must not be null");
}
if (!(source instanceof SourceImpl)) {
throw new RepositoryException("Unknown Source implementation");
}
if (constraint != null && !(constraint instanceof ConstraintImpl)) {
throw new RepositoryException("Unknown Constraint implementation");
}
OrderingImpl[] ords;
if (orderings != null) {
ords = new OrderingImpl[orderings.length];
for (int i = 0; i < orderings.length; i++) {
if (!(orderings[i] instanceof OrderingImpl)) {
throw new RepositoryException("Unknown Ordering implementation");
}
ords[i] = (OrderingImpl) orderings[i];
}
} else {
ords = OrderingImpl.EMPTY_ARRAY;
}
ColumnImpl[] cols;
if (columns != null) {
cols = new ColumnImpl[columns.length];
for (int i = 0; i < columns.length; i++) {
if (!(columns[i] instanceof ColumnImpl)) {
throw new RepositoryException("Unknown Column implementation");
}
cols[i] = (ColumnImpl) columns[i];
}
} else {
cols = ColumnImpl.EMPTY_ARRAY;
}
QueryObjectModelTree qomTree = new QueryObjectModelTree(resolver, (SourceImpl) source, (ConstraintImpl) constraint, ords, cols);
return createQuery(qomTree);
}
Aggregations