atg.commerce.catalog.comparison
Class ComparisonList

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.catalog.comparison.ComparisonList
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
ProductComparisonList

public class ComparisonList
extends GenericService

ComparisonList maintains a list of items that the user might want to compare with each other, together with an associated set of sort directives to apply when displaying the items in the list.

Like Java List classes, ComparisonList maintains the insertion order of items in the list. Unlike the List classes, it prohibits duplicate entries in the list by ignoring requests to add items that compare equal to items already in the list.

ComparisonList wraps access to the list in synchronized blocks to assure that all operations on the list are carried out atomically. This makes it possible for multiple request-scoped droplets and form handlers to operate on a shared session-scoped ComparisonList safely, as long as all changes to the list are made through the ComparisonList API.

If an application calls getItems() to obtain a direct reference to the list, the application could should either perform all access to the list within synchronized blocks that synchronize on the list itself, or call the synchronizedList method of java.util.Collections to obtain a synchronized version of the list and access the list through the synchronized wrapper.

See Also:
TableInfo

Field Summary
static java.lang.String CLASS_VERSION
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ComparisonList()
           
 
Method Summary
 boolean addItem(java.lang.Object pItem)
          Add an item to the end of the comparison list if and only if it was not already present in the list.
 void clear()
          Remove all items from the comparison list.
 boolean containsItem(java.lang.Object pItem)
          Return true if the comparison list contains the specified item.
 java.lang.Object getItem(int pIndex)
          Return the item at the specified index in the comparison list.
 java.util.List getItems()
          Get the list of items being compared.
 java.lang.String getPrimarySortString()
          Get a string suitable for use with the sortProperties parameter of droplets like ForEach, representing the sort direction and property name for the first entry in the list of sort criteria.
 java.lang.String getSortString()
          Get a string suitable for use with the sortProperties parameter of droplets like ForEach, representing the sort direction and property name for all entries in the list of sort criteria.
 TableInfo.Column[] getTableColumns()
           
 TableInfo getTableInfo()
           
 int indexOf(java.lang.Object pItem)
          Return the index of the specified item in the comparison list, or -1 if the item does not appear in the list.
 java.lang.Object removeItem(int pIndex)
          Remove an item from the comparison list if it was present in the list to begin with.
 boolean removeItem(java.lang.Object pItem)
          Remove an item from the comparison list if it was present in the list to begin with.
 void setItems(java.util.List pItems)
          Set the list of items being compared.
 void setTableInfo(TableInfo pTableInfo)
           
 int size()
          Return the number of items in the comparison list.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

ComparisonList

public ComparisonList()
Method Detail

setItems

public void setItems(java.util.List pItems)
Set the list of items being compared. The specified list will be wrapped in a synchronous list by calling java.util.Collections.synchronizedList so that multiple request scoped form handlers can safely operate on session scoped comparison lists.


getItems

public java.util.List getItems()
Get the list of items being compared. Callers should treat the list as readonly, and all modifications should be made through the ComparisonList API.

See Also:
List

setTableInfo

public void setTableInfo(TableInfo pTableInfo)

getTableInfo

public TableInfo getTableInfo()

getTableColumns

public TableInfo.Column[] getTableColumns()

addItem

public boolean addItem(java.lang.Object pItem)
Add an item to the end of the comparison list if and only if it was not already present in the list.

Parameters:
pItem - The object to add.
Returns:
true if the item was added to the list, false if the item was already present in the list.

removeItem

public boolean removeItem(java.lang.Object pItem)
Remove an item from the comparison list if it was present in the list to begin with.

Parameters:
pItem - The object to remove.
Returns:
true if the item was removed from the list, false if the item was not present in the list.

removeItem

public java.lang.Object removeItem(int pIndex)
Remove an item from the comparison list if it was present in the list to begin with.

Parameters:
pIndex - The index position of the object to remove.
Returns:
The item that was removed.

containsItem

public boolean containsItem(java.lang.Object pItem)
Return true if the comparison list contains the specified item. Containment is determined by the List implementation, which uses list_element.equals(pItem). Therefore, the items in question need not be the same object so long as the list element's equals method considers them equal to one another.


indexOf

public int indexOf(java.lang.Object pItem)
Return the index of the specified item in the comparison list, or -1 if the item does not appear in the list.


getItem

public java.lang.Object getItem(int pIndex)
Return the item at the specified index in the comparison list.


size

public int size()
Return the number of items in the comparison list.


clear

public void clear()
Remove all items from the comparison list.


getSortString

public java.lang.String getSortString()
Get a string suitable for use with the sortProperties parameter of droplets like ForEach, representing the sort direction and property name for all entries in the list of sort criteria. For example, if if the sort criteria consist of "date descending, author ascending", this method will return the string "-date,+author".

This method is just shorthand for calling getSortProperties().getSortString()


getPrimarySortString

public java.lang.String getPrimarySortString()
Get a string suitable for use with the sortProperties parameter of droplets like ForEach, representing the sort direction and property name for the first entry in the list of sort criteria. For example, if the sort criteria consist of "date descending, author ascending", this method will return the string "-date".

This method is just shorthand for calling getSortProperties().getPrimarySortString()