001 /*
002
003 $Id: MissingFilesResponse.java,v 1.5 2003/03/24 17:20:42 culdesac Exp $
004
005 */
006
007 package sharpster.common;
008
009 import sharpster.common.FileCollection;
010 import sharpster.common.Response;
011 import sharpster.common.ResponseType;
012
013 /**
014 * A response which specifies missing files.
015 */
016 public class MissingFilesResponse extends Response
017 implements java.io.Serializable {
018
019 /**
020 * Represents the location of the missing file.
021 */
022 private int location;
023
024 /**
025 * A collection of the missing files.
026 */
027 private FileCollection files;
028
029 /**
030 * Returns the type of this response.
031 */
032 public int getType() {
033 return ResponseType.MISSING_FILES;
034 }
035
036 /**
037 * Sets the location of a missing file.
038 */
039 public void setLocation(int location) {
040 this.location = location;
041 }
042
043 /**
044 * Returns the location of the missing file.
045 */
046 public int getLocation() {
047 return location;
048 }
049
050 /**
051 * Returns the FileCollection containing information about the missing files.
052 */
053 public FileCollection getfiles() {
054 return files;
055 }
056
057 /**
058 *
059 */
060 public boolean hasMissingFiles() {
061 return (files.getFileCount()!=0);
062 }
063
064 /**
065 * Sets the FileCollection containing information about the missing files.
066 */
067 public void setFiles(FileCollection files) {
068 this.files = files;
069 }
070
071 public String toString() {
072 String msg = super.toString();
073
074 msg = "Missing files response\n" + msg;
075 msg += "- Origin: " + getOrigin() + "\n";
076
077 if(location == FileLocation.LOCAL_HDD) {
078 msg += "- Location: Local HDD\n";
079 }
080 else if(location == FileLocation.LOCAL_CVS) {
081 msg += "- Location: Local CVS\n";
082 }
083 else if(location == FileLocation.LOCAL_MEMORY) {
084 msg += "- Location: Local Memory\n";
085 }
086 else {
087 msg += "- Location: Remote CVS\n";
088 }
089 msg += "- Files: ";
090
091 for(int i=0;i<files.getFileCount();i++) {
092 SharedFile file = files.getFile(i);
093 if(file != null) {
094 msg += file.getFileName() + "\n ";
095 }
096 }
097
098 return msg;
099 }
100 }