View Javadoc

1   /***
2    *     Ambient - A music player for the Android platform
3    Copyright (C) 2007 Martin Vysny
4    
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9    
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14  
15   You should have received a copy of the GNU General Public License
16   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package sk.baka.ambient.activity;
20  
21  import java.io.Serializable;
22  
23  import sk.baka.ambient.R;
24  import sk.baka.ambient.commons.Bind;
25  import sk.baka.ambient.commons.MiscUtils;
26  
27  /***
28   * Stores the ampache client configuration.
29   * 
30   * @author Martin Vysny
31   */
32  public final class AmpacheClientBean implements Serializable {
33  
34  	private static final long serialVersionUID = -7484521864864745310L;
35  
36  	/***
37  	 * Host name of the ampache server.
38  	 */
39  	@Bind(captionId = -1, viewId = R.id.ampacheServer)
40  	public String host;
41  
42  	/***
43  	 * Optional user name for ampache.
44  	 */
45  	@Bind(captionId = -1, viewId = R.id.ampacheUser)
46  	public String username;
47  
48  	/***
49  	 * Password for ampache.
50  	 */
51  	@Bind(captionId = -1, viewId = R.id.ampachePassword)
52  	public String password;
53  
54  	/***
55  	 * Checks if the data in this bean are valid.
56  	 * 
57  	 * @return <code>true</code> if a connection to the Ampache server can
58  	 *         potentially be performed.
59  	 */
60  	public boolean isValid() {
61  		return !MiscUtils.isEmptyOrWhitespace(host);
62  	}
63  
64  	/***
65  	 * Returns a http:// URL of the ampache server.
66  	 * 
67  	 * @return the URL of the server.
68  	 */
69  	public String getURL() {
70  		return "http://" + host + "/ampache";
71  	}
72  }