nan.model
Class NewsgroupList

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

public class NewsgroupList
extends java.lang.Object
implements XMLSerializable, Transposer

A list container for Newsgroups that also support JList components.

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

Field Summary
static java.lang.String XML_TAG
          XML tag for serialization.
static java.lang.String XML_UPDATED
          XML tag for the last updated property.
 
Constructor Summary
NewsgroupList()
          Creates a new NewsgroupList object.
 
Method Summary
 void add(Newsgroup newsgroup)
          Adds a Newsgroup to this list.
 void append(NewsgroupList list)
          Appends the Newsgroups from a NewsgroupList onto this NewsgroupList.
 boolean contains(Newsgroup newsgroup)
          Asks if a Newsgroup is contained in this list.
 Newsgroup get(int index)
          Gets a Newsgroup from this list.
 javax.swing.ListModel getListModel()
          Gets the ListModel.
 int getSize()
          Gets the number of Newsgroups in this NewsgroupList.
 java.util.Date getUpdated()
          Gets the last update time.
 Newsgroup remove(int index)
          Removes a Newsgroup from this list.
 void setUpdated()
          Sets the current time as the last update time.
protected  void setUpdated(java.util.Date date)
          Sets the last update time.
 void sort()
          Sorts this list by Newsgroup.compareTo, which by default is an alpbetical sort.
 java.lang.String toString()
          Returns a String representation of this NewsgroupList.
 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, equals, 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_UPDATED

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

See Also:
Constant Field Values
Constructor Detail

NewsgroupList

public NewsgroupList()
Creates a new NewsgroupList object.

Method Detail

append

public void append(NewsgroupList list)
Appends the Newsgroups from a NewsgroupList onto this NewsgroupList.

Parameters:
list - The NewsgroupList to append from.

getSize

public int getSize()
Gets the number of Newsgroups in this NewsgroupList.

Returns:
The Newsgroup count.

contains

public boolean contains(Newsgroup newsgroup)
Asks if a Newsgroup is contained in this list.

Parameters:
newsgroup - The Newsgroup to check.
Returns:
true if the Newsgroup is in this list; false otherwise.

add

public void add(Newsgroup newsgroup)
Adds a Newsgroup to this list.

Parameters:
newsgroup - The Newsgroup.

remove

public Newsgroup remove(int index)
                 throws java.lang.IndexOutOfBoundsException
Removes a Newsgroup from this list.

Parameters:
index - The index to remove at.
Returns:
The removed Newsgroup.
Throws:
java.lang.IndexOutOfBoundsException - if the index is invalid.

get

public Newsgroup get(int index)
              throws java.lang.IndexOutOfBoundsException
Gets a Newsgroup from this list.

Parameters:
index - The index of the Newsgroup to retrieve.
Returns:
The retrieved Newsgroup.
Throws:
java.lang.IndexOutOfBoundsException - if the index is invalid.

sort

public void sort()
Sorts this list by Newsgroup.compareTo, which by default is an alpbetical sort.


getListModel

public javax.swing.ListModel getListModel()
Gets the ListModel. Useful for components like JList.

Returns:
The ListModel.

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.

toXML

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

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

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 NewsgroupList.

Returns:
A String representation.