Class Functions


  • public class Functions
    extends java.lang.Object
    JSP EL Functions. This file contains static methods that are used by JSP EL.
    • Field Detail

      • DEFAULT_HOMEPAGE_URL

        public static final java.lang.String DEFAULT_HOMEPAGE_URL
        See Also:
        Constant Field Values
    • Constructor Detail

      • Functions

        public Functions()
    • Method Detail

      • getPrimaryImageForProductAndFormat

        public static ImageData getPrimaryImageForProductAndFormat​(ProductData product,
                                                                   java.lang.String format)
        JSP EL Function to get a primary Image for a Product in a specific format
        Parameters:
        product - the product
        format - the desired format
        Returns:
        the image
      • getPrimaryImageForTypeAndFormat

        protected static ImageData getPrimaryImageForTypeAndFormat​(java.util.Collection<ImageData> images,
                                                                   java.lang.String format)
      • getImageForStoreAndFormat

        public static ImageData getImageForStoreAndFormat​(PointOfServiceData store,
                                                          java.lang.String format)
        JSP EL Function to get an Image for a Store in a specific format
        Parameters:
        store - the store
        format - the desired image format
        Returns:
        the image
      • getImageForFormat

        protected static ImageData getImageForFormat​(java.util.Collection<ImageData> images,
                                                     java.lang.String format)
      • getUrlForCMSLinkComponent

        public static java.lang.String getUrlForCMSLinkComponent​(CMSLinkComponentModel component)
        JSP EL Function to get the URL for a CMSLinkComponent
        Parameters:
        component - The Link Component
        Returns:
        The URL
      • getProductUrlConverter

        protected static Converter<ProductModel,​ProductData> getProductUrlConverter​(javax.servlet.http.HttpServletRequest httpRequest)
      • getCMSPageContextService

        protected static CMSPageContextService getCMSPageContextService​(javax.servlet.http.HttpServletRequest httpRequest)
      • getCMSPageSlotComponentService

        protected static CMSPageSlotComponentService getCMSPageSlotComponentService​(javax.servlet.http.HttpServletRequest httpRequest)
      • getSpringBean

        public static <T> T getSpringBean​(javax.servlet.http.HttpServletRequest httpRequest,
                                          java.lang.String beanName,
                                          java.lang.Class<T> beanClass)
        Returns the Spring bean with name beanName and of type beanClass.
        Type Parameters:
        T - type of the bean
        Parameters:
        httpRequest - the http request
        beanName - name of the bean
        beanClass - expected type of the bean
        Returns:
        the bean matching the given arguments or null if no bean could be resolved
      • isConsumedByEntry

        public static boolean isConsumedByEntry​(PromotionOrderEntryConsumedData consumed,
                                                OrderEntryData entry)
        Test if entry or grouped entry belongs to consumed entry
        Parameters:
        consumed -
        entry -
        Returns:
        true if consumed entry and entry/grouped entry corresponds to each other otherwise false
      • doesAppliedPromotionExistForOrderEntry

        public static boolean doesAppliedPromotionExistForOrderEntry​(CartData cart,
                                                                     int entryNumber)
        Test if a cart has an applied promotion for the specified entry number.
        Parameters:
        cart - the cart
        entryNumber - the entry number
        Returns:
        true if there is an applied promotion for the entry number
      • doesAppliedPromotionExistForOrderEntryOrOrderEntryGroup

        public static boolean doesAppliedPromotionExistForOrderEntryOrOrderEntryGroup​(CartData cart,
                                                                                      OrderEntryData entry)
        Test if a cart has an applied promotion for the specified entry or grouped entry.
        Parameters:
        cart - the cart
        entry - the order entry
        Returns:
        true if there is an applied promotion for the entry number
      • doesPotentialPromotionExistForOrderEntry

        public static boolean doesPotentialPromotionExistForOrderEntry​(CartData cart,
                                                                       int entryNumber)
        Test if a cart has an potential promotion for the specified entry number.
        Parameters:
        cart - the cart
        entryNumber - the entry number
        Returns:
        true if there is an potential promotion for the entry number
      • doesPotentialPromotionExistForOrderEntryOrOrderEntryGroup

        public static boolean doesPotentialPromotionExistForOrderEntryOrOrderEntryGroup​(CartData cart,
                                                                                        OrderEntryData entry)
        Test if a cart has an potential promotion for the specified entry or entry group.
        Parameters:
        cart - the cart
        entry - the entry
        Returns:
        true if there is an potential promotion for the entry or entry group
      • doesPromotionExistForOrderEntry

        public static boolean doesPromotionExistForOrderEntry​(java.util.List<PromotionResultData> productPromotions,
                                                              int entryNumber)
      • doesPromotionExistForOrderEntry

        protected static boolean doesPromotionExistForOrderEntry​(java.lang.Integer entryNumberToFind,
                                                                 PromotionResultData productPromotion)
      • encodeUrl

        public static java.lang.String encodeUrl​(java.lang.String url)
        Utility method that encodes given URL
        Parameters:
        url - the url to encode
        Returns:
        encoded URL
      • encodeHTML

        public static java.lang.String encodeHTML​(java.lang.String valueToBeEncoded)
        Utility method that encodes the given input as HTML
        Parameters:
        valueToBeEncoded - the value to encode
        Returns:
        value encoded as HTML
      • sanitizeHtmlTagName

        public static java.lang.String sanitizeHtmlTagName​(java.lang.String tag)
        Validates that tag is a valid HTML tag name
        Parameters:
        tag - HTML tag name
        Returns:
        tag if valid, div if it is not valid.
      • encodeJavaScript

        public static java.lang.String encodeJavaScript​(java.lang.String valueToBeEncoded)
        Utility method that encodes the given input as HTML
        Parameters:
        valueToBeEncoded - the value to encode
        Returns:
        value encoded as JavaScript
      • checkIfPickupEnabledForStore

        public static boolean checkIfPickupEnabledForStore()
        Utility tag function to check if Pickup mode is enabled for the current base store.
        Returns:
        boolean
      • getCurrentRequest

        protected static javax.servlet.http.HttpServletRequest getCurrentRequest()
      • isExtensionInstalled

        public static boolean isExtensionInstalled​(java.lang.String extensionName)
      • isQuoteUserSalesRep

        public static boolean isQuoteUserSalesRep()
      • isQuoteUserSellerApprover

        public static boolean isQuoteUserSellerApprover()
      • getQuoteUserTypeIdentificationStrategy

        protected static QuoteUserTypeIdentificationStrategy getQuoteUserTypeIdentificationStrategy​(javax.servlet.http.HttpServletRequest httpRequest)
      • getQuoteUserIdentificationStrategy

        protected static QuoteUserIdentificationStrategy getQuoteUserIdentificationStrategy​(javax.servlet.http.HttpServletRequest httpRequest)
      • normalizedCode

        public static java.lang.String normalizedCode​(java.lang.String code)
        Returns normalized code for selection data code
        Parameters:
        code -
        Returns:
        code normalized according to replace condition
      • getImageForProductCode

        public static ImageData getImageForProductCode​(ProductData product,
                                                       java.lang.String productCode,
                                                       java.lang.String format)
        JSP EL Function to get an image for a Product in a specific format based on the product code.
        Parameters:
        product - The product.
        productCode - The desired product code.
        format - The desired format.
        Returns:
        The image.
      • getImageData

        protected static ImageData getImageData​(ProductData product,
                                                java.lang.String productCode,
                                                java.lang.String format)
      • arrayContainsInstance

        public static boolean arrayContainsInstance​(java.lang.String[] stringArr,
                                                    java.lang.String string)
        Check if array contains instance.
        Parameters:
        stringArr - the string array
        string - the string instance
        Returns:
        true, if contains