View Javadoc

1   /*
2    * This file is part of NetPisteur.
3    * 
4    * Copyright 2001-2002 : Olivier CORNEC, David BOUANCHEAU, Looc LOPEZ,
5    *                       Gaetan BOUDARD, Mael LE LANNOU, Julien ROBINEAU
6    * 
7    * Copyright 2002-2003 : Olivier BRIENS, Simon DEZE, Florence FRIGOULT,
8    *                       Olivier JOURNEAULT, Francois MARTINIER, Damien RAUDE-MORVAN
9    * 
10   * Copyright 2004-2007 : Damien RAUDE-MORVAN
11   * 
12   * NetPisteur is free software; you can redistribute it and/or modify
13   * it under the terms of the GNU General Public License as published by
14   * the Free Software Foundation; either version 2 of the License, or
15   * (at your option) any later version.
16   *
17   * NetPisteur is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20   * GNU General Public License for more details.
21   *
22   * You should have received a copy of the GNU General Public License
23   * along with NetPisteur; if not, write to the Free Software
24   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
25   *
26   * $Author: drazzib $
27   * $Date: 2004-07-07 21:39:49 +0200 (Wed, 07 Jul 2004) $
28   * $Id: Utilisateur.java 24 2004-07-07 19:39:49Z drazzib $
29   */
30  package com.drazzib.netpisteur.configuration;
31  
32  import java.net.MalformedURLException;
33  import java.net.URL;
34  
35  import org.apache.commons.logging.Log;
36  import org.apache.commons.logging.LogFactory;
37  
38  /**
39   * <P>
40   * <STRONG>Description </STRONG>
41   * <P>
42   * Represents an User
43   * 
44   * 
45   * @since 2002/03/18
46   * @author NetPisteur Team
47   */
48  
49  public class Utilisateur extends Personne {
50  	
51  	private static Log log = LogFactory.getLog(Utilisateur.class);
52  
53  	/**
54  	 * Represents the password of an user
55  	 */
56  	private String motDePasse;
57  
58  	/**
59  	 * Represents the directory of an user
60  	 */
61  	private String separateur;
62  
63  	/**
64  	 * Represents the default URL of an user
65  	 */
66  	private String pageAccueil;
67  
68  	/**
69  	 * Utilisateur()
70  	 */
71  	public Utilisateur() {
72  		super();
73  		this.motDePasse = "";
74  		this.separateur = "";
75  		this.pageAccueil = "";
76  
77  	} // ----------Utilisateur()
78  
79  	/**
80  	 * Utilisateur(String unNom, String unPrenom, String unMotDePasse, String
81  	 * unSeparateur, URL unePageAccueil) : 2nd constructor
82  	 * 
83  	 * @param unNom
84  	 *            name of the user
85  	 * @param unPrenom
86  	 *            firstname of the user
87  	 * @param unMotDePasse
88  	 *            password of the person
89  	 * @param unSeparateur
90  	 *            directory of the person
91  	 * @param unePageAccueil
92  	 *            default url of the person
93  	 * 
94  	 */
95  	public Utilisateur(String unNom, String unPrenom, String unMotDePasse,
96  			String unSeparateur, String unePageAccueil) {
97  
98  		super(unNom, unPrenom);
99  		this.motDePasse = unMotDePasse;
100 		this.separateur = unSeparateur;
101 		this.pageAccueil = unePageAccueil;
102 
103 	} // ----------Utilisateur()
104 
105 	// /////////////////////////////////////
106 	// modification methods
107 
108 	/**
109 	 * setMotDePasse(String unMotDePasse) : set the password
110 	 * 
111 	 * @param unMotDePasse
112 	 *            a password
113 	 * 
114 	 */
115 	public void setMotDePasse(String unMotDePasse) {
116 
117 		this.motDePasse = unMotDePasse;
118 
119 	} // ----------setMotDePasse()
120 
121 	/**
122 	 * setSeparateur(String unSeparateur) : set the directory to store data
123 	 * 
124 	 * @param unSeparateur
125 	 *            a directory
126 	 * 
127 	 */
128 	public void setSeparateur(String unSeparateur) {
129 
130 		this.separateur = unSeparateur;
131 
132 	} // ----------setSeparateur()
133 
134 	/**
135 	 * setPageAccueil(String unePageAccueil) : set the user's default url
136 	 * 
137 	 * @param unePageAccueil
138 	 *            an Url
139 	 * 
140 	 */
141 	public void setPageAccueil(String unePageAccueil) {
142 
143 		this.pageAccueil = unePageAccueil;
144 
145 	} // ----------setPageAccueil()
146 
147 	// /////////////////////////////////////
148 	// access methods for attributes
149 
150 	/**
151 	 * getMotDePasse() : return the password
152 	 * 
153 	 * @return the password
154 	 * 
155 	 */
156 	public String getMotDePasse() {
157 
158 		return this.motDePasse;
159 
160 	} // ----------getMotDePasse()
161 
162 	public String getPage() {
163 
164 		return this.pageAccueil;
165 
166 	} // ----------getMotDePasse()
167 
168 	/**
169 	 * getSeparateur() : return the directory
170 	 * 
171 	 * @return the directory
172 	 * 
173 	 */
174 	public String getSeparateur() {
175 
176 		return this.separateur;
177 
178 	} // ----------getSeparateur()
179 
180 	/**
181 	 * getPageAccueil() : return the user's default url
182 	 * 
183 	 * @return the user's default url
184 	 * 
185 	 */
186 	public URL getPageAccueil() {
187 		URL startPage = null;
188 
189 		try {
190 
191 			if (this.pageAccueil == null) {
192 
193 				log.info("Page d'accueil non definie : page accueil par defaut");
194 				startPage = new URL("http://www.yahoo.fr/");
195 			}
196 
197 			else {
198 				startPage = new URL(this.pageAccueil);
199 
200 			}
201 
202 		} catch (MalformedURLException ex) {
203 			log.error("URL Invalide : " + this.pageAccueil);
204 		}
205 
206 		return startPage;
207 
208 	} // ----------getPageAccueil()
209 
210 	// /////////////////////////////////////
211 	// access methods for attributes
212 	
213 	public boolean equals(Object arg0) {
214 		if (arg0 == this)
215 			return true;
216 		
217 		if (arg0 instanceof Utilisateur)
218 		{
219 			if (this.getNom() != null
220 				&& this.getNom().equals(((Utilisateur)arg0).getNom())
221 				&& this.getPrenom() != null
222 				&& this.getPrenom().equals(((Utilisateur)arg0).getPrenom()))
223 			{
224 				return true;
225 			}
226 		}
227 
228 		return false;
229 	}
230 	
231 	public String toString() {
232 		StringBuffer oOut = new StringBuffer();
233 		
234 		oOut.append("[Utilisateur]");
235 		oOut.append("Nom:").append(this.getNom()).append("/");
236 		oOut.append("Prenom:").append(this.getPrenom()).append("/");
237 		oOut.append("Page:").append(this.getPage()).append("/");
238 		oOut.append("Separateur:").append(this.getSeparateur());
239 		
240 		return oOut.toString();
241 	}
242 
243 }// ----------------------------------------------------------------------Utilisateur
244