001    /*
002    
003      $Id: Response.java,v 1.5 2003/05/08 18:58:28 ndulgheru Exp $
004    
005    */
006    
007    package sharpster.common;
008    
009    /**
010     * A Reponse containing information about the users which are 
011     * available on the network.
012     */
013    public abstract class Response implements java.io.Serializable {
014        
015        /**
016         * Identifies the module which has created the response.
017         */
018        private String origin;
019    
020        /**
021         * Identifies the user on whose deamon the message was created
022         * (can be the user of the local client or an external user).
023         */
024        private String user;
025    
026        /**
027         * Is true if the response is an error message.
028         */
029        private boolean error;
030     
031        /**
032         * Get the type of this response.
033         */
034        public abstract int getType();
035      
036        public Response() {
037            error = false;
038            user = new String();
039            origin = new String();  
040        }
041        
042        /**
043         *  Sets the error status of this response object.
044         *
045         * @param error Error status to set
046         */
047        public void setError(boolean error) {
048            this.error = error;
049        }
050    
051        /**
052         * Get the error status of this response object.
053         *
054         * @return The error status
055         */
056        public boolean isError() {
057            return error;
058        }  
059       
060    
061        /**
062         * Set the name of the module which has created this response.
063         *
064         * @param origin A string identifying the origin.
065         */
066        public void setOrigin(String origin) {
067            this.origin = new String(origin);
068        }
069    
070        /**
071         * Returns the name of the module which has created this response.
072         *
073         * @return A string identifying the origin
074         */
075        public String getOrigin() {
076            return origin;
077        }
078    
079        /**
080         * Sets the user from whose deamon the response were created.
081         *
082         * @param user A String identifying the user
083         */
084        public void setUser(String user) {
085            this.user = new String(user);
086        } 
087    
088        /**
089         * Returns the user from whose deamon the response were created.
090         *
091         * @return A string identifying the user
092         */
093        public String getUser() {
094            return user;
095        }
096    
097        public String toString() {
098            String msg = new String();
099            
100            msg += "- Origin: " + getOrigin() + "\n";
101            msg += "- User: " + user + "\n";
102            if(error) msg += "- Error: " + error + "\n";
103    
104            return msg;
105        }
106    }
107    
108    
109    
110    
111    
112