nan.model
Class Newsgroup

java.lang.Object
  extended bynan.model.Newsgroup
All Implemented Interfaces:
java.lang.Comparable, Transposer, XMLSerializable

public class Newsgroup
extends java.lang.Object
implements XMLSerializable, java.lang.Comparable, Transposer

A representation of an NNTP newsgroup.

Version:
1.12, 1/2/04
Author:
John David Ratliff

Field Summary
static int ALL_MESSAGES
          Integer constant representing that all messages should be cached locally.
static int DEFAULT_MESSAGES
          The default number of messages to cache locally.
static java.lang.String XML_FIRST_ARTICLE
          XML tag for the first article property.
static java.lang.String XML_LAST_ARTICLE
          XML tag for the last article property.
static java.lang.String XML_MESSAGES
          XML tag for the messages property.
static java.lang.String XML_NAME
          XML tag for the name property.
static java.lang.String XML_NEXT_ARTICLE
          XML tag for the next article property.
static java.lang.String XML_POSTING_ALLOWED
          XML tag for the posting allowed property.
static java.lang.String XML_TAG
          XML tag for serialization.
static java.lang.String XML_UPDATED
          XML tag for the updated property.
 
Constructor Summary
protected Newsgroup()
          Creates a new Newsgroup object.
  Newsgroup(java.lang.String name, boolean postingAllowed, int messages)
          Creates a new Newsgroup object.
 
Method Summary
 int compareTo(java.lang.Object object)
          Compares this Newsgroup to another object for lexiographic equivalence by Newsgroup name.
 boolean equals(java.lang.Object object)
          Tests for equivalence with another object.
 MessageTree getCache()
          Gets the local cache.
 int getFirstArticle()
          Gets the first article id in this Newsgroup.
 int getLastArticle()
          Gets the last article id in this Newsgroup.
 int getMessages()
          Gets the number of messages to cache locally.
 java.lang.String getName()
          Gets the name of this Newsgroup.
 int getNextArticle()
          Gets the next article in need of retrieval.
 java.util.Date getUpdated()
          Gets the last update time.
 boolean hasCache()
          Asks if this Newsgroup has a current cache.
 boolean isPostingAllowed()
          Asks if this Newsgroup permits posting.
 void setCache(MessageTree cache)
          Sets the local cache.
 void setFirstArticle(int firstArticle)
          Sets the first article id in this Newsgroup.
 void setLastArticle(int lastArticle)
          Sets the last article id in this Newsgroup.
 void setMessages(int messages)
          Sets the number of messages to cache locally.
 void setName(java.lang.String name)
          Sets the name of this Newsgroup.
 void setNextArticle(int nextArticle)
          Sets the next article in need of retrieval.
 void setPostingAllowed(boolean postingAllowed)
          Sets whether posting is allowed on this Newsgroup or not.
 void setUpdated()
          Sets the current time as the last update time.
protected  void setUpdated(java.util.Date date)
          Sets the last update time.
 java.lang.String toString()
          Returns a String representation of this Newsgroup.
 org.dom4j.Document toXML()
          Converts an object into an XML Document.
 void transpose(java.lang.Object object)
          Transposes (copies over) the values of another object of the same type onto this one.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_TAG

public static final java.lang.String XML_TAG
XML tag for serialization.

See Also:
Constant Field Values

XML_NAME

public static final java.lang.String XML_NAME
XML tag for the name property.

See Also:
Constant Field Values

XML_FIRST_ARTICLE

public static final java.lang.String XML_FIRST_ARTICLE
XML tag for the first article property.

See Also:
Constant Field Values

XML_LAST_ARTICLE

public static final java.lang.String XML_LAST_ARTICLE
XML tag for the last article property.

See Also:
Constant Field Values

XML_NEXT_ARTICLE

public static final java.lang.String XML_NEXT_ARTICLE
XML tag for the next article property.

See Also:
Constant Field Values

XML_POSTING_ALLOWED

public static final java.lang.String XML_POSTING_ALLOWED
XML tag for the posting allowed property.

See Also:
Constant Field Values

XML_UPDATED

public static final java.lang.String XML_UPDATED
XML tag for the updated property.

See Also:
Constant Field Values

XML_MESSAGES

public static final java.lang.String XML_MESSAGES
XML tag for the messages property.

See Also:
Constant Field Values

DEFAULT_MESSAGES

public static final int DEFAULT_MESSAGES
The default number of messages to cache locally.

See Also:
Constant Field Values

ALL_MESSAGES

public static final int ALL_MESSAGES
Integer constant representing that all messages should be cached locally.

See Also:
Constant Field Values
Constructor Detail

Newsgroup

public Newsgroup(java.lang.String name,
                 boolean postingAllowed,
                 int messages)
Creates a new Newsgroup object.

Parameters:
name - The name of this Newsgroup.
postingAllowed - Whether this Newsgroup permits posting.
messages - The number of messages to cache locally (0 = all).

Newsgroup

protected Newsgroup()
Creates a new Newsgroup object.

Method Detail

getName

public java.lang.String getName()
Gets the name of this Newsgroup.

Returns:
The name.

setName

public void setName(java.lang.String name)
Sets the name of this Newsgroup.

Parameters:
name - The name.

getFirstArticle

public int getFirstArticle()
Gets the first article id in this Newsgroup.

Returns:
The first article id.

setFirstArticle

public void setFirstArticle(int firstArticle)
Sets the first article id in this Newsgroup.

Parameters:
firstArticle - The first article id.

getLastArticle

public int getLastArticle()
Gets the last article id in this Newsgroup.

Returns:
The last article id.

setLastArticle

public void setLastArticle(int lastArticle)
Sets the last article id in this Newsgroup.

Parameters:
lastArticle - The last article id.

getNextArticle

public int getNextArticle()
Gets the next article in need of retrieval.

Returns:
The next article number.

setNextArticle

public void setNextArticle(int nextArticle)
Sets the next article in need of retrieval.

Parameters:
nextArticle - The next article number.

isPostingAllowed

public boolean isPostingAllowed()
Asks if this Newsgroup permits posting.

Returns:
true if posting is allowed; false otherwise.

setPostingAllowed

public void setPostingAllowed(boolean postingAllowed)
Sets whether posting is allowed on this Newsgroup or not.

Parameters:
postingAllowed - true if posting is allowed; false otherwise.

hasCache

public boolean hasCache()
Asks if this Newsgroup has a current cache.

Returns:
true if this Newsgroup has a local cache; false otherwise.

getCache

public MessageTree getCache()
Gets the local cache.

Returns:
The MessageTree cache.

setCache

public void setCache(MessageTree cache)
Sets the local cache.

Parameters:
cache - The MessageTree cache.

setUpdated

protected void setUpdated(java.util.Date date)
Sets the last update time.

Parameters:
date - The new Date.

setUpdated

public void setUpdated()
Sets the current time as the last update time.


getUpdated

public java.util.Date getUpdated()
Gets the last update time.

Returns:
The Date of the last update.

getMessages

public int getMessages()
Gets the number of messages to cache locally.

Returns:
The number of messages.

setMessages

public void setMessages(int messages)
Sets the number of messages to cache locally.

Parameters:
messages - The number of messages.

toXML

public org.dom4j.Document toXML()
Converts an object into an XML Document.

Specified by:
toXML in interface XMLSerializable
Returns:
The XML Document.

compareTo

public int compareTo(java.lang.Object object)
Compares this Newsgroup to another object for lexiographic equivalence by Newsgroup name.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
object - The object to compare with.
Returns:
0 if the objects are equal or not of the same type. Less than 0 if this group comes alphabetically before the object, and greater than 1 if this group comes alphabetically after the object.

equals

public boolean equals(java.lang.Object object)
Tests for equivalence with another object. Two Newsgroup objects are said to be equivalent if their names are the same (String equality, case sensitive).

Parameters:
object - The other object to test equivalence with.
Returns:
true if the two objects are equivalent; false otherwise.

transpose

public void transpose(java.lang.Object object)
Transposes (copies over) the values of another object of the same type onto this one. If the object is not the same type as the invoked object, it will be ignored.

Specified by:
transpose in interface Transposer
Parameters:
object - The object to transpose over this one.

toString

public java.lang.String toString()
Returns a String representation of this Newsgroup.

Returns:
A String representation.