KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > net > nntp > NewsgroupInfo


1 /*
2  * Copyright 2001-2005 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.net.nntp;
17
18 /***
19  * NewsgroupInfo stores information pertaining to a newsgroup returned by
20  * the NNTP GROUP, LIST, and NEWGROUPS commands, implemented by
21  * {@link org.apache.commons.net.nntp.NNTPClient#selectNewsgroup selectNewsgroup }
22  * ,
23  * {@link org.apache.commons.net.nntp.NNTPClient#listNewsgroups listNewsgroups }
24  * , and
25  * {@link org.apache.commons.net.nntp.NNTPClient#listNewNewsgroups listNewNewsgroups }
26  * respectively.
27  * <p>
28  * <p>
29  * @author Daniel F. Savarese
30  * @see NNTPClient
31  ***/

32
33 public final class NewsgroupInfo
34 {
35     /***
36      * A constant indicating that the posting permission of a newsgroup is
37      * unknown. For example, the NNTP GROUP command does not return posting
38      * information, so NewsgroupInfo instances obtained from that command
39      * willhave an UNKNOWN_POSTING_PERMISSION.
40      ***/

41     public static final int UNKNOWN_POSTING_PERMISSION = 0;
42
43     /*** A constant indicating that a newsgroup is moderated. ***/
44     public static final int MODERATED_POSTING_PERMISSION = 1;
45
46     /*** A constant indicating that a newsgroup is public and unmoderated. ***/
47     public static final int PERMITTED_POSTING_PERMISSION = 2;
48
49     /***
50      * A constant indicating that a newsgroup is closed for general posting.
51      ***/

52     public static final int PROHIBITED_POSTING_PERMISSION = 3;
53
54     private String JavaDoc __newsgroup;
55     private int __estimatedArticleCount;
56     private int __firstArticle, __lastArticle;
57     private int __postingPermission;
58
59     void _setNewsgroup(String JavaDoc newsgroup)
60     {
61         __newsgroup = newsgroup;
62     }
63
64     void _setArticleCount(int count)
65     {
66         __estimatedArticleCount = count;
67     }
68
69     void _setFirstArticle(int first)
70     {
71         __firstArticle = first;
72     }
73
74     void _setLastArticle(int last)
75     {
76         __lastArticle = last;
77     }
78
79     void _setPostingPermission(int permission)
80     {
81         __postingPermission = permission;
82     }
83
84     /***
85      * Get the newsgroup name.
86      * <p>
87      * @return The name of the newsgroup.
88      ***/

89     public String JavaDoc getNewsgroup()
90     {
91         return __newsgroup;
92     }
93
94     /***
95      * Get the estimated number of articles in the newsgroup. The
96      * accuracy of this value will depend on the server implementation.
97      * <p>
98      * @return The estimated number of articles in the newsgroup.
99      ***/

100     public int getArticleCount()
101     {
102         return __estimatedArticleCount;
103     }
104
105     /***
106      * Get the number of the first article in the newsgroup.
107      * <p>
108      * @return The number of the first article in the newsgroup.
109      ***/

110     public int getFirstArticle()
111     {
112         return __firstArticle;
113     }
114
115     /***
116      * Get the number of the last article in the newsgroup.
117      * <p>
118      * @return The number of the last article in the newsgroup.
119      ***/

120     public int getLastArticle()
121     {
122         return __lastArticle;
123     }
124
125     /***
126      * Get the posting permission of the newsgroup. This will be one of
127      * the <code> POSTING_PERMISSION </code> constants.
128      * <p>
129      * @return The posting permission status of the newsgroup.
130      ***/

131     public int getPostingPermission()
132     {
133         return __postingPermission;
134     }
135
136     /*
137     public String toString() {
138       StringBuffer buffer = new StringBuffer();
139       buffer.append(__newsgroup);
140       buffer.append(' ');
141       buffer.append(__lastArticle);
142       buffer.append(' ');
143       buffer.append(__firstArticle);
144       buffer.append(' ');
145       switch(__postingPermission) {
146         case 1: buffer.append('m'); break;
147         case 2: buffer.append('y'); break;
148         case 3: buffer.append('n'); break;
149       }
150       return buffer.toString();
151 }
152     */

153 }
154
Popular Tags