src/org/sonews/storage/Group.java
changeset 46 28870db3b9fd
parent 37 74139325d305
child 47 e118b4d60029
     1.1 --- a/src/org/sonews/storage/Group.java	Sun Aug 29 18:17:37 2010 +0200
     1.2 +++ b/src/org/sonews/storage/Group.java	Sat Sep 10 20:20:19 2011 +0200
     1.3 @@ -15,7 +15,6 @@
     1.4   *   You should have received a copy of the GNU General Public License
     1.5   *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     1.6   */
     1.7 -
     1.8  package org.sonews.storage;
     1.9  
    1.10  import java.sql.SQLException;
    1.11 @@ -29,8 +28,7 @@
    1.12   * @since sonews/0.5.0
    1.13   */
    1.14  // TODO: This class should not be public!
    1.15 -public class Group extends Channel
    1.16 -{
    1.17 +public class Group extends Channel {
    1.18  
    1.19  	private long id = 0;
    1.20  	private int flags = -1;
    1.21 @@ -39,8 +37,7 @@
    1.22  	/**
    1.23  	 * @return List of all groups this server handles.
    1.24  	 */
    1.25 -	public static List<Channel> getAll()
    1.26 -	{
    1.27 +	public static List<Channel> getAll() {
    1.28  		try {
    1.29  			return StorageManager.current().getGroups();
    1.30  		} catch (StorageBackendException ex) {
    1.31 @@ -53,16 +50,14 @@
    1.32  	 * @param name
    1.33  	 * @param id
    1.34  	 */
    1.35 -	public Group(final String name, final long id, final int flags)
    1.36 -	{
    1.37 +	public Group(final String name, final long id, final int flags) {
    1.38  		this.id = id;
    1.39  		this.flags = flags;
    1.40  		this.name = name;
    1.41  	}
    1.42  
    1.43  	@Override
    1.44 -	public boolean equals(Object obj)
    1.45 -	{
    1.46 +	public boolean equals(Object obj) {
    1.47  		if (obj instanceof Group) {
    1.48  			return ((Group) obj).id == this.id;
    1.49  		} else {
    1.50 @@ -71,73 +66,61 @@
    1.51  	}
    1.52  
    1.53  	public Article getArticle(long idx)
    1.54 -		throws StorageBackendException
    1.55 -	{
    1.56 +			throws StorageBackendException {
    1.57  		return StorageManager.current().getArticle(idx, this.id);
    1.58  	}
    1.59  
    1.60  	public List<Pair<Long, ArticleHead>> getArticleHeads(final long first, final long last)
    1.61 -		throws StorageBackendException
    1.62 -	{
    1.63 +			throws StorageBackendException {
    1.64  		return StorageManager.current().getArticleHeads(this, first, last);
    1.65  	}
    1.66  
    1.67  	public List<Long> getArticleNumbers()
    1.68 -		throws StorageBackendException
    1.69 -	{
    1.70 +			throws StorageBackendException {
    1.71  		return StorageManager.current().getArticleNumbers(id);
    1.72  	}
    1.73  
    1.74  	public long getFirstArticleNumber()
    1.75 -		throws StorageBackendException
    1.76 -	{
    1.77 +			throws StorageBackendException {
    1.78  		return StorageManager.current().getFirstArticleNumber(this);
    1.79  	}
    1.80  
    1.81 -	public int getFlags()
    1.82 -	{
    1.83 +	public int getFlags() {
    1.84  		return this.flags;
    1.85  	}
    1.86  
    1.87  	public long getIndexOf(Article art)
    1.88 -		throws StorageBackendException
    1.89 -	{
    1.90 +			throws StorageBackendException {
    1.91  		return StorageManager.current().getArticleIndex(art, this);
    1.92  	}
    1.93  
    1.94  	/**
    1.95  	 * Returns the group id.
    1.96  	 */
    1.97 -	public long getInternalID()
    1.98 -	{
    1.99 +	public long getInternalID() {
   1.100  		assert id > 0;
   1.101  
   1.102  		return id;
   1.103  	}
   1.104  
   1.105 -	public boolean isDeleted()
   1.106 -	{
   1.107 +	public boolean isDeleted() {
   1.108  		return (this.flags & DELETED) != 0;
   1.109  	}
   1.110  
   1.111 -	public boolean isMailingList()
   1.112 -	{
   1.113 +	public boolean isMailingList() {
   1.114  		return (this.flags & MAILINGLIST) != 0;
   1.115  	}
   1.116  
   1.117 -	public boolean isWriteable()
   1.118 -	{
   1.119 +	public boolean isWriteable() {
   1.120  		return true;
   1.121  	}
   1.122  
   1.123  	public long getLastArticleNumber()
   1.124 -		throws StorageBackendException
   1.125 -	{
   1.126 +			throws StorageBackendException {
   1.127  		return StorageManager.current().getLastArticleNumber(this);
   1.128  	}
   1.129  
   1.130 -	public String getName()
   1.131 -	{
   1.132 +	public String getName() {
   1.133  		return name;
   1.134  	}
   1.135  
   1.136 @@ -146,13 +129,11 @@
   1.137  	 * in the JDBCDatabase.
   1.138  	 * @param flag
   1.139  	 */
   1.140 -	public void setFlag(final int flag)
   1.141 -	{
   1.142 +	public void setFlag(final int flag) {
   1.143  		this.flags |= flag;
   1.144  	}
   1.145  
   1.146 -	public void setName(final String name)
   1.147 -	{
   1.148 +	public void setName(final String name) {
   1.149  		this.name = name;
   1.150  	}
   1.151  
   1.152 @@ -161,8 +142,7 @@
   1.153  	 * @throws java.sql.SQLException
   1.154  	 */
   1.155  	public long getPostingsCount()
   1.156 -		throws StorageBackendException
   1.157 -	{
   1.158 +			throws StorageBackendException {
   1.159  		return StorageManager.current().getPostingsCount(this.name);
   1.160  	}
   1.161  
   1.162 @@ -170,8 +150,7 @@
   1.163  	 * Updates flags and name in the backend.
   1.164  	 */
   1.165  	public void update()
   1.166 -		throws StorageBackendException
   1.167 -	{
   1.168 +			throws StorageBackendException {
   1.169  		StorageManager.current().update(this);
   1.170  	}
   1.171  }