Class MapToArrayDefaultFirst

  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.commerce.util.MapToArrayDefaultFirst
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class MapToArrayDefaultFirst
extends DynamoServlet

This droplet is used to convert a map of items to a sorted array of map entries with the default item in the beginning of the array. The default item is specified either through defaultId parameter (only for repository items) or through defaultKey parameter that is the map key that corresponds to the default item.

The droplet is primarily intended to sort shipping addresses or credit cards so that the default address or card is displayed as the first item on the JSP page.

If sortByKeys parameter is set to true then the returning array will be sorted by keys otherwise an unsorted array will be returned. In the case of a null map, the returning array would be null.

This droplet takes the following parameters

The parameter that defines the repositoryId of the default item. Can be used only for repository item, for other types of objects like ShippingGroup the defaultKey parameter should be used.
The parameter that defines the map key of the default item that should be placed in the beginning of the array.
Boolean that specifies whether to sort map entries by keys or not.
The parameter that defines the map of items to convert to the sorted array.


  <dsp:droplet name="MapToArrayDefaultFirst">
     <param name="defaultId" value="Profile.shippingAddress.repositoryId"/>
     <param name="map" value="Profile.secondaryAddresses"/>
     <oparam name="output">
        <dsp:droplet name="ForEach">
           <param name="array" value="sortedArray"/>
           <oparam name="output">
              key: &ltdsp:valueof param="element.key"/&gt
              address city: <dsp:valueof param=""&gt/>


   output- Rendered on successful sort.
     sortedArray- Array of RepositoryItem object with the default item first      sortedArraySize- Size of returned array

Field Summary
static java.lang.String CLASS_VERSION
          Class version string.
static ParameterName DEFAULT_ID
          Default id parameter name.
static ParameterName DEFAULT_KEY
          Default key parameter name.
static ParameterName MAP
          Map parameter name.
static ParameterName OUTPUT
          Output parameter name.
static ParameterName SORT_BY_KEYS
          Sort by keys parameter name
static java.lang.String SORTED_ARRAY
          Sorted array parameter name.
static java.lang.String SORTED_ARRAY_SIZE
          Sorted array size parameter name.
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
Fields inherited from class atg.nucleus.servlet.ServletService
Fields inherited from class atg.nucleus.GenericService
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
Constructor Summary
Method Summary
protected  java.lang.String getDefaultMapKey(java.util.Map pMap, java.lang.String pDefaultId)
          Taken the map of repository items and default ID value returns a map key that corresponds to the item with the specified repository ID.
protected  java.lang.Object[] getSortedArray(java.util.Map pMap, java.lang.String pDefaultKey, boolean pSortByKeys, DynamoHttpServletRequest pRequest)
          Converts the map to the array of map entries with the default one in the beginning of the array.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          See the class documentation above.
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
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


public static java.lang.String CLASS_VERSION
Class version string.


public static final ParameterName MAP
Map parameter name.


public static final ParameterName DEFAULT_ID
Default id parameter name.


public static final ParameterName DEFAULT_KEY
Default key parameter name.


public static final ParameterName SORT_BY_KEYS
Sort by keys parameter name


public static final ParameterName OUTPUT
Output parameter name.


public static java.lang.String SORTED_ARRAY
Sorted array parameter name.


public static java.lang.String SORTED_ARRAY_SIZE
Sorted array size parameter name.

Constructor Detail


public MapToArrayDefaultFirst()
Method Detail


public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,

See the class documentation above.

service in class DynamoServlet
pRequest - - http request
pResponse - - http response
javax.servlet.ServletException - if an error occurs - if an error occurs


protected java.lang.Object[] getSortedArray(java.util.Map pMap,
                                            java.lang.String pDefaultKey,
                                            boolean pSortByKeys,
                                            DynamoHttpServletRequest pRequest)
Converts the map to the array of map entries with the default one in the beginning of the array. If pSortByKeys boolean is true then map entries are sorted by keys.

pMap - - the map to convert to the sorted array
pDefaultKey - - the map key that corresponds to the default item
pSortByKeys - - boolean that specifies whether to sort items by keys or not
pRequest - - the http request
Object[] sorted array of items


protected java.lang.String getDefaultMapKey(java.util.Map pMap,
                                            java.lang.String pDefaultId)
Taken the map of repository items and default ID value returns a map key that corresponds to the item with the specified repository ID. This method is intended for the map of repository items only. For maps of objects different from repository items returns null.

pMap - - map of repository items to check
pDefaultId - - default id
the map key that corresponds to the item with default ID or null if the map holds objects different from repository items or default ID is not specified.