Methods Summary |
---|
public NNTPArticle | addArticle(java.io.InputStream newsStream)
File articleFile = null;
synchronized (this) {
int artNum;
if (numOfArticles < 0)
throw new IllegalStateException("NNTP Group is corrupt (articles < 0).");
else if (numOfArticles == 0) {
firstArticle = 1;
artNum = 1;
} else {
artNum = getLastArticleNumber() + 1;
}
articleFile = new File(root, artNum + "");
articleFile.createNewFile();
lastArticle = artNum;
numOfArticles++;
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Copying message to: "+articleFile.getAbsolutePath());
}
FileOutputStream fout = null;
try {
fout = new FileOutputStream(articleFile);
IOUtil.copy(newsStream,fout);
fout.flush();
} finally {
try {
if (fout != null) {
fout.close();
}
} catch (IOException ioe) {
// Ignore this exception so we don't
// trash any "real" exceptions
}
}
return new NNTPArticleImpl(this, articleFile);
|
private void | collectArticleRangeInfo()Generates the first, last, and number of articles from the
information in the group directory.
if ( articleRangeInfoCollected ) {
return;
}
String[] list = root.list();
int first = -1;
int last = -1;
for ( int i = 0 ; i < list.length ; i++ ) {
int num = Integer.parseInt(list[i]);
if ( first == -1 || num < first ) {
first = num;
}
if ( num > last ) {
last = num;
}
}
numOfArticles = list.length;
firstArticle = Math.max(first,0);
lastArticle = Math.max(last,0);
articleRangeInfoCollected = true;
|
public NNTPArticle | getArticle(int number)
File f = new File(root,number + "");
return f.exists() ? new NNTPArticleImpl(this, f) : null;
|
public java.util.Iterator | getArticles()
File[] f = root.listFiles();
List list = new ArrayList();
for ( int i = 0 ; i < f.length ; i++ )
list.add(new NNTPArticleImpl(this, f[i]));
return list.iterator();
|
public java.util.Iterator | getArticlesSince(java.util.Date dt)
File[] f = root.listFiles(new AndFileFilter
(new DateSinceFileFilter(dt.getTime()),
new InvertedFileFilter(new ExtensionFileFilter(".id"))));
List list = new ArrayList();
for ( int i = 0 ; i < f.length ; i++ ) {
list.add(new NNTPArticleImpl(this, f[i]));
}
return list.iterator();
|
public java.lang.String | getDescription()
return getName();
|
public int | getFirstArticleNumber()
collectArticleRangeInfo();
return firstArticle;
|
public int | getLastArticleNumber()
collectArticleRangeInfo();
return lastArticle;
|
public java.lang.String | getListFormat()
StringBuffer showBuffer =
new StringBuffer(128)
.append(getName())
.append(" ")
.append(getLastArticleNumber())
.append(" ")
.append(getFirstArticleNumber())
.append(" ")
.append((isPostAllowed() ? "y":"n"));
return showBuffer.toString();
|
public java.lang.String | getListNewsgroupsFormat()
StringBuffer showBuffer =
new StringBuffer(128)
.append(getName())
.append(" ")
.append(getDescription());
return showBuffer.toString();
|
public java.lang.String | getName()
return root.getName();
|
public int | getNumberOfArticles()
collectArticleRangeInfo();
return numOfArticles;
|
public boolean | isPostAllowed()
return true;
|