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 the NNTP GROUP, LIST, and NEWGROUPS commands, implemented by 22 * {@link org.apache.commons.net.nntp.NNTPClient#selectNewsgroup selectNewsgroup } , {@link org.apache.commons.net.nntp.NNTPClient#listNewsgroups listNewsgroups 23 * } , and {@link org.apache.commons.net.nntp.NNTPClient#listNewNewsgroups listNewNewsgroups } respectively. 24 * 25 * @see NNTPClient 26 */ 27 28 public final class NewsgroupInfo { 29 /** 30 * A constant indicating that the posting permission of a newsgroup is unknown. For example, the NNTP GROUP command does not return posting information, so 31 * NewsgroupInfo instances obtained from that command will have an UNKNOWN_POSTING_PERMISSION. 32 */ 33 public static final int UNKNOWN_POSTING_PERMISSION = 0; 34 35 /** A constant indicating that a newsgroup is moderated. */ 36 public static final int MODERATED_POSTING_PERMISSION = 1; 37 38 /** A constant indicating that a newsgroup is public and unmoderated. */ 39 public static final int PERMITTED_POSTING_PERMISSION = 2; 40 41 /** 42 * A constant indicating that a newsgroup is closed for general posting. 43 */ 44 public static final int PROHIBITED_POSTING_PERMISSION = 3; 45 46 private String newsgroup; 47 private long estimatedArticleCount; 48 private long firstArticle; 49 private long lastArticle; 50 private int postingPermission; 51 52 @Deprecated 53 public int getArticleCount() { 54 return (int) estimatedArticleCount; 55 } 56 57 /** 58 * Get the estimated number of articles in the newsgroup. The accuracy of this value will depend on the server implementation. 59 * 60 * @return The estimated number of articles in the newsgroup. 61 */ 62 public long getArticleCountLong() { 63 return estimatedArticleCount; 64 } 65 66 @Deprecated 67 public int getFirstArticle() { 68 return (int) firstArticle; 69 } 70 71 /** 72 * Get the number of the first article in the newsgroup. 73 * 74 * @return The number of the first article in the newsgroup. 75 */ 76 public long getFirstArticleLong() { 77 return firstArticle; 78 } 79 80 @Deprecated 81 public int getLastArticle() { 82 return (int) lastArticle; 83 } 84 85 /** 86 * Get the number of the last article in the newsgroup. 87 * 88 * @return The number of the last article in the newsgroup. 89 */ 90 public long getLastArticleLong() { 91 return lastArticle; 92 } 93 94 /** 95 * Get the newsgroup name. 96 * 97 * @return The name of the newsgroup. 98 */ 99 public String getNewsgroup() { 100 return newsgroup; 101 } 102 103 /** 104 * Get the posting permission of the newsgroup. This will be one of the <code> POSTING_PERMISSION </code> constants. 105 * 106 * @return The posting permission status of the newsgroup. 107 */ 108 public int getPostingPermission() { 109 return postingPermission; 110 } 111 112 void setArticleCount(final long count) { 113 estimatedArticleCount = count; 114 } 115 116 void setFirstArticle(final long first) { 117 firstArticle = first; 118 } 119 120 /* 121 * public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append(__newsgroup); buffer.append(' '); buffer.append(__lastArticle); 122 * buffer.append(' '); buffer.append(__firstArticle); buffer.append(' '); switch(__postingPermission) { case 1: buffer.append('m'); break; case 2: 123 * buffer.append('y'); break; case 3: buffer.append('n'); break; } return buffer.toString(); } 124 */ 125 126 // DEPRECATED METHODS - for API compatibility only - DO NOT USE 127 128 void setLastArticle(final long last) { 129 lastArticle = last; 130 } 131 132 void setNewsgroup(final String newsgroup) { 133 this.newsgroup = newsgroup; 134 } 135 136 void setPostingPermission(final int permission) { 137 postingPermission = permission; 138 } 139 }