1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net.nntp;
  17. /***
  18. * NewsgroupInfo stores information pertaining to a newsgroup returned by
  19. * the NNTP GROUP, LIST, and NEWGROUPS commands, implemented by
  20. * <a href="org.apache.commons.net.nntp.NNTPClient.html#selectNewsgroup">
  21. * selectNewsgroup </a>,
  22. * <a href="org.apache.commons.net.nntp.NNTPClient.html#listNewsgroups">
  23. * listNewsgroups </a>, and
  24. * <a href="org.apache.commons.net.nntp.NNTPClient.html#listNewNewsgroups">
  25. * listNewNewsgroups </a> respectively.
  26. * <p>
  27. * <p>
  28. * @author Daniel F. Savarese
  29. * @see NNTPClient
  30. ***/
  31. public final class NewsgroupInfo
  32. {
  33. /***
  34. * A constant indicating that the posting permission of a newsgroup is
  35. * unknown. For example, the NNTP GROUP command does not return posting
  36. * information, so NewsgroupInfo instances obtained from that command
  37. * willhave an UNKNOWN_POSTING_PERMISSION.
  38. ***/
  39. public static final int UNKNOWN_POSTING_PERMISSION = 0;
  40. /*** A constant indicating that a newsgroup is moderated. ***/
  41. public static final int MODERATED_POSTING_PERMISSION = 1;
  42. /*** A constant indicating that a newsgroup is public and unmoderated. ***/
  43. public static final int PERMITTED_POSTING_PERMISSION = 2;
  44. /***
  45. * A constant indicating that a newsgroup is closed for general posting.
  46. ***/
  47. public static final int PROHIBITED_POSTING_PERMISSION = 3;
  48. private String __newsgroup;
  49. private int __estimatedArticleCount;
  50. private int __firstArticle, __lastArticle;
  51. private int __postingPermission;
  52. void _setNewsgroup(String newsgroup)
  53. {
  54. __newsgroup = newsgroup;
  55. }
  56. void _setArticleCount(int count)
  57. {
  58. __estimatedArticleCount = count;
  59. }
  60. void _setFirstArticle(int first)
  61. {
  62. __firstArticle = first;
  63. }
  64. void _setLastArticle(int last)
  65. {
  66. __lastArticle = last;
  67. }
  68. void _setPostingPermission(int permission)
  69. {
  70. __postingPermission = permission;
  71. }
  72. /***
  73. * Get the newsgroup name.
  74. * <p>
  75. * @return The name of the newsgroup.
  76. ***/
  77. public String getNewsgroup()
  78. {
  79. return __newsgroup;
  80. }
  81. /***
  82. * Get the estimated number of articles in the newsgroup. The
  83. * accuracy of this value will depend on the server implementation.
  84. * <p>
  85. * @return The estimated number of articles in the newsgroup.
  86. ***/
  87. public int getArticleCount()
  88. {
  89. return __estimatedArticleCount;
  90. }
  91. /***
  92. * Get the number of the first article in the newsgroup.
  93. * <p>
  94. * @return The number of the first article in the newsgroup.
  95. ***/
  96. public int getFirstArticle()
  97. {
  98. return __firstArticle;
  99. }
  100. /***
  101. * Get the number of the last article in the newsgroup.
  102. * <p>
  103. * @return The number of the last article in the newsgroup.
  104. ***/
  105. public int getLastArticle()
  106. {
  107. return __lastArticle;
  108. }
  109. /***
  110. * Get the posting permission of the newsgroup. This will be one of
  111. * the <code> POSTING_PERMISSION </code> constants.
  112. * <p>
  113. * @return The posting permission status of the newsgroup.
  114. ***/
  115. public int getPostingPermission()
  116. {
  117. return __postingPermission;
  118. }
  119. /*
  120. public String toString() {
  121. StringBuffer buffer = new StringBuffer();
  122. buffer.append(__newsgroup);
  123. buffer.append(' ');
  124. buffer.append(__lastArticle);
  125. buffer.append(' ');
  126. buffer.append(__firstArticle);
  127. buffer.append(' ');
  128. switch(__postingPermission) {
  129. case 1: buffer.append('m'); break;
  130. case 2: buffer.append('y'); break;
  131. case 3: buffer.append('n'); break;
  132. }
  133. return buffer.toString();
  134. }
  135. */
  136. }