Class Util

java.lang.Object
com.day.cq.reporting.helpers.Util

public class Util extends Object
Class that provides some helper functionality.
  • Method Details

    • createTimeStamp

      public static long createTimeStamp(Calendar cal)
      Creates a timestamp (format: yyyymmddhhmmss) from the specified Calendar,
      Parameters:
      cal - The calendar
      Returns:
      The timestamp
    • writeToJSON

      public static void writeToJSON(JSONWriter writer, com.day.cq.reporting.impl.snapshots.AggregationInterval interval, Calendar cal, TimeZone timeZone, Locale locale) throws JSONException
      Writes the specified Calendar to the specified JSONWriter.
      Parameters:
      writer - The writer
      interval - The aggregation interval to create display values for
      cal - The calendar
      timeZone - The time zone
      locale - The locale
      Throws:
      JSONException - if writing data failed
    • clearTime

      public static void clearTime(Calendar calendar)
      Clears the time information by setting it back to midnight.
      Parameters:
      calendar - The calendar to clear time information from
    • arrayContainsString

      public static boolean arrayContainsString(String[] array, String str)
      Determines if the specified String array contains the specified string.
      Parameters:
      array - The array
      str - The string
      Returns:
      true if the array contains the given string
    • getRenderTypeFromRequest

      public static String getRenderTypeFromRequest(SlingHttpServletRequest req)
      Gets the render type from the reuest.
      Parameters:
      req - The request to determine the render type from
      Returns:
      The render type (Const.RENDER_TYPE_TABULAR or Const.RENDER_TYPE_CHART; null for rendering the chart in default mode
    • getChartIdFromRequest

      public static String getChartIdFromRequest(SlingHttpServletRequest req)
      Gets a chart id for rendering from the specified request, if applicable.
      Parameters:
      req - The request
      Returns:
      The chart id; null if no chart id is available/required
    • isSingleViewRendering

      public static boolean isSingleViewRendering(SlingHttpServletRequest req)
      Checks if the specified request triggers a single view rendering.
      Parameters:
      req - The request to be analyzed
      Returns:
      true if a single view rendering is triggered by the request
    • getRenderSizeFromRequest

      public static Integer[] getRenderSizeFromRequest(SlingHttpServletRequest req)
      Determines a predefines size from the specified request, if applicable.
      Parameters:
      req - The request
      Returns:
      A two element array specifiying a predefined width (first element) and height (second element); each of the element may be null, indicating that the respective dimension has to be autocalculated
    • getChartLayoutFromRequest

      public static String getChartLayoutFromRequest(SlingHttpServletRequest req)
      Determines a provided chart layout from the specified request, if applicable.
      Parameters:
      req - The request
      Returns:
      The chart layout ("horizontal", "vertical" or null (if no chart layout was provided)
    • equalsNullAware

      public static boolean equalsNullAware(Object obj1, Object obj2)

      Compares two objects by their respective Object.equals(java.lang.Object) methods. Both objects may be null.

      Parameters:
      obj1 - The first object
      obj2 - The second object
      Returns:
      true if both objects are equal