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: * A constant indicating that the posting permission of a newsgroup is
036: * unknown. For example, the NNTP GROUP command does not return posting
037: * information, so NewsgroupInfo instances obtained from that command
038: * willhave an UNKNOWN_POSTING_PERMISSION.
039: ***/
040: public static final int UNKNOWN_POSTING_PERMISSION = 0;
041:
042: /*** A constant indicating that a newsgroup is moderated. ***/
043: public static final int MODERATED_POSTING_PERMISSION = 1;
044:
045: /*** A constant indicating that a newsgroup is public and unmoderated. ***/
046: public static final int PERMITTED_POSTING_PERMISSION = 2;
047:
048: /***
049: * A constant indicating that a newsgroup is closed for general posting.
050: ***/
051: public static final int PROHIBITED_POSTING_PERMISSION = 3;
052:
053: private String __newsgroup;
054: private int __estimatedArticleCount;
055: private int __firstArticle, __lastArticle;
056: private int __postingPermission;
057:
058: void _setNewsgroup(String newsgroup) {
059: __newsgroup = newsgroup;
060: }
061:
062: void _setArticleCount(int count) {
063: __estimatedArticleCount = count;
064: }
065:
066: void _setFirstArticle(int first) {
067: __firstArticle = first;
068: }
069:
070: void _setLastArticle(int last) {
071: __lastArticle = last;
072: }
073:
074: void _setPostingPermission(int permission) {
075: __postingPermission = permission;
076: }
077:
078: /***
079: * Get the newsgroup name.
080: * <p>
081: * @return The name of the newsgroup.
082: ***/
083: public String getNewsgroup() {
084: return __newsgroup;
085: }
086:
087: /***
088: * Get the estimated number of articles in the newsgroup. The
089: * accuracy of this value will depend on the server implementation.
090: * <p>
091: * @return The estimated number of articles in the newsgroup.
092: ***/
093: public int getArticleCount() {
094: return __estimatedArticleCount;
095: }
096:
097: /***
098: * Get the number of the first article in the newsgroup.
099: * <p>
100: * @return The number of the first article in the newsgroup.
101: ***/
102: public int getFirstArticle() {
103: return __firstArticle;
104: }
105:
106: /***
107: * Get the number of the last article in the newsgroup.
108: * <p>
109: * @return The number of the last article in the newsgroup.
110: ***/
111: public int getLastArticle() {
112: return __lastArticle;
113: }
114:
115: /***
116: * Get the posting permission of the newsgroup. This will be one of
117: * the <code> POSTING_PERMISSION </code> constants.
118: * <p>
119: * @return The posting permission status of the newsgroup.
120: ***/
121: public int getPostingPermission() {
122: return __postingPermission;
123: }
124:
125: /*
126: public String toString() {
127: StringBuffer buffer = new StringBuffer();
128: buffer.append(__newsgroup);
129: buffer.append(' ');
130: buffer.append(__lastArticle);
131: buffer.append(' ');
132: buffer.append(__firstArticle);
133: buffer.append(' ');
134: switch(__postingPermission) {
135: case 1: buffer.append('m'); break;
136: case 2: buffer.append('y'); break;
137: case 3: buffer.append('n'); break;
138: }
139: return buffer.toString();
140: }
141: */
142: }
|