1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.net.nntp;
19
20 /***
21 * NewsgroupInfo stores information pertaining to a newsgroup returned by
22 * the NNTP GROUP, LIST, and NEWGROUPS commands, implemented by
23 * {@link org.apache.commons.net.nntp.NNTPClient#selectNewsgroup selectNewsgroup }
24 * ,
25 * {@link org.apache.commons.net.nntp.NNTPClient#listNewsgroups listNewsgroups }
26 * , and
27 * {@link org.apache.commons.net.nntp.NNTPClient#listNewNewsgroups listNewNewsgroups }
28 * respectively.
29 * <p>
30 * <p>
31 * @see NNTPClient
32 ***/
33
34 public final class NewsgroupInfo
35 {
36 /***
37 * A constant indicating that the posting permission of a newsgroup is
38 * unknown. For example, the NNTP GROUP command does not return posting
39 * information, so NewsgroupInfo instances obtained from that command
40 * willhave an UNKNOWN_POSTING_PERMISSION.
41 ***/
42 public static final int UNKNOWN_POSTING_PERMISSION = 0;
43
44 /*** A constant indicating that a newsgroup is moderated. ***/
45 public static final int MODERATED_POSTING_PERMISSION = 1;
46
47 /*** A constant indicating that a newsgroup is public and unmoderated. ***/
48 public static final int PERMITTED_POSTING_PERMISSION = 2;
49
50 /***
51 * A constant indicating that a newsgroup is closed for general posting.
52 ***/
53 public static final int PROHIBITED_POSTING_PERMISSION = 3;
54
55 private String __newsgroup;
56 private long __estimatedArticleCount;
57 private long __firstArticle;
58 private long __lastArticle;
59 private int __postingPermission;
60
61 void _setNewsgroup(String newsgroup)
62 {
63 __newsgroup = newsgroup;
64 }
65
66 void _setArticleCount(long count)
67 {
68 __estimatedArticleCount = count;
69 }
70
71 void _setFirstArticle(long first)
72 {
73 __firstArticle = first;
74 }
75
76 void _setLastArticle(long last)
77 {
78 __lastArticle = last;
79 }
80
81 void _setPostingPermission(int permission)
82 {
83 __postingPermission = permission;
84 }
85
86 /***
87 * Get the newsgroup name.
88 * <p>
89 * @return The name of the newsgroup.
90 ***/
91 public String getNewsgroup()
92 {
93 return __newsgroup;
94 }
95
96 /***
97 * Get the estimated number of articles in the newsgroup. The
98 * accuracy of this value will depend on the server implementation.
99 * <p>
100 * @return The estimated number of articles in the newsgroup.
101 ***/
102 public long getArticleCountLong()
103 {
104 return __estimatedArticleCount;
105 }
106
107 /***
108 * Get the number of the first article in the newsgroup.
109 * <p>
110 * @return The number of the first article in the newsgroup.
111 ***/
112 public long getFirstArticleLong()
113 {
114 return __firstArticle;
115 }
116
117 /***
118 * Get the number of the last article in the newsgroup.
119 * <p>
120 * @return The number of the last article in the newsgroup.
121 ***/
122 public long getLastArticleLong()
123 {
124 return __lastArticle;
125 }
126
127 /***
128 * Get the posting permission of the newsgroup. This will be one of
129 * the <code> POSTING_PERMISSION </code> constants.
130 * <p>
131 * @return The posting permission status of the newsgroup.
132 ***/
133 public int getPostingPermission()
134 {
135 return __postingPermission;
136 }
137
138 /*
139 public String toString() {
140 StringBuilder buffer = new StringBuilder();
141 buffer.append(__newsgroup);
142 buffer.append(' ');
143 buffer.append(__lastArticle);
144 buffer.append(' ');
145 buffer.append(__firstArticle);
146 buffer.append(' ');
147 switch(__postingPermission) {
148 case 1: buffer.append('m'); break;
149 case 2: buffer.append('y'); break;
150 case 3: buffer.append('n'); break;
151 }
152 return buffer.toString();
153 }
154 */
155
156 // DEPRECATED METHODS - for API compatibility only - DO NOT USE
157
158 @Deprecated
159 public int getArticleCount() {
160 return (int) __estimatedArticleCount;
161 }
162
163 @Deprecated
164 public int getFirstArticle() {
165 return (int) __firstArticle;
166 }
167
168 @Deprecated
169 public int getLastArticle() {
170 return (int) __lastArticle;
171 }
172 }