View Javadoc

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   * @author Daniel F. Savarese
32   * @see NNTPClient
33   ***/
34  
35  public final class NewsgroupInfo
36  {
37      /***
38       * A constant indicating that the posting permission of a newsgroup is
39       * unknown.  For example, the NNTP GROUP command does not return posting
40       * information, so NewsgroupInfo instances obtained from that command
41       * willhave an UNKNOWN_POSTING_PERMISSION.
42       ***/
43      public static final int UNKNOWN_POSTING_PERMISSION = 0;
44  
45      /*** A constant indicating that a newsgroup is moderated. ***/
46      public static final int MODERATED_POSTING_PERMISSION = 1;
47  
48      /*** A constant indicating that a newsgroup is public and unmoderated. ***/
49      public static final int PERMITTED_POSTING_PERMISSION = 2;
50  
51      /***
52       * A constant indicating that a newsgroup is closed for general posting.
53       ***/
54      public static final int PROHIBITED_POSTING_PERMISSION = 3;
55  
56      private String __newsgroup;
57      private int __estimatedArticleCount;
58      private int __firstArticle, __lastArticle;
59      private int __postingPermission;
60  
61      void _setNewsgroup(String newsgroup)
62      {
63          __newsgroup = newsgroup;
64      }
65  
66      void _setArticleCount(int count)
67      {
68          __estimatedArticleCount = count;
69      }
70  
71      void _setFirstArticle(int first)
72      {
73          __firstArticle = first;
74      }
75  
76      void _setLastArticle(int 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 int getArticleCount()
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 int getFirstArticle()
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 int getLastArticle()
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       StringBuffer buffer = new StringBuffer();
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 }