Interface BusinessObjectUtils

All Known Implementing Classes:
BusinessObjectUtilsImpl

public interface BusinessObjectUtils
Interface for a utility object containing various methods used by BusinessProcessors in performing business logic.

Each BusinessProcessors is able to retrieve an instance of BusinessObjectUtils by calling its utils method.

The default "businessObjectUtilsImplementer" is BusinessObjectUtilsImpl.

Author:
David Tobey
  • Method Details

    • formatDateTime

      String formatDateTime(Date dateTime)
      Formats a Date object into a string suitable for storage in the database.
      Parameters:
      dateTime -
      Returns:
      a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.
    • parseDateTime

      Date parseDateTime(String dateTime)
      Parses a string (typically taken from a database query) into a Date object.
      Parameters:
      dateTime -
      Returns:
      a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.
    • formatPrice

      String formatPrice(Double rawPrice, String currencyCode, Locale locale)
      Formats a Double into a string suitable for displaying the double as a price, or a price representing 0 if the Double is null.
      Parameters:
      rawPrice -
      currencyCode -
      locale -
      Returns:
      a String suitable for displaying the double as a price.
    • formatPrice

      String formatPrice(double rawPrice, String currencyCode, Locale locale)
      Formats a double into a string suitable for displaying the double as a price.
      Parameters:
      rawPrice -
      currencyCode -
      locale -
      Returns:
      a String suitable for displaying the double as a price.
    • prepareRequestData

      String prepareRequestData(Map params, boolean urlEncode) throws Exception
      Prepares a string, which may optionally be url-encoded, for use with an HTTP request, given a map of the request's parameters.
      Parameters:
      params - A Map of key-value String pairs representing the parameters of the request.
      urlEncode - If true, the keys and values in the string will be url-encoded.
      Returns:
      A String representing a valid URL-encoded query string.
      Throws:
      Exception
    • parseResponseData

      Map parseResponseData(String response) throws Exception
      Parses a query string of name value pairs into a Map.
      Parameters:
      response - A String key-value pairs in the form of a URL query string
      Returns:
      A Map representing the query string.
      Throws:
      Exception
    • sendHTTPPost

      String sendHTTPPost(String urlString, String postData, boolean followRedirect, Map requestProperties, String inputCharSet, Integer timeoutInSeconds) throws Exception
      Sends an HTTP request using the POST method to a given URL.
      Parameters:
      urlString - The URL to send the request to.
      postData - A String representing a valid URL-encoded query string.
      followRedirect - A boolean indicating whether redirects should be followed.
      requestProperties - Map that holds request properties to be sent in connection.
      inputCharSet - Character set of the response data
      timeoutInSeconds - The timeout in seconds before an exception is thrown. If null there is no timeout.
      Returns:
      A String representing the server's response, or the Location header if redirects are not to be followed.
      Throws:
      Exception
    • sendHTTPGet

      String sendHTTPGet(String urlString, String postData, boolean followRedirect, Map requestProperties, String inputCharSet, Integer timeoutInSeconds) throws Exception
      Throws:
      Exception
    • getMapsFromBeans

      Collection getMapsFromBeans(Collection beans)
      Given a collection of bean objects returns a collection of Maps describing each bean's properties.
      Parameters:
      beans -
      Returns:
      A Collection of Maps describing the beans.
    • parse

      Document parse(InputStream xmlStream, boolean ignoreWhitespace) throws ParserConfigurationException, SAXException, IOException
      Returns a DOM Level2 document that represents the given document.
      Parameters:
      xmlStream - An InputStream that is the source of the XML data
      ignoreWhitespace - This is passed through to the DocumentBuilder.
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • parsePartialDocument

      Node parsePartialDocument(String xml) throws ParserConfigurationException, SAXException, IOException
      Parses a section of XML and returns the first Element node found
      Parameters:
      xml - The XML to be parsed in String form
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • stringArrayValuesGreaterThan

      boolean stringArrayValuesGreaterThan(String[] paramValues, int value)
      Determines if at least one element in a string array is greater than a given value.
      Parameters:
      paramValues - The string array being tested.
      value - The value for the string array's elements to be tested against.
      Returns:
      true if at least one element in a string array is greater than a given value. false if not.
    • roundForMoney

      Double roundForMoney(Double value)
      Rounds money values in general
      Parameters:
      value - The value to be rounded.
      Returns:
      The value after rounding
    • roundForMoney

      Double roundForMoney(double value)
      Rounds money values in general
      Parameters:
      value - The value to be rounded.
      Returns:
      The value after rounding
    • buildOrderItemAttributeMap

      Map buildOrderItemAttributeMap(OrderItem oi)
      From a given OrderItem, returns a Map of each of the OrderItemAttributes under it, keyed by the attributeCode.
      Parameters:
      oi -
      Returns:
      A Map of OrderItemAttributes and their values.
    • doesOrderItemHaveAttributeCode

      boolean doesOrderItemHaveAttributeCode(OrderItem oi, String attributeCode)
      Tests to see if a given order item has an OrderItemAttribute under it with the given attributeCode.
      Parameters:
      oi - The order item
      attributeCode - The attribute code
      Returns:
      true, if the OrderItem has an OrderItemAttribute under it with the attributeCode.