001 /*
002 * Copyright 2001-2005 The Apache Software Foundation
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.apache.commons.net.nntp;
017
018 /***
019 * NewsgroupInfo stores information pertaining to a newsgroup returned by
020 * the NNTP GROUP, LIST, and NEWGROUPS commands, implemented by
021 * {@link org.apache.commons.net.nntp.NNTPClient#selectNewsgroup selectNewsgroup }
022 * ,
023 * {@link org.apache.commons.net.nntp.NNTPClient#listNewsgroups listNewsgroups }
024 * , and
025 * {@link org.apache.commons.net.nntp.NNTPClient#listNewNewsgroups listNewNewsgroups }
026 * respectively.
027 * <p>
028 * <p>
029 * @author Daniel F. Savarese
030 * @see NNTPClient
031 ***/
032
033 public final class NewsgroupInfo
034 {
035 /***
036 * A constant indicating that the posting permission of a newsgroup is
037 * unknown. For example, the NNTP GROUP command does not return posting
038 * information, so NewsgroupInfo instances obtained from that command
039 * willhave an UNKNOWN_POSTING_PERMISSION.
040 ***/
041 public static final int UNKNOWN_POSTING_PERMISSION = 0;
042
043 /*** A constant indicating that a newsgroup is moderated. ***/
044 public static final int MODERATED_POSTING_PERMISSION = 1;
045
046 /*** A constant indicating that a newsgroup is public and unmoderated. ***/
047 public static final int PERMITTED_POSTING_PERMISSION = 2;
048
049 /***
050 * A constant indicating that a newsgroup is closed for general posting.
051 ***/
052 public static final int PROHIBITED_POSTING_PERMISSION = 3;
053
054 private String __newsgroup;
055 private int __estimatedArticleCount;
056 private int __firstArticle, __lastArticle;
057 private int __postingPermission;
058
059 void _setNewsgroup(String newsgroup)
060 {
061 __newsgroup = newsgroup;
062 }
063
064 void _setArticleCount(int count)
065 {
066 __estimatedArticleCount = count;
067 }
068
069 void _setFirstArticle(int first)
070 {
071 __firstArticle = first;
072 }
073
074 void _setLastArticle(int last)
075 {
076 __lastArticle = last;
077 }
078
079 void _setPostingPermission(int permission)
080 {
081 __postingPermission = permission;
082 }
083
084 /***
085 * Get the newsgroup name.
086 * <p>
087 * @return The name of the newsgroup.
088 ***/
089 public String getNewsgroup()
090 {
091 return __newsgroup;
092 }
093
094 /***
095 * Get the estimated number of articles in the newsgroup. The
096 * accuracy of this value will depend on the server implementation.
097 * <p>
098 * @return The estimated number of articles in the newsgroup.
099 ***/
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 }