Package com.day.cq.reporting.helpers
Class Util
- java.lang.Object
-
- com.day.cq.reporting.helpers.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 specifiedString
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 specifiedCalendar
,static boolean
equalsNullAware(java.lang.Object obj1, java.lang.Object obj2)
Compares two objects by their respectiveObject.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 specifiedCalendar
to 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 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
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 specifiedString
array contains the specified string.- Parameters:
array
- The arraystr
- The string- Returns:
true
if 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_TABULAR
orConst.RENDER_TYPE_CHART
;null
for 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;
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 benull
.- Parameters:
obj1
- The first objectobj2
- The second object- Returns:
true
if both objects are equal
-
-