SailQuery.java :  » RSS-RDF » sesame » org » openrdf » repository » sail » Java Open Source

Java Open Source » RSS RDF » sesame 
sesame » org » openrdf » repository » sail » SailQuery.java
/*
 * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
 *
 * Licensed under the Aduna BSD-style license.
 */
package org.openrdf.repository.sail;

import org.openrdf.query.Dataset;
import org.openrdf.query.impl.AbstractQuery;
import org.openrdf.query.parser.ParsedQuery;

/**
 * @author Arjohn Kampman
 */
public abstract class SailQuery extends AbstractQuery {

  private final ParsedQuery parsedQuery;

  private final SailRepositoryConnection con;

  protected SailQuery(ParsedQuery parsedQuery, SailRepositoryConnection con) {
    this.parsedQuery = parsedQuery;
    this.con = con;
  }

  public ParsedQuery getParsedQuery() {
    return parsedQuery;
  }

  protected SailRepositoryConnection getConnection() {
    return con;
  }

  /**
   * Gets the "active" dataset for this query. The active dataset is either the
   * dataset that has been specified using {@link #setDataset(Dataset)} or the
   * dataset that has been specified in the query, where the former takes
   * precedence over the latter.
   * 
   * @return The active dataset, or <tt>null</tt> if there is no dataset.
   */
  public Dataset getActiveDataset() {
    if (dataset != null) {
      return dataset;
    }

    // No external dataset specified, use query's own dataset (if any)
    return parsedQuery.getDataset();
  }

  @Override
  public String toString() {
    return parsedQuery.toString();
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.