edu.nrao.sss.catalog
Class Catalog<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>

java.lang.Object
  extended by edu.nrao.sss.catalog.Catalog<I,G,C>
All Implemented Interfaces:
CatalogItemGroupListener<I,G,C>, Cloneable
Direct Known Subclasses:
SimpleCatalog

public abstract class Catalog<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>
extends Object
implements Cloneable, CatalogItemGroupListener<I,G,C>

A generic catalog. In addition to holding a collection of catalog items, this catalog supports the notion of groups of catalog items.

Version Info:

$Revision: 2204 $
$Date: 2009-04-16 11:58:16 -0600 (Thu, 16 Apr 2009) $
$Author: dharland $ (last person to modify)

Since:
2006-10-23
Author:
David M. Harland

Constructor Summary
Catalog()
          Helps create a new catalog with a default name.
Catalog(String nameOfCatalog)
          Helps create a new catalog with the given name.
 
Method Summary
 boolean addGroup(G newGroup)
          Adds a new group to this catalog.
 boolean addGroup(int index, G newGroup)
          Adds a new group to this catalog at the specified position.
 boolean addGroups(Collection<? extends G> newGroups)
          Adds newGroups to this catalog.
 boolean addGroups(int index, Collection<? extends G> newGroups)
          Adds newGroups to this catalog at the specified position.
 I addItem(I newItem)
          Adds a new item to this catalog.
 I addItem(int index, I newItem)
          Adds a new item to this catalog at the specified position.
 I addItemEvenIfEqualToCurrentItem(I newItem)
          Adds newItem even if this catalog already has an item to which it is equal.
 I addItemEvenIfEqualToCurrentItem(int index, I newItem)
          Adds newItem even if this catalog already has an item to which it is equal.
 Collection<I> addItems(Collection<? extends I> newItems)
          Adds newItems to this catalog.
 Collection<I> addItems(int index, Collection<? extends I> newItems)
          Adds newItems to this catalog at the specified position.
 void addListener(CatalogListener<I,G,C> newListener)
          Adds newListener to this catalog list.
 void clear()
          Removes all groups and all items from this catalog.
 void clearId()
          Resets this catalog's ID, and the IDs of all its groups, to a value that represents the unidentified state.
 C clone()
          Returns a catalog that is a copy of this one.
 boolean contains(I item)
          Returns true if this catalog holds item.
 boolean containsGroupNamed(String name)
          Returns true if this catalog contains a group with the given name.
abstract  G createGroup()
          Returns a group of the same type of items used by this catalog.
protected abstract  G createMainGroup()
          Creates and returns a new group to use as the holder of items for this catalog.
 G decrementIndexOfGroup(G group)
          Moves group to an index one lower than its current index.
 G decrementIndexOfGroupAt(int index)
          Moves the group at index to an index of index-minus-one.
 I decrementIndexOfItem(I item)
          Moves item to an index one lower than its current index.
 I decrementIndexOfItemAt(int index)
          Moves the item at index to an index of index-minus-one.
 boolean equals(Object o)
          Returns true if o is equal to this catalog.
 G getGroup(int index)
          Returns the group at the given position.
 G getGroup(String groupName)
          Returns a group with the given name, or null if this catalog has no such group.
 List<G> getGroups()
          Returns a list of this catalog's groups.
 List<G> getGroupsThatContain(I item)
          Returns a list of groups that contain item.
 Long getId()
          Returns this catalog's ID.
protected  long getIdOfUnidentified()
          Returns a value that represents an undefined ID.
protected  List<G> getInternalGroupList()
          Returns the internal group list.
protected  List<I> getInternalItemList()
          Returns the internal item list.
 I getItem(int index)
          Returns the item at the given position.
 List<I> getItems()
          Returns a list of this catalog's items.
 String getName()
          Returns the name of this catalog.
 List<String> getNotes()
          Returns a list of notes about this catalog.
 String getReservedGroupName()
          Returns the name that this catalog uses for its special group.
 int hashCode()
          Returns a hash code value for this catalog.
 G incrementIndexOfGroup(G group)
          Moves group to an index one higher than its current index.
 G incrementIndexOfGroupAt(int index)
          Moves the group at index to an index of index-plus-one.
 I incrementIndexOfItem(I item)
          Moves item to an index one higher than its current index.
 I incrementIndexOfItemAt(int index)
          Moves the item at index to an index of index-plus-one.
 int indexOf(I item)
          Returns the index of the first occurence of item in this catalog.
 int lastIndexOf(I item)
          Returns the index of the lasst occurence of item in this catalog.
 void memberAdded(G group, I newMember, int index)
          Called after newMember was added to group.
 void memberMoved(G group, I member, int fromIndex, int toIndex)
          Called after member was moved from one location to another within group.
 void memberRemoved(G group, I formerMember, int index)
          Called after formerMember was removed from group.
 void memberReplaced(G group, I formerMember, I newMember, int index)
          Called after the member located at index was replaced by another member.
 void membersSorted(G group)
          Called after the members of this group were sorted.
 G moveGroup(G group, int toIndex)
          Moves group toIndex.
 G moveGroup(int fromIndex, int toIndex)
          Moves a group fromIndex toIndex.
 I moveItem(I item, int toIndex)
          Moves item toIndex.
 I moveItem(int fromIndex, int toIndex)
          Moves an item fromIndex toIndex.
 void removeAllGroups()
          Removes all groups from this catalog.
 void removeAllItems()
          Removes all items from this catalog and its groups, but does not remove the groups themselves.
 void removeAllListeners()
          Removes all listeners from this catalog.
 G removeGroup(G group)
          Removes group from this catalog.
 G removeGroup(int index)
          Removes the group at index from this catalog.
 I removeItem(I item)
          Removes item from this catalog, if present.
 I removeItem(int index)
          Removes the item found at index.
 void removeListener(CatalogListener<I,G,C> listener)
          Removes listener from this catalog's list.
protected  void setId(Long id)
          Sets the ID of this catalog.
protected  void setInternalGroupList(List<G> replacementList)
          Replaces the internal group list with replacementList.
protected  void setInternalItemList(List<I> replacementList)
          Replaces the internal item list with replacementList.
 void setName(String newName)
          Sets the name of this catalog.
protected  void setReservedGroupName(String reservedName)
          Sets the name that this catalog will treat as a reserved name.
 int size()
          Returns the number of items in this catalog.
 void sort(Comparator<? super I> comparator)
          Uses comparator to sort the items of this catalog.
 void sortGroups(Comparator<? super G> comparator)
          Uses comparator to sort the members of this group.
 List<G> swapGroups(int index1, int index2)
          Swaps the groups at the given positions.
 List<I> swapItems(int index1, int index2)
          Swaps the items at the given positions.
protected  void tellListenersAboutFormerGroup(G formerGroup, int index)
           
protected  void tellListenersAboutMovedGroup(G group, int fromIndex, int toIndex)
           
protected  void tellListenersAboutNewGroup(G newGroup, int index)
           
 G toGroup()
          Creates and returns a group that has the same items in the same order as this catalog.
 String toString()
          Returns a text representation of this catalog.
 String toXml()
          Returns an XML representation of this catalog.
 void writeAsXmlTo(Writer writer)
          Writes an XML representation of this catalog to writer.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Catalog

public Catalog()
Helps create a new catalog with a default name.


Catalog

public Catalog(String nameOfCatalog)
Helps create a new catalog with the given name.

Parameters:
nameOfCatalog - the name of this catalog. If this value is null, this catalog will be given a default name.
Method Detail

createMainGroup

protected abstract G createMainGroup()
Creates and returns a new group to use as the holder of items for this catalog.

Returns:
a new group to use as this catalog's main group.

createGroup

public abstract G createGroup()
Returns a group of the same type of items used by this catalog.

Returns:
a group of the same type of items used by this catalog.

setId

protected void setId(Long id)
Sets the ID of this catalog. If id is null, this catalog's ID will be set to an unidentified ID.

Parameters:
id - a new ID for this catalog.

getIdOfUnidentified

protected long getIdOfUnidentified()
Returns a value that represents an undefined ID. Subclasses may override this method to suit their needs.


clearId

public void clearId()
Resets this catalog's ID, and the IDs of all its groups, to a value that represents the unidentified state. Note that it does nothing to the IDs of its items, because CatalogItem does not implement the Identifiable interface. Subclasses of this catalog whose items are Identifiable should override this method, call super.clearId(), then clear the IDs of their items.

This method is useful for preparing a catalog for storage in a database. The ID property (as of now, though this may change in the future) is used by our persistence mechanism to identify objects. If you are persisting this catalog for the first time, you may need to call this method before performing a save. This is especially true if you have created this source from XML, as the XML unmarshalling brings along the ID property.


getId

public Long getId()
Returns this catalog's ID.

Returns:
this catalog's ID.

setName

public void setName(String newName)
Sets the name of this catalog.

If newName is null or the empty string (""), the request to change the name will be denied and the current name will remain in place.

Parameters:
newName - the new name for this catalog.

getName

public String getName()
Returns the name of this catalog.

Returns:
the name of this catalog.

getNotes

public List<String> getNotes()
Returns a list of notes about this catalog. Each note is free-form text with no particular structure.

This method returns the list actually held by this Catalog, so any list manipulations may be performed by first fetching the list and then operating on it.

Returns:
a list of notes about this catalog.

addItem

public I addItem(I newItem)
Adds a new item to this catalog. The new item is added only if this catalog holds no item to which it is equal.

Parameters:
newItem - a new item for this catalog.
Returns:
the item that was added to, or was already a part of, this catalog. This will be either newItem if this catalog contains no item equal to newItem, or the first item in this catalog that is equal to newItem.

addItem

public I addItem(int index,
                 I newItem)
Adds a new item to this catalog at the specified position. The new item is added only if this catalog holds no item to which it is equal.

Parameters:
index - the position at which to insert the new item.
newItem - a prospective new item in this catalog.
Returns:
the item that was added to, or was already a part of, this catalog. This will be either newItem if this catalog contains no item equal to newItem, or the first item in this catalog that is equal to newItem.

addItems

public Collection<I> addItems(Collection<? extends I> newItems)
Adds newItems to this catalog. Only non-null elements of newItems that are not already part of this catalog are classified as new items.

Parameters:
newItems - new items in this catalog.
Returns:
the collection of items that were added to this catalog.

addItems

public Collection<I> addItems(int index,
                              Collection<? extends I> newItems)
Adds newItems to this catalog at the specified position. Only non-null elements of newItems that are not already part of this catalog are classified as new items.

Parameters:
index - the position at which to insert the first new item. Subsequent new items are added at successive positions.
newItems - new items in this catalog.
Returns:
the collection of items that were added to this catalog.

addItemEvenIfEqualToCurrentItem

public I addItemEvenIfEqualToCurrentItem(I newItem)
Adds newItem even if this catalog already has an item to which it is equal. Contrast this with addItem(CatalogItem).

The only times newItem is not added to this catalog are when it is null and when a reference to it is already contained in this catalog.

Parameters:
newItem - a potential new item for this catalog.
Returns:
newItem.

addItemEvenIfEqualToCurrentItem

public I addItemEvenIfEqualToCurrentItem(int index,
                                         I newItem)
Adds newItem even if this catalog already has an item to which it is equal. Contrast this with addItem(int, CatalogItem).

The only times newItem is not added to this catalog are when it is null and when a reference to it is already contained in this catalog.

Parameters:
index - the position at which to add newItem.
newItem - a potential new item for this catalog.
Returns:
newItem.

addGroup

public boolean addGroup(G newGroup)
Adds a new group to this catalog. All of the new group's members are also added to this catalog.

This catalog is now enforcing uniqueness for the names of its groups. If newGroup has the same name as a group that is already in this catalog, a side effect of this add method is that newGroup's name will be changed to newGroup.getName() + " (Copy #)", where "#" is the nth duplication of this name.

Parameters:
newGroup - a new group of items for this catalog.
Returns:
true if this catalog changed as a result of the call. Reasons for a return value of false:
  1. newGroup is null
  2. newGroup is already a part of this catalog

addGroup

public boolean addGroup(int index,
                        G newGroup)
Adds a new group to this catalog at the specified position. All of the new group's members are also added to this catalog.

This catalog is now enforcing uniqueness for the names of its groups. If newGroup has the same name as a group that is already in this catalog, a side effect of this add method is that newGroup's name will be changed to newGroup.getName() + " (Copy #)", where "#" is the nth duplication of this name.

Parameters:
index - the position at which to insert the new group.
newGroup - a new group of items for this catalog.
Returns:
true if this catalog changed as a result of the call. Reasons for a return value of false:
  1. newGroup is null
  2. newGroup is already a part of this catalog

addGroups

public boolean addGroups(Collection<? extends G> newGroups)
Adds newGroups to this catalog.

This is a convenience method that is the equivalent of iterating over newGroups and calling addGroup(CatalogItemGroup).

Parameters:
newGroups - new groups in this catalog.
Returns:
true if one or more groups were added to this catalog.

addGroups

public boolean addGroups(int index,
                         Collection<? extends G> newGroups)
Adds newGroups to this catalog at the specified position.

This is a convenience method that is the equivalent of iterating over newGroups and calling addGroup(int, CatalogItemGroup).

Parameters:
index - the position at which to insert the first new group. Subsequent new groups are added at successive positions.
newGroups - new groups in this catalog.
Returns:
true if one or more groups were added to this catalog.

tellListenersAboutNewGroup

protected void tellListenersAboutNewGroup(G newGroup,
                                          int index)

removeItem

public I removeItem(I item)
Removes item from this catalog, if present. The item is also removed from every group of this catalog in which it is present.

Parameters:
item - the item that is to be removed from this catalog.
Returns:
item if it had been an item in this catalog, null if it had not.

removeItem

public I removeItem(int index)
Removes the item found at index.

Parameters:
index - the index of the item to be removed.
Returns:
the removed item, or null if no item was removed.

removeGroup

public G removeGroup(G group)
Removes group from this catalog. Note that the items held by group are not removed from this catalog.

Parameters:
group - the group that is to be removed from this catalog.
Returns:
group if it had belonged to this catalog and was able to be removed, null otherwise.

removeGroup

public G removeGroup(int index)
Removes the group at index from this catalog. Note that the items held by group are not removed from this catalog.

Parameters:
index - the index of the group to be removed.
Returns:
the group found at index if it was able to be removed, null otherwise.

removeAllGroups

public void removeAllGroups()
Removes all groups from this catalog. No catalog items are removed as a result of the call.

See Also:
removeAllItems(), clear()

removeAllItems

public void removeAllItems()
Removes all items from this catalog and its groups, but does not remove the groups themselves.

See Also:
removeAllGroups(), clear()

clear

public void clear()
Removes all groups and all items from this catalog.

See Also:
removeAllItems(), removeAllGroups()

tellListenersAboutFormerGroup

protected void tellListenersAboutFormerGroup(G formerGroup,
                                             int index)

incrementIndexOfItem

public I incrementIndexOfItem(I item)
Moves item to an index one higher than its current index. The item will not be moved if it is not in this catalog, or if it is already in the highest position.

If item is in this catalog in multiple positions, the instance with the highest index will be moved.

Parameters:
item - the item to be moved.
Returns:
if no movement occurred, null is returned. Otherwise the item that was moved is returned. This will be either item, or an equal item that was already part of this catalog.

decrementIndexOfItem

public I decrementIndexOfItem(I item)
Moves item to an index one lower than its current index. The item will not be moved if it is not in this catalog, or if it is already in the lowest position.

If item is in this catalog in multiple positions, the instance with the lowest index will be moved.

Parameters:
item - the item to be moved.
Returns:
if no movement occurred, null is returned. Otherwise the item that was moved is returned. This will be either item, or an equal item that was already part of this catalog.

incrementIndexOfItemAt

public I incrementIndexOfItemAt(int index)
Moves the item at index to an index of index-plus-one. No move will occur if index is out of bounds, or if it is already the highest index of this catalog.

Parameters:
index - the index of the item to be moved.
Returns:
the item that was moved, or null if no item was moved.

decrementIndexOfItemAt

public I decrementIndexOfItemAt(int index)
Moves the item at index to an index of index-minus-one. No move will occur if index is out of bounds, or if it is already the lowest index of this catalog.

Parameters:
index - the index of the item to be moved.
Returns:
the item that was moved, or null if no item was moved.

swapItems

public List<I> swapItems(int index1,
                         int index2)
Swaps the items at the given positions.

If the indices are equal, no action is taken. If one or both of the indices are not in the range [0,size()), the underlying List will throw an exception.

Parameters:
index1 - the position of the one of the items.
index2 - the position of another of the items.
Returns:
a list with the item originally at the lower index followed by the item originally at the higher index. If no swap was made the returned list will be empty.

moveItem

public I moveItem(int fromIndex,
                  int toIndex)
Moves an item fromIndex toIndex.

Parameters:
fromIndex - the current index of an item.
toIndex - the new index of that same item.
Returns:
the item that moved.

moveItem

public I moveItem(I item,
                  int toIndex)
Moves item toIndex.

Parameters:
item - the item to be moved.
toIndex - the new position for item.
Returns:
the item that moved, or null if no movement occurred. Note that the item that moved might be item or, alternatively, an item equal to item, if this catalog has such an item.

sort

public void sort(Comparator<? super I> comparator)
Uses comparator to sort the items of this catalog.

Parameters:
comparator - used to order this catalog's items.

incrementIndexOfGroup

public G incrementIndexOfGroup(G group)
Moves group to an index one higher than its current index. The group will not be moved if it is not in this catalog, or if it is already in the highest position.

If group is in this catalog in multiple positions, the instance with the highest index will be moved. (It is not generally possible for a group to occupy multiple positions in a catalog.) Note that the special group that holds all items of this catalog may not be moved.

Parameters:
group - the group to be moved.
Returns:
if no movement occurred, null is returned. Otherwise the group that was moved is returned. This will be either group, or an equal group that was already part of this catalog.

decrementIndexOfGroup

public G decrementIndexOfGroup(G group)
Moves group to an index one lower than its current index. The group will not be moved if it is not in this catalog, or if it is already in the lowest position.

If group is in this catalog in multiple positions, the instance with the lowest index will be moved. (It is not generally possible for a group to occupy multiple positions in a catalog.) Note that the special group that holds all items of this catalog may not be moved.

Parameters:
group - the group to be moved.
Returns:
if no movement occurred, null is returned. Otherwise the group that was moved is returned. This will be either group, or an equal group that was already part of this catalog.

incrementIndexOfGroupAt

public G incrementIndexOfGroupAt(int index)
Moves the group at index to an index of index-plus-one. No move will occur if index is out of bounds, or if it is already the highest index of this catalog.

Parameters:
index - the index of the group to be moved.
Returns:
the group that was moved, or null if no group was moved.

decrementIndexOfGroupAt

public G decrementIndexOfGroupAt(int index)
Moves the group at index to an index of index-minus-one. No move will occur if index is out of bounds, or if it is already the lowest index of this catalog.

Parameters:
index - the index of the group to be moved.
Returns:
the group that was moved, or null if no group was moved.

swapGroups

public List<G> swapGroups(int index1,
                          int index2)
Swaps the groups at the given positions.

If the indices are equal, no action is taken. If one or both of the indices are not in the range [0,size()), the underlying List will throw an exception.

Parameters:
index1 - the position of the one of the groups.
index2 - the position of another of the groups.
Returns:
a list with the group originally at the lower index followed by the group originally at the higher index. If no swap was made the returned list will be empty.

moveGroup

public G moveGroup(int fromIndex,
                   int toIndex)
Moves a group fromIndex toIndex.

Parameters:
fromIndex - the current index of a group.
toIndex - the new index of that same group.
Returns:
the group that moved, even if it moved back to the same position.

moveGroup

public G moveGroup(G group,
                   int toIndex)
Moves group toIndex.

Parameters:
group - the group to be moved.
toIndex - the new position for group.
Returns:
the group that moved, or null if no movement occurred.

sortGroups

public void sortGroups(Comparator<? super G> comparator)
Uses comparator to sort the members of this group.

Parameters:
comparator - used to order this group's members

tellListenersAboutMovedGroup

protected void tellListenersAboutMovedGroup(G group,
                                            int fromIndex,
                                            int toIndex)

size

public int size()
Returns the number of items in this catalog. (A group is not considered to be an item.)

Returns:
the number of items in this catalog.

getItem

public I getItem(int index)
Returns the item at the given position.

Parameters:
index - the position of the item to return.
Returns:
the item at index.

getItems

public List<I> getItems()
Returns a list of this catalog's items. (A group is not considered to be an item.)

Note that the returned list is not held internally by this catalog. This means that any changes made to the returned list will not be reflected in this object. The elements of the list, though, are the actual items of this catalog, so changes made to them will be reflected in this catalog.

Returns:
a list of this catalog's items. The returned value is guaranteed to be non-null, but it may be an empty list.

getInternalItemList

protected List<I> getInternalItemList()
Returns the internal item list. This method is meant solely for use by frameworks (such as JAXB or Hibernate) that rely on getX/setX pairs for persisted properties. It is protected, as opposed to private, so that subclasses can create and annotate methods that call this one.


setInternalItemList

protected void setInternalItemList(List<I> replacementList)
Replaces the internal item list with replacementList. This method is meant solely for use by frameworks (such as JAXB or Hibernate) that rely on getX/setX pairs for persisted properties. It is protected, as opposed to private, so that subclasses can create and annotate methods that call this one.


contains

public boolean contains(I item)
Returns true if this catalog holds item.

Parameters:
item - a possible item in this catalog.
Returns:
true if this catalog holds item.

indexOf

public int indexOf(I item)
Returns the index of the first occurence of item in this catalog. See List.indexOf(Object) for more details.

Parameters:
item - a potential item of this catalog
Returns:
the index of the first occurence of item in this catalog, or -1 if this catalog does not contain item.

lastIndexOf

public int lastIndexOf(I item)
Returns the index of the lasst occurence of item in this catalog. See List.lastIndexOf(Object) for more details.

Parameters:
item - a potential item of this catalog
Returns:
the index of the last occurence of item in this catalog, or -1 if this catalog does not contain item.

getGroup

public G getGroup(int index)
Returns the group at the given position.

Parameters:
index - the position of the group to return.
Returns:
the group at index.

getGroup

public G getGroup(String groupName)
Returns a group with the given name, or null if this catalog has no such group.

Parameters:
groupName - the name of group potentially in this catalog.
Returns:
a group with the given name, or null if this catalog has no such group.

getGroups

public List<G> getGroups()
Returns a list of this catalog's groups.

Note that the returned list is not held internally by this catalog. This means that any changes made to the returned list will not be reflected in this object. The elements of the list, though, are the actual groups of this catalog, so changes made to them will be reflected in this catalog.

Returns:
a list of this catalog's groups. The returned value is guaranteed to be non-null, but it may be an empty list.

getGroupsThatContain

public List<G> getGroupsThatContain(I item)
Returns a list of groups that contain item.

Parameters:
item - an item of this catalog that may be in one or more groups.
Returns:
a list of groups that contain item.

containsGroupNamed

public boolean containsGroupNamed(String name)
Returns true if this catalog contains a group with the given name.

Parameters:
name - potential name of a group contained by this catalog.
Returns:
true if this catalog has a group named name.

getInternalGroupList

protected List<G> getInternalGroupList()
Returns the internal group list. This method is meant solely for use by frameworks (such as JAXB or Hibernate) that rely on getX/setX pairs for persisted properties. It is protected, as opposed to private, so that subclasses can create and annotate methods that call this one.


setInternalGroupList

protected void setInternalGroupList(List<G> replacementList)
Replaces the internal group list with replacementList. This method is meant solely for use by frameworks (such as JAXB or Hibernate) that rely on getX/setX pairs for persisted properties. It is protected, as opposed to private, so that subclasses can create and annotate methods that call this one.


getReservedGroupName

public String getReservedGroupName()
Returns the name that this catalog uses for its special group. The special group is the internal group that holds all the items of this catalog. No other group may use this name.

Returns:
the name that this catalog uses for its special group.

setReservedGroupName

protected void setReservedGroupName(String reservedName)
Sets the name that this catalog will treat as a reserved name. The reserved name is used for the special group that holds all the items in this catalog.

Parameters:
reservedName - the name this catalog will use for its special group. If this value is null, this catalog will use a default name in its place.

addListener

public void addListener(CatalogListener<I,G,C> newListener)
Adds newListener to this catalog list.

The listener will be informed whenever:

Parameters:
newListener - the listener to be added to this catalog's list.

removeListener

public void removeListener(CatalogListener<I,G,C> listener)
Removes listener from this catalog's list.

Parameters:
listener - the listener to be removed from this catalog's list.

removeAllListeners

public void removeAllListeners()
Removes all listeners from this catalog.


memberAdded

public void memberAdded(G group,
                        I newMember,
                        int index)
Description copied from interface: CatalogItemGroupListener
Called after newMember was added to group.

Specified by:
memberAdded in interface CatalogItemGroupListener<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>
Parameters:
group - the group to which a new member was added.
newMember - the new member added to group.
index - the index at which the new member was added.

memberRemoved

public void memberRemoved(G group,
                          I formerMember,
                          int index)
Description copied from interface: CatalogItemGroupListener
Called after formerMember was removed from group.

Specified by:
memberRemoved in interface CatalogItemGroupListener<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>
Parameters:
group - the group from which a member was removed.
formerMember - the member removed from group.
index - the index at which the former member had been located.

memberMoved

public void memberMoved(G group,
                        I member,
                        int fromIndex,
                        int toIndex)
Description copied from interface: CatalogItemGroupListener
Called after member was moved from one location to another within group.

It is anticipated that most implementations of CatalogItemGroup will send this message only for the member that instigated the change in this list. For example, if the last member of the list was moved to the first position in the list, only one message will be sent, even though every member of the list is now in a new position. The message sent for this example would be for the member now in the first position.

Specified by:
memberMoved in interface CatalogItemGroupListener<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>
Parameters:
group - the group in which the movement occurred.
member - the member whose position changed.
fromIndex - the position at which the member had been located.
toIndex - the position at which the member is now located.

memberReplaced

public void memberReplaced(G group,
                           I formerMember,
                           I newMember,
                           int index)
Description copied from interface: CatalogItemGroupListener
Called after the member located at index was replaced by another member.

Specified by:
memberReplaced in interface CatalogItemGroupListener<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>
Parameters:
group - the group in which the replacement occurred.
formerMember - the member that had been located at index.
newMember - the member that is now located at index.
index - the position at which the replacement occurred.

membersSorted

public void membersSorted(G group)
Description copied from interface: CatalogItemGroupListener
Called after the members of this group were sorted.

Specified by:
membersSorted in interface CatalogItemGroupListener<I extends CatalogItem<I>,G extends CatalogItemGroup<I,G,C>,C extends Catalog<I,G,C>>
Parameters:
group - the group whose members were sorted.

toString

public String toString()
Returns a text representation of this catalog.

Overrides:
toString in class Object
Returns:
a text representation of this catalog.

toXml

public String toXml()
             throws JAXBException
Returns an XML representation of this catalog.

Returns:
an XML representation of this catalog.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.

writeAsXmlTo

public void writeAsXmlTo(Writer writer)
                  throws JAXBException
Writes an XML representation of this catalog to writer.

Parameters:
writer - the device to which XML is written.
Throws:
JAXBException - if anything goes wrong during the conversion to XML.

toGroup

public G toGroup()
Creates and returns a group that has the same items in the same order as this catalog.

Returns:
a group representation of this catalog.

clone

public C clone()
Returns a catalog that is a copy of this one.

The returned catalog has items and groups with the same properties as those of this catalog, but those items and groups are new and distinct from those held herein.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Overrides:
clone in class Object

equals

public boolean equals(Object o)
Returns true if o is equal to this catalog.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this catalog.

Overrides:
hashCode in class Object


Copyright © 2009. All Rights Reserved.