All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.deri.xquery.DatasetResults Maven / Gradle / Ivy

/**
 *
 * Copyright (C) 2011, NUI Galway.
 * All rights reserved.
 *
 * The software in this package is published under the terms of the BSD style license a copy of which has been included
 * with this distribution in the bsb_license.txt file and/or available on NUI Galway Server at
 * http://xsparql.deri.ie/license/bsd_license.txt
 *
 * Created: 09 February 2011, Reasoning and Querying Unit (URQ), Digital Enterprise Research Institute (DERI) on behalf of
 * NUI Galway.
 */
package org.deri.xquery;

import java.util.*;
import com.hp.hpl.jena.query.*;

/**
 * class for datasets and results of datasets for the parser.
 * 
 * @author Nuno Lopes 
 * 
 */
public class DatasetResults {

  private Dataset scopedDataset;
  private Stack scopedDatasetResults;

  /**
   * Creates a new DatasetResults instance.
   * 
   * @param ds
   *          a Dataset value
   */
  public DatasetResults(Dataset ds) {
    scopedDataset = ds;

    scopedDatasetResults = new Stack();

  }

  /**
   * Converts a ResultSet into a ResultSetRewindable.
   * 
   * @param rs
   *          a ResultSet value
   * @return a ResultSetRewindable value
   */
  public ResultSetRewindable addResults(ResultSet rs) {
    ResultSetRewindable res = ResultSetFactory.makeRewindable(rs);
    scopedDatasetResults.add(res);

    return res;
  }

  /**
   * return the current ResultSet.
   * 
   * @return a ResultSetRewindable value
   */
  public ResultSetRewindable getResults() {
    return scopedDatasetResults.peek();
  }

  /**
   * Destroy the current ResultSet.
   * 
   * @return a ResultSetRewindable value
   */
  public ResultSetRewindable popResults() {
    return scopedDatasetResults.pop();
  }

  /**
   * return the current Scoped Dataset.
   * 
   * @return a Dataset value
   */
  public Dataset getDataset() {
    return scopedDataset;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy