initial implementation for JAL-718
[jalview.git] / src / jalview / io / packed / SimpleDataProvider.java
diff --git a/src/jalview/io/packed/SimpleDataProvider.java b/src/jalview/io/packed/SimpleDataProvider.java
new file mode 100644 (file)
index 0000000..6b00ddb
--- /dev/null
@@ -0,0 +1,49 @@
+package jalview.io.packed;
+
+import jalview.io.FileParse;
+
+/**
+ * minimal implementation of the DataProvider interface.
+ * Allows a FileParse datasource to be specified as one of the DataProvider.JvDataType content types, with or without some other associated object as external reference.
+ */
+public class SimpleDataProvider implements DataProvider
+{
+  DataProvider.JvDataType jvtype;
+
+  FileParse source;
+
+  Object assocseq;
+
+  /**
+   * create a SimpleDataProvider
+   * @param type - contents of resource accessible via fp
+   * @param fp - datasource
+   * @param assoc - external object that fp's content should be associated with (may be null)
+   */
+  public SimpleDataProvider(DataProvider.JvDataType type, FileParse fp,
+          Object assoc)
+  {
+    jvtype = type;
+    source = fp;
+    assocseq = assoc;
+  }
+
+  @Override
+  public FileParse getDataSource()
+  {
+    return source;
+  }
+
+  @Override
+  public Object getSequenceTarget()
+  {
+    return assocseq;
+  }
+
+  @Override
+  public DataProvider.JvDataType getType()
+  {
+    return jvtype;
+  }
+
+}
\ No newline at end of file