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