org.brains2b.coffee
Class NewsServer

java.lang.Object
  extended by org.brains2b.coffee.NewsServer
All Implemented Interfaces:
TicketHandler

public class NewsServer
extends java.lang.Object
implements TicketHandler

Class for handling newsserver actions and maintaining connections

Version:
0.89.1 [25-02-2008]
Author:
dennis@brains2b.nl

Constructor Summary
NewsServer(ServerDescriptor server)
          Constructor
 
Method Summary
 void addProgressMonitor(ProgressMonitor monitor)
           
 void close()
           
 java.lang.String getAddress()
          get the address of the Server
 NNTPMessage getArticle(java.lang.String groupName, int number)
          get Article from group by either unique id or number
 NNTPMessage getArticle(java.lang.String groupName, int type, java.lang.String value)
          get Article from group by either unique id or number
 NNTPMessage getArticle(java.lang.String groupName, java.lang.String messageId)
          get Article from group by unique id
 NNTPMessage getArticles(NewsGroup group)
          get selected articles from the NewsGroup Selection is made as articles between NewsGroup.getFirst() and NewsGroup.getLast().
 GroupList getGroupList()
          get the list of groups this newsserver supports
 int[] getHandledEvents()
           
 int getMaxConnection()
          get the maximum connections this server can support This may differ from the connections supplied by ServerDescription if server rejects more connections
 NNTPMessage getNewArticles(NewsGroup group)
          get new articles from the NewsGroup get the all the new articles from the list, with a maximum of 50000.
 ServerDescriptor getServer()
           
 NNTPMessage handleEvent(CoffeeEvent event)
           
 boolean isAvailable()
           
 void open()
           
 NNTPMessage post(Article a)
          post an article to the NewsServer
 void removeProgressMonitor(ProgressMonitor monitor)
           
 void setMaxConnection(int maxConnection)
          set the maximum connections you want the server to support
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NewsServer

public NewsServer(ServerDescriptor server)
Constructor

Parameters:
server - ServerDescriptor, information to make NNTP connections
Method Detail

handleEvent

public NNTPMessage handleEvent(CoffeeEvent event)
                        throws CoffeeSpill
Specified by:
handleEvent in interface TicketHandler
Throws:
CoffeeSpill

getGroupList

public GroupList getGroupList()
get the list of groups this newsserver supports

Returns:
GroupList

getArticles

public NNTPMessage getArticles(NewsGroup group)
get selected articles from the NewsGroup

Selection is made as articles between NewsGroup.getFirst() and NewsGroup.getLast().

Parameters:
group - NewsGroup, the group to get articles from
Returns:
NNTPMessage, either NewsGroup or InfoMessage

getNewArticles

public NNTPMessage getNewArticles(NewsGroup group)
get new articles from the NewsGroup

get the all the new articles from the list, with a maximum of 50000. It uses NewsGroup.getLast() from the supplied group to determine what is new

Parameters:
group - NewsGroup, the group to get articles from
Returns:
NNTPMessage, either NewsGroup or InfoMessage

getArticle

public NNTPMessage getArticle(java.lang.String groupName,
                              java.lang.String messageId)
get Article from group by unique id

Parameters:
groupName - String, the name of the group
messageId - String, the unique id of the message
Returns:
NNTPMessage, either Article or InfoMessage

getArticle

public NNTPMessage getArticle(java.lang.String groupName,
                              int type,
                              java.lang.String value)
get Article from group by either unique id or number

Parameters:
groupName - String, the name of the group
type - int, 0 for messageId or 1 for number
value - String, the unique id of the message, or its number
Returns:
NNTPMessage, either Article or InfoMessage

getArticle

public NNTPMessage getArticle(java.lang.String groupName,
                              int number)
get Article from group by either unique id or number

Parameters:
groupName - String, the name of the group
number - int, the number of the message in this group
Returns:
NNTPMessage, either Article or InfoMessage

post

public NNTPMessage post(Article a)
post an article to the NewsServer

Parameters:
a - Article, the article to post
Returns:
NNTPMessage, either Article with unique id set or an InfoMessage

getAddress

public java.lang.String getAddress()
get the address of the Server

Returns:
String, the address of the Server

getMaxConnection

public int getMaxConnection()
get the maximum connections this server can support

This may differ from the connections supplied by ServerDescription if server rejects more connections

Returns:
int, the maximum connections

setMaxConnection

public void setMaxConnection(int maxConnection)
set the maximum connections you want the server to support

Parameters:
maxConnection -
See Also:
getMaxConnection()

close

public void close()
           throws java.lang.Exception
Specified by:
close in interface TicketHandler
Throws:
java.lang.Exception

isAvailable

public boolean isAvailable()
Specified by:
isAvailable in interface TicketHandler

addProgressMonitor

public void addProgressMonitor(ProgressMonitor monitor)
Specified by:
addProgressMonitor in interface TicketHandler

open

public void open()
Specified by:
open in interface TicketHandler

removeProgressMonitor

public void removeProgressMonitor(ProgressMonitor monitor)
Specified by:
removeProgressMonitor in interface TicketHandler

getHandledEvents

public int[] getHandledEvents()
Specified by:
getHandledEvents in interface TicketHandler

getServer

public ServerDescriptor getServer()