Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv24844
Modified Files:
SerializableInputStream.java
Log Message:
added a constructor with FileItem, which makes this a generic Wrapper for
several binary wrappers
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util
Index: SerializableInputStream.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/SerializableInputStream.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SerializableInputStream.java 16 Apr 2009 13:46:11 -0000 1.2
+++ SerializableInputStream.java 17 Apr 2009 20:17:27 -0000 1.3
@@ -12,13 +12,15 @@
import java.io.*;
import org.mmbase.util.logging.*;
+import org.apache.commons.fileupload.FileItem;
/**
* Sometimes you need an InputStream to be Serializable. This wraps
- * another InputStream.
+ * another InputStream, or some other representation of a 'binary'.
+ *
* @since MMBase-1.9
* @author Michiel Meeuwissen
- * @version $Id: SerializableInputStream.java,v 1.2 2009/04/16 13:46:11
michiel Exp $
+ * @version $Id: SerializableInputStream.java,v 1.3 2009/04/17 20:17:27
michiel Exp $
* @todo IllegalStateException or so, if the inputstreas is used (already).
*/
@@ -57,20 +59,31 @@
private InputStream wrapped;
+ private String name;
public SerializableInputStream(InputStream wrapped, long s) {
this.wrapped = wrapped;
this.size = s;
+ this.name = null;
}
public SerializableInputStream(byte[] array) {
this.wrapped = new ByteArrayInputStream(array);
this.size = array.length;
+ this.name = null;
+ }
+ public SerializableInputStream(FileItem fi) throws IOException {
+ this.wrapped = fi.getInputStream();
+ this.size = fi.getSize();
+ this.name = fi.getName();
}
public long getSize() {
return size;
}
+ public String getName() {
+ return name;
+ }
private void writeObject(java.io.ObjectOutputStream out) throws
IOException {
wrapped.reset();
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs