Package com.day.cq.reporting.helpers
Class Util
- java.lang.Object
-
- com.day.cq.reporting.helpers.Util
-
public class Util extends java.lang.ObjectClass that provides some helper functionality.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanarrayContainsString(java.lang.String[] array, java.lang.String str)Determines if the specifiedStringarray contains the specified string.static voidclearTime(java.util.Calendar calendar)Clears the time information by setting it back to midnight.static longcreateTimeStamp(java.util.Calendar cal)Creates a timestamp (format: yyyymmddhhmmss) from the specifiedCalendar,static booleanequalsNullAware(java.lang.Object obj1, java.lang.Object obj2)Compares two objects by their respectiveObject.equals(java.lang.Object)methods.static java.lang.StringgetChartIdFromRequest(SlingHttpServletRequest req)Gets a chart id for rendering from the specified request, if applicable.static java.lang.StringgetChartLayoutFromRequest(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.StringgetRenderTypeFromRequest(SlingHttpServletRequest req)Gets the render type from the reuest.static booleanisSingleViewRendering(SlingHttpServletRequest req)Checks if the specified request triggers a single view rendering.static voidwriteToJSON(JSONWriter writer, com.day.cq.reporting.impl.snapshots.AggregationInterval interval, java.util.Calendar cal, java.util.TimeZone timeZone, java.util.Locale locale)Writes the specifiedCalendarto the specifiedJSONWriter.
-
-
-
Method Detail
-
createTimeStamp
public static long createTimeStamp(java.util.Calendar cal)
Creates a timestamp (format: yyyymmddhhmmss) from the specifiedCalendar,- 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 specifiedCalendarto the specifiedJSONWriter.- Parameters:
writer- The writerinterval- The aggregation interval to create display values forcal- The calendartimeZone- The time zonelocale- 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 specifiedStringarray contains the specified string.- Parameters:
array- The arraystr- The string- Returns:
trueif the array contains the given string
-
getRenderTypeFromRequest
public static java.lang.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_TABULARorConst.RENDER_TYPE_CHART;nullfor rendering the chart in default mode
-
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;
nullif 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:
trueif 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 benull.- Parameters:
obj1- The first objectobj2- The second object- Returns:
trueif both objects are equal
-
-