Class Util


  • public class Util
    extends java.lang.Object
    Class that provides some helper functionality.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean arrayContainsString​(java.lang.String[] array, java.lang.String str)
      Determines if the specified String array contains the specified string.
      static void clearTime​(java.util.Calendar calendar)
      Clears the time information by setting it back to midnight.
      static long createTimeStamp​(java.util.Calendar cal)
      Creates a timestamp (format: yyyymmddhhmmss) from the specified Calendar,
      static boolean equalsNullAware​(java.lang.Object obj1, java.lang.Object obj2)
      Compares two objects by their respective Object.equals(java.lang.Object) methods.
      static java.lang.String getChartIdFromRequest​(SlingHttpServletRequest req)
      Gets a chart id for rendering from the specified request, if applicable.
      static java.lang.String getChartLayoutFromRequest​(SlingHttpServletRequest req)
      Determines a provided chart layout from the specified request, if applicable.
      static java.lang.Integer[] getRenderSizeFromRequest​(SlingHttpServletRequest req)
      Determines a predefines size from the specified request, if applicable.
      static java.lang.String getRenderTypeFromRequest​(SlingHttpServletRequest req)
      Gets the render type from the reuest.
      static boolean isSingleViewRendering​(SlingHttpServletRequest req)
      Checks if the specified request triggers a single view rendering.
      static void writeToJSON​(JSONWriter writer, com.day.cq.reporting.impl.snapshots.AggregationInterval interval, java.util.Calendar cal, java.util.TimeZone timeZone, java.util.Locale locale)
      Writes the specified Calendar to the specified JSONWriter.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createTimeStamp

        public static long createTimeStamp​(java.util.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,
                                       java.util.Calendar cal,
                                       java.util.TimeZone timeZone,
                                       java.util.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​(java.util.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​(java.lang.String[] array,
                                                  java.lang.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
      • getChartIdFromRequest

        public static java.lang.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 java.lang.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 java.lang.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​(java.lang.Object obj1,
                                              java.lang.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