001    /*
002    
003      $Id: FileResponse.java,v 1.5 2003/05/02 20:29:47 culdesac Exp $
004    
005    */
006    
007    package sharpster.common;
008    
009    import sharpster.common.FileCollection;
010    import sharpster.common.Response;
011    import java.io.Serializable;
012    import java.io.ObjectStreamException;
013    
014    /**
015     * A response containg received files.
016     */
017    public class FileResponse extends Response implements java.io.Serializable {
018    
019        /**
020         * Object for holding the affected files.
021         */
022        private FileCollection files;
023    
024        /**
025         * Returns the type of this response.
026         */
027        public int getType() {
028            return sharpster.common.ResponseType.FILE;
029        }
030    
031        /**
032         * Returns the file collection.
033         *
034         * @return A file collection.
035         */
036        public FileCollection getFiles() {
037            return files;
038        }
039    
040        public Object writeReplace() throws ObjectStreamException {
041            files.removeAllPluginData();
042            return this;
043        }
044    
045        /**
046         * Sets the FileCollection.
047         *
048         * @param files The file collection to be set.
049         */
050        public void setFiles(FileCollection files) {
051            this.files = files;
052        }
053    
054        public String toString() {
055            String msg = super.toString();
056    
057            msg = "File response\n" + msg;
058            msg += "- Files: ";
059    
060            for(int i=0;i<files.getFileCount();i++) {
061                SharedFile file = files.getFile(i);
062                if(file != null) {
063                    msg += file.toString() + "\n         ";
064                }
065            }
066    
067            return msg;
068        }
069    }
070    
071