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.collection.ampache;
20  
21  import java.util.Date;
22  
23  import sk.baka.ambient.commons.Immutable;
24  import sk.baka.ambient.commons.ThreadSafe;
25  import sk.baka.ambient.commons.ThreadUnsafe;
26  
27  /***
28   * Contains information about the Ampache server.
29   * 
30   * @author Martin Vysny
31   */
32  @Immutable
33  @ThreadSafe
34  public final class AmpacheInfo {
35  	/***
36  	 * @param token
37  	 *            The Ampache security token.
38  	 * @param apiVersion
39  	 *            The Ampache XML API version.
40  	 * @param lastUpdate
41  	 *            Last Update.
42  	 * @param lastAdd
43  	 *            Last Add.
44  	 * @param songs
45  	 *            Number of songs in the collection.
46  	 * @param artists
47  	 *            Number of artists in the collection.
48  	 * @param albums
49  	 *            Number of albums in the collection.
50  	 */
51  	public AmpacheInfo(String token, String apiVersion, Date lastUpdate,
52  			Date lastAdd, int songs, int artists, int albums) {
53  		super();
54  		this.token = token;
55  		this.apiVersion = apiVersion;
56  		this.lastUpdate = lastUpdate;
57  		this.lastAdd = lastAdd;
58  		this.songs = songs;
59  		this.artists = artists;
60  		this.albums = albums;
61  	}
62  
63  	/***
64  	 * The Ampache security token.
65  	 */
66  	public final String token;
67  	/***
68  	 * The Ampache XML API version.
69  	 */
70  	public final String apiVersion;
71  	/***
72  	 * Last Update.
73  	 */
74  	public final Date lastUpdate;
75  	/***
76  	 * Last Add.
77  	 */
78  	public final Date lastAdd;
79  	/***
80  	 * Number of songs in the collection.
81  	 */
82  	public final int songs;
83  	/***
84  	 * Number of artists in the collection.
85  	 */
86  	public final int artists;
87  	/***
88  	 * Number of albums in the collection.
89  	 */
90  	public final int albums;
91  
92  	@Override
93  	public String toString() {
94  		return "Ampache server token " + token + "; apiVersion " + apiVersion
95  				+ "; lastUpdated " + lastUpdate + "; lastAdd " + lastAdd
96  				+ "; songs " + songs + "; artists " + artists + "; albums "
97  				+ albums;
98  	}
99  
100 	/***
101 	 * Builds instances of {@link AmpacheInfo} class.
102 	 * 
103 	 * @author Martin Vysny
104 	 */
105 	@ThreadUnsafe
106 	public final static class Builder {
107 		/***
108 		 * The Ampache security token.
109 		 */
110 		public String token;
111 		/***
112 		 * The Ampache XML API version.
113 		 */
114 		public String apiVersion;
115 		/***
116 		 * Last Update.
117 		 */
118 		public Date lastUpdate;
119 		/***
120 		 * Last Add.
121 		 */
122 		public Date lastAdd;
123 		/***
124 		 * Number of songs in the collection.
125 		 */
126 		public int songs;
127 		/***
128 		 * Number of artists in the collection.
129 		 */
130 		public int artists;
131 		/***
132 		 * Number of albums in the collection.
133 		 */
134 		public int albums;
135 
136 		/***
137 		 * Builds new object instance.
138 		 * 
139 		 * @return non-<code>null</code> instance.
140 		 */
141 		public AmpacheInfo build() {
142 			return new AmpacheInfo(token, apiVersion, lastUpdate, lastAdd,
143 					songs, artists, albums);
144 		}
145 	}
146 }