View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  
21  
22  package org.apache.james.nntpserver.repository;
23  
24  import java.io.InputStream;
25  import java.io.IOException;
26  import java.util.Date;
27  import java.util.Iterator;
28  
29  /** 
30   * Contract exposed by a NewsGroup
31   *
32   */
33  public interface NNTPGroup {
34  
35      /**
36       * Gets the name of the newsgroup
37       *
38       * @return the newsgroup name
39       */
40      String getName();
41  
42      /**
43       * Gets the description of the newsgroup
44       *
45       * @return the newsgroup description
46       */
47      String getDescription();
48  
49      /**
50       * Returns whether posting is allowed to this newsgroup
51       *
52       * @return whether posting is allowed to this newsgroup
53       */
54      boolean isPostAllowed();
55  
56      /**
57       * Gets the number of articles in the group.
58       *
59       * @return the number of articles in the group.
60       */
61      int getNumberOfArticles();
62  
63      /**
64       * Gets the first article number in the group.
65       *
66       * @return the first article number in the group.
67       */
68      int getFirstArticleNumber();
69  
70      /**
71       * Gets the last article number in the group.
72       *
73       * @return the last article number in the group.
74       */
75      int getLastArticleNumber();
76  
77      /**
78       * Gets the article with the specified article number.
79       *
80       * @param number the article number
81       *
82       * @return the article
83       */
84      NNTPArticle getArticle(int number);
85  
86      /**
87       * Retrieves an iterator of articles in this newsgroup that were
88       * posted on or after the specified date.
89       *
90       * @param dt the Date that acts as a lower bound for the list of
91       *           articles
92       *
93       * @return the article iterator
94       */
95      Iterator getArticlesSince(Date dt);
96  
97      /**
98       * Retrieves an iterator of all articles in this newsgroup
99       *
100      * @return the article iterator
101      */
102     Iterator getArticles();
103 
104     /**
105      * Retrieves the group information in a format consistent with
106      * a LIST or LIST ACTIVE return line
107      *
108      * @return the properly formatted string
109      */
110     String getListFormat();
111 
112     /**
113      * Retrieves the group information in a format consistent with
114      * a LIST NEWSGROUPS return line
115      *
116      * @return the properly formatted string
117      */
118     String getListNewsgroupsFormat();
119 
120     /**
121      * Adds an article to the group based on the data in the
122      * stream.
123      *
124      * @param newsStream the InputStream containing the article data
125      *
126      * @return the newly created article
127      */
128     NNTPArticle addArticle(InputStream newsStream) throws IOException;
129 }