Search in sources :

Example 1 with AbstractQueryImpl

use of org.apache.jackrabbit.core.query.AbstractQueryImpl in project jackrabbit by apache.

the class SearchManager method createQueryInstance.

/**
     * Creates a new instance of an {@link AbstractQueryImpl} which is not
     * initialized.
     *
     * @return an new query instance.
     * @throws RepositoryException if an error occurs while creating a new query
     *                             instance.
     */
protected AbstractQueryImpl createQueryInstance() throws RepositoryException {
    try {
        String queryImplClassName = handler.getQueryClass();
        Object obj = Class.forName(queryImplClassName).newInstance();
        if (obj instanceof AbstractQueryImpl) {
            return (AbstractQueryImpl) obj;
        } else {
            throw new IllegalArgumentException(queryImplClassName + " is not of type " + AbstractQueryImpl.class.getName());
        }
    } catch (Throwable t) {
        throw new RepositoryException("Unable to create query: " + t.toString(), t);
    }
}
Also used : AbstractQueryImpl(org.apache.jackrabbit.core.query.AbstractQueryImpl) RepositoryException(javax.jcr.RepositoryException)

Example 2 with AbstractQueryImpl

use of org.apache.jackrabbit.core.query.AbstractQueryImpl in project jackrabbit by apache.

the class SearchManager method createQuery.

/**
     * Creates a query object that can be executed on the workspace.
     *
     * @param sessionContext component context of the current session
     * @param statement the actual query statement.
     * @param language  the syntax of the query statement.
     * @param node      a nt:query node where the query was read from or
     *                  <code>null</code> if it is not a stored query.
     * @return a <code>Query</code> instance to execute.
     * @throws InvalidQueryException if the query is malformed or the
     *                               <code>language</code> is unknown.
     * @throws RepositoryException   if any other error occurs.
     */
public Query createQuery(SessionContext sessionContext, String statement, String language, Node node) throws InvalidQueryException, RepositoryException {
    AbstractQueryImpl query = createQueryInstance();
    query.init(sessionContext, handler, statement, language, node);
    return query;
}
Also used : AbstractQueryImpl(org.apache.jackrabbit.core.query.AbstractQueryImpl)

Aggregations

AbstractQueryImpl (org.apache.jackrabbit.core.query.AbstractQueryImpl)2 RepositoryException (javax.jcr.RepositoryException)1