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 * @see NNTPClient 032 ***/ 033 034 public final class NewsgroupInfo 035 { 036 /*** 037 * A constant indicating that the posting permission of a newsgroup is 038 * unknown. For example, the NNTP GROUP command does not return posting 039 * information, so NewsgroupInfo instances obtained from that command 040 * willhave an UNKNOWN_POSTING_PERMISSION. 041 ***/ 042 public static final int UNKNOWN_POSTING_PERMISSION = 0; 043 044 /*** A constant indicating that a newsgroup is moderated. ***/ 045 public static final int MODERATED_POSTING_PERMISSION = 1; 046 047 /*** A constant indicating that a newsgroup is public and unmoderated. ***/ 048 public static final int PERMITTED_POSTING_PERMISSION = 2; 049 050 /*** 051 * A constant indicating that a newsgroup is closed for general posting. 052 ***/ 053 public static final int PROHIBITED_POSTING_PERMISSION = 3; 054 055 private String __newsgroup; 056 private long __estimatedArticleCount; 057 private long __firstArticle; 058 private long __lastArticle; 059 private int __postingPermission; 060 061 void _setNewsgroup(String newsgroup) 062 { 063 __newsgroup = newsgroup; 064 } 065 066 void _setArticleCount(long count) 067 { 068 __estimatedArticleCount = count; 069 } 070 071 void _setFirstArticle(long first) 072 { 073 __firstArticle = first; 074 } 075 076 void _setLastArticle(long 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 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 }