001    /*
002    
003      $Id: MissingAccessResponse.java,v 1.4 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    
012    /**
013     * A response which specifies missing file accesses.
014     */
015    public class MissingAccessResponse extends Response 
016        implements java.io.Serializable {
017        
018        /**
019         * Identifies the access which were denied (read, write or remove).
020         */
021        private int access;
022        
023        /**
024         * A collection of the files that caused the response.
025         */
026        private FileCollection files;
027        
028        /**
029         * Returns the type of this response.
030         */
031        public int getType() {
032            return sharpster.common.ResponseType.MISSING_ACCESS;
033        }    
034    
035        /**
036         * Sets and integer identifying the access which 
037         * were denied (read, write or remove).
038         */
039        public void setAccess(int access) {
040            this.access = access;
041        }
042        
043        /**
044         * Returns an integer identifying the access which were 
045         * denied (read, write or remove).
046         */
047        public int getAccess() {
048            return access;
049        }
050        
051        /** 
052         * Returns the FileCollection with information about the 
053         * files which has caused the error.
054         */
055        public FileCollection getfiles() {
056            return files;
057        }
058        
059        /** 
060         * Sets the FileCollection containing information about the 
061         * files which has caused the error.
062         */
063        public void setFiles(FileCollection files) {
064            this.files = files;
065        }
066    
067        public String toString() {
068            String msg = super.toString();
069            String a = new String();
070            
071            if((access&4) != 0) a += "r";
072            if((access&2) != 0) a += "w";
073            if((access&1) != 0) a += "d";
074    
075            msg = "Missing access response\n" + msg;
076            msg += "- Access: " + a + "\n";
077            msg += "- Files: ";
078    
079            for(int i=0;i<files.getFileCount();i++) {
080                SharedFile file = files.getFile(i);
081                if(file != null) {
082                    msg += file.getFileName() + "\n         ";
083                }
084            }
085    
086            return msg;
087        }
088    }
089    
090    
091    
092    
093    
094    
095    
096