001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.nntpserver.repository;
019:
020: import java.io.InputStream;
021: import java.io.IOException;
022: import java.util.Date;
023: import java.util.Iterator;
024:
025: /**
026: * Contract exposed by a NewsGroup
027: *
028: */
029: public interface NNTPGroup {
030:
031: /**
032: * Gets the name of the newsgroup
033: *
034: * @return the newsgroup name
035: */
036: String getName();
037:
038: /**
039: * Gets the description of the newsgroup
040: *
041: * @return the newsgroup description
042: */
043: String getDescription();
044:
045: /**
046: * Returns whether posting is allowed to this newsgroup
047: *
048: * @return whether posting is allowed to this newsgroup
049: */
050: boolean isPostAllowed();
051:
052: /**
053: * Gets the number of articles in the group.
054: *
055: * @return the number of articles in the group.
056: */
057: int getNumberOfArticles();
058:
059: /**
060: * Gets the first article number in the group.
061: *
062: * @return the first article number in the group.
063: */
064: int getFirstArticleNumber();
065:
066: /**
067: * Gets the last article number in the group.
068: *
069: * @return the last article number in the group.
070: */
071: int getLastArticleNumber();
072:
073: /**
074: * Gets the article with the specified article number.
075: *
076: * @param number the article number
077: *
078: * @return the article
079: */
080: NNTPArticle getArticle(int number);
081:
082: /**
083: * Retrieves an iterator of articles in this newsgroup that were
084: * posted on or after the specified date.
085: *
086: * @param dt the Date that acts as a lower bound for the list of
087: * articles
088: *
089: * @return the article iterator
090: */
091: Iterator getArticlesSince(Date dt);
092:
093: /**
094: * Retrieves an iterator of all articles in this newsgroup
095: *
096: * @return the article iterator
097: */
098: Iterator getArticles();
099:
100: /**
101: * Retrieves the group information in a format consistent with
102: * a LIST or LIST ACTIVE return line
103: *
104: * @return the properly formatted string
105: */
106: String getListFormat();
107:
108: /**
109: * Retrieves the group information in a format consistent with
110: * a LIST NEWSGROUPS return line
111: *
112: * @return the properly formatted string
113: */
114: String getListNewsgroupsFormat();
115:
116: /**
117: * Adds an article to the group based on the data in the
118: * stream.
119: *
120: * @param newsStream the InputStream containing the article data
121: *
122: * @return the newly created article
123: */
124: NNTPArticle addArticle(InputStream newsStream) throws IOException;
125: }
|