Package com.day.cq.reporting.helpers
Class Util
java.lang.Object
com.day.cq.reporting.helpers.Util
Class that provides some helper functionality.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
arrayContainsString
(String[] array, String str) Determines if the specifiedString
array contains the specified string.static void
Clears the time information by setting it back to midnight.static long
createTimeStamp
(Calendar cal) Creates a timestamp (format: yyyymmddhhmmss) from the specifiedCalendar
,static boolean
equalsNullAware
(Object obj1, Object obj2) Compares two objects by their respectiveObject.equals(java.lang.Object)
methods.static String
Gets a chart id for rendering from the specified request, if applicable.static String
Determines a provided chart layout from the specified request, if applicable.static Integer[]
Determines a predefines size from the specified request, if applicable.static String
Gets the render type from the reuest.static boolean
Checks if the specified request triggers a single view rendering.static void
writeToJSON
(JSONWriter writer, com.day.cq.reporting.impl.snapshots.AggregationInterval interval, Calendar cal, TimeZone timeZone, Locale locale) Writes the specifiedCalendar
to the specifiedJSONWriter
.
-
Method Details
-
createTimeStamp
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, Calendar cal, TimeZone timeZone, Locale locale) throws JSONException Writes the specifiedCalendar
to 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
Clears the time information by setting it back to midnight.- Parameters:
calendar
- The calendar to clear time information from
-
arrayContainsString
Determines if the specifiedString
array contains the specified string.- Parameters:
array
- The arraystr
- The string- Returns:
true
if the array contains the given string
-
getRenderTypeFromRequest
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
orConst.RENDER_TYPE_CHART
;null
for rendering the chart in default mode
-
getChartIdFromRequest
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
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
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
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
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:
true
if both objects are equal
-