[Mulgara-svn] r472 - branches/nw-interface/src/jar/query/java/org/mulgara/query/operation
pag at mulgara.org
pag at mulgara.org
Thu Oct 11 17:08:56 UTC 2007
Author: pag
Date: 2007-10-11 12:08:54 -0500 (Thu, 11 Oct 2007)
New Revision: 472
Modified:
branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java
Log:
New option for an API to use an external InputStream
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java 2007-10-11 16:04:58 UTC (rev 471)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/DataTx.java 2007-10-11 17:08:54 UTC (rev 472)
@@ -54,6 +54,9 @@
/** Indicates that data is to be loaded locally from the client. */
private boolean local;
+
+ /** A stream to enable an API to load data directly. */
+ private InputStream overrideStream;
/**
* Create a new load command.
@@ -67,9 +70,19 @@
this.source = source;
this.destination = destination;
this.local = local;
+ overrideStream = null;
}
/**
+ * Allows an API to set the stream for loading, instead of getting it from the
+ * source URI.
+ * @param overrideStream The stream to use for loading data.
+ */
+ public void setOverrideStream(InputStream overrideStream) {
+ this.overrideStream = overrideStream;
+ }
+
+ /**
* @return The URI of the destination graph.
*/
public URI getServerURI() throws UnsupportedOperationException {
@@ -155,11 +168,11 @@
* @throws IOException An error while reading from the input stream.
* @return InputStream A new input stream which supplies uncompressed data.
*/
- private static InputStream adjustForCompression(URL fileLocation) throws IOException {
+ private InputStream adjustForCompression(URL fileLocation) throws IOException {
if (fileLocation == null) throw new IllegalArgumentException("File name is null");
- InputStream stream = fileLocation.openStream();
+ InputStream stream = (overrideStream == null) ? fileLocation.openStream() : overrideStream;
// wrap the stream in a decompressor if the suffixes indicate this should happen.
String fileName = fileLocation.toString();
More information about the Mulgara-svn
mailing list