// Path: src/com/dydra/jena/DydraNTripleWriter.java
// public class DydraNTripleWriter extends NTripleWriter implements RDFWriter {
//   @NotNull
//   public static String formatQuery(@NotNull final String queryTemplate,
//                                    @Nullable final Node... nodes) {
//     if (nodes == null || nodes.length == 0) {
//       return queryTemplate;
//     }
//     else {
//       final String[] args = new String[nodes.length];
//       for (int i = 0; i < nodes.length; i++) {
//         args[i] = (nodes[i] != null) ? formatNode(nodes[i]) : "[]";
//       }
//       return String.format(queryTemplate, (Object[])args);
//     }
//   }
// 
//   @NotNull
//   public static String formatNode(@NotNull final Node node) {
//     if (node == null)
//       throw new NullPointerException("node cannot be null");
// 
//     if (node instanceof Node_Variable) {
//       return node.toString(); // special case for variables
//     }
// 
//     final Model model = ModelFactory.createDefaultModel();
//     try {
//       final RDFNode rdfNode = model.getRDFNode(node);
//       final StringWriter writer = new StringWriter();
//       NTripleWriter.writeNode(rdfNode, new PrintWriter(writer));
//       return writer.toString();
//     } finally { model.close(); }
//   }
// 
//   @NotNull
//   public static String formatNode(@NotNull final RDFNode node) {
//     if (node == null)
//       throw new NullPointerException("node cannot be null");
// 
//     final StringWriter writer = new StringWriter();
//     NTripleWriter.writeNode(node, new PrintWriter(writer));
//     return writer.toString();
//   }
// }
// 
// Path: src/com/dydra/jena/DydraQueryExecutionFactory.java
// public class DydraQueryExecutionFactory {
//   protected DydraQueryExecutionFactory() {}
// 
//   /**
//    * @param  query
//    * @param  repository
//    */
//   @NotNull
//   public static QueryExecution prepare(@NotNull final String query,
//                                        @NotNull final Repository repository) {
//     return new DydraQueryEngine(repository, query);
//   }
// 
//   /**
//    * @param  query
//    * @param  repository
//    * @param  defaultGraphURI
//    */
//   @NotNull
//   public static QueryExecution prepare(@NotNull final String query,
//                                        @NotNull final Repository repository,
//                                        @Nullable final String defaultGraphURI) {
//     DydraQueryEngine engine = new DydraQueryEngine(repository, query);
//     if (defaultGraphURI != null) {
//       engine.addDefaultGraph(defaultGraphURI);
//     }
//     return engine;
//   }
// 
//   /**
//    * @param  query
//    * @param  repository
//    * @param  defaultGraphURIs
//    * @param  namedGraphURIs
//    */
//   @NotNull
//   public static QueryExecution prepare(@NotNull final String query,
//                                        @NotNull final Repository repository,
//                                        @Nullable final List<String> defaultGraphURIs,
//                                        @Nullable final List<String> namedGraphURIs) {
//     DydraQueryEngine engine = new DydraQueryEngine(repository, query);
//     if (defaultGraphURIs != null) {
//       engine.setDefaultGraphURIs(defaultGraphURIs);
//     }
//     if (namedGraphURIs != null) {
//       engine.setNamedGraphURIs(namedGraphURIs);
//     }
//     return engine;
//   }
// }


import com.dydra.annotation.*;
import com.dydra.jena.DydraNTripleWriter;
import com.dydra.jena.DydraQueryExecutionFactory;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Node_Variable;
import com.hp.hpl.jena.graph.TripleMatch;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.update.Update;
import com.hp.hpl.jena.update.UpdateExecutionFactory;
import com.hp.hpl.jena.update.UpdateProcessor;
  /**
   * Prepares to execute the given SPARQL query on this repository.
   *
   * Note: this is a Jena-specific method.
   *
   * @param  queryTemplate
   *   the SPARQL query template, e.g. "SELECT * WHERE {%s ?p ?o} LIMIT 10"
   */
  @NotNull
  public QueryExecution prepareQueryExecution(@NotNull final String queryTemplate,
                                              @Nullable final Node... nodes) {
    if (queryTemplate == null)
      throw new NullPointerException("queryTemplate cannot be null");

    return prepareQueryExecution(DydraNTripleWriter.formatQuery(queryTemplate, nodes));
  }

  /**
   * Prepares to execute the given SPARQL query on this repository.
   *
   * Note: this is a Jena-specific method.
   *
   * @param  queryString
   *   the SPARQL query string, e.g. "SELECT * WHERE {?s ?p ?o} LIMIT 10"
   */
  @NotNull
  public QueryExecution prepareQueryExecution(@NotNull final String queryString) {
    if (queryString == null)
      throw new NullPointerException("queryString cannot be null");

// Path: src/com/dydra/jena/DydraNTripleWriter.java
// public class DydraNTripleWriter extends NTripleWriter implements RDFWriter {
//   @NotNull
//   public static String formatQuery(@NotNull final String queryTemplate,
//                                    @Nullable final Node... nodes) {
//     if (nodes == null || nodes.length == 0) {
//       return queryTemplate;
//     }
//     else {
//       final String[] args = new String[nodes.length];
//       for (int i = 0; i < nodes.length; i++) {
//         args[i] = (nodes[i] != null) ? formatNode(nodes[i]) : "[]";
//       }
//       return String.format(queryTemplate, (Object[])args);
//     }
//   }
// 
//   @NotNull
//   public static String formatNode(@NotNull final Node node) {
//     if (node == null)
//       throw new NullPointerException("node cannot be null");
// 
//     if (node instanceof Node_Variable) {
//       return node.toString(); // special case for variables
//     }
// 
//     final Model model = ModelFactory.createDefaultModel();
//     try {
//       final RDFNode rdfNode = model.getRDFNode(node);
//       final StringWriter writer = new StringWriter();
//       NTripleWriter.writeNode(rdfNode, new PrintWriter(writer));
//       return writer.toString();
//     } finally { model.close(); }
//   }
// 
//   @NotNull
//   public static String formatNode(@NotNull final RDFNode node) {
//     if (node == null)
//       throw new NullPointerException("node cannot be null");
// 
//     final StringWriter writer = new StringWriter();
//     NTripleWriter.writeNode(node, new PrintWriter(writer));
//     return writer.toString();
//   }
// }
// 
// Path: src/com/dydra/jena/DydraQueryExecutionFactory.java
// public class DydraQueryExecutionFactory {
//   protected DydraQueryExecutionFactory() {}
// 
//   /**
//    * @param  query
//    * @param  repository
//    */
//   @NotNull
//   public static QueryExecution prepare(@NotNull final String query,
//                                        @NotNull final Repository repository) {
//     return new DydraQueryEngine(repository, query);
//   }
// 
//   /**
//    * @param  query
//    * @param  repository
//    * @param  defaultGraphURI
//    */
//   @NotNull
//   public static QueryExecution prepare(@NotNull final String query,
//                                        @NotNull final Repository repository,
//                                        @Nullable final String defaultGraphURI) {
//     DydraQueryEngine engine = new DydraQueryEngine(repository, query);
//     if (defaultGraphURI != null) {
//       engine.addDefaultGraph(defaultGraphURI);
//     }
//     return engine;
//   }
// 
//   /**
//    * @param  query
//    * @param  repository
//    * @param  defaultGraphURIs
//    * @param  namedGraphURIs
//    */
//   @NotNull
//   public static QueryExecution prepare(@NotNull final String query,
//                                        @NotNull final Repository repository,
//                                        @Nullable final List<String> defaultGraphURIs,
//                                        @Nullable final List<String> namedGraphURIs) {
//     DydraQueryEngine engine = new DydraQueryEngine(repository, query);
//     if (defaultGraphURIs != null) {
//       engine.setDefaultGraphURIs(defaultGraphURIs);
//     }
//     if (namedGraphURIs != null) {
//       engine.setNamedGraphURIs(namedGraphURIs);
//     }
//     return engine;
//   }
// }


// Path: src/com/dydra/Repository.java
import com.dydra.annotation.*;
import com.dydra.jena.DydraNTripleWriter;
import com.dydra.jena.DydraQueryExecutionFactory;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Node_Variable;
import com.hp.hpl.jena.graph.TripleMatch;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.update.Update;
import com.hp.hpl.jena.update.UpdateExecutionFactory;
import com.hp.hpl.jena.update.UpdateProcessor;

  /**
   * Prepares to execute the given SPARQL query on this repository.
   *
   * Note: this is a Jena-specific method.
   *
   * @param  queryTemplate
   *   the SPARQL query template, e.g. "SELECT * WHERE {%s ?p ?o} LIMIT 10"
   */
  @NotNull
  public QueryExecution prepareQueryExecution(@NotNull final String queryTemplate,
                                              @Nullable final Node... nodes) {
    if (queryTemplate == null)
      throw new NullPointerException("queryTemplate cannot be null");

    return prepareQueryExecution(DydraNTripleWriter.formatQuery(queryTemplate, nodes));
  }

  /**
   * Prepares to execute the given SPARQL query on this repository.
   *
   * Note: this is a Jena-specific method.
   *
   * @param  queryString
   *   the SPARQL query string, e.g. "SELECT * WHERE {?s ?p ?o} LIMIT 10"
   */
  @NotNull
  public QueryExecution prepareQueryExecution(@NotNull final String queryString) {
    if (queryString == null)
      throw new NullPointerException("queryString cannot be null");

    return DydraQueryExecutionFactory.prepare(queryString, this);