org.apertereports.util
Class DashboardUtil

java.lang.Object
  extended by org.apertereports.util.DashboardUtil

public final class DashboardUtil
extends Object

Utility class with methods for report tags retrieval, regexp matching etc.


Nested Class Summary
static class DashboardUtil.MatchHandler
          Handles single group match.
static class DashboardUtil.MatchHandlerWithList
          Handles multiple groups match.
 
Field Summary
static String CHART_SOURCE_PREFIX_REGEXP
          Regexp that identifies the anchor of the report drilldown in dashboard HTML.
static String CHART_SOURCE_PREFIX_TEXT
          Used as a JRExporter parameter to identify drilldown reports.
static Pattern CHART_TAG_PATTERN
          Regexp that identifies a complex drilldown anchor.
static Pattern DRILLDOWN_TAG_PATTERN
           
static Pattern REPORT_TAG_PATTERN
          Regexp that identifies the anchor of the report in dashboard HTML.
 
Method Summary
static void executeTemplateMatcher(String template, Pattern pattern, DashboardUtil.MatchHandler handler)
          Searches a given template for a regexp pattern.
static void executeTemplateMatcherWithList(String template, Pattern pattern, DashboardUtil.MatchHandlerWithList handler)
          Searches a given template for a regexp pattern.
static byte[] exportReportOrderData(ReportOrder reportOrder, ReportConstants.ReportType format)
          Extracts the report data from given ReportOrder instance.
static Integer generateDrilldownId(Set<Integer> actualIds)
          Generates a temporary drilldown component id based on actual ids.
static Set<Integer> getReportConfigIds(String template)
          Parses the input HTML and extracts the report tag.
static Pair<String,Map<String,String>> parseHtmlTag(String tag, boolean spanStyle)
          This method parses a HTML tag.
static Map<String,List<String>> parseHyperlinkParameters(String hyperlink)
          This method parses a href HTML tag's parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHART_SOURCE_PREFIX_REGEXP

public static final String CHART_SOURCE_PREFIX_REGEXP
Regexp that identifies the anchor of the report drilldown in dashboard HTML.

See Also:
Constant Field Values

CHART_SOURCE_PREFIX_TEXT

public static final String CHART_SOURCE_PREFIX_TEXT
Used as a JRExporter parameter to identify drilldown reports.

See Also:
Constant Field Values

REPORT_TAG_PATTERN

public static final Pattern REPORT_TAG_PATTERN
Regexp that identifies the anchor of the report in dashboard HTML.


CHART_TAG_PATTERN

public static Pattern CHART_TAG_PATTERN
Regexp that identifies a complex drilldown anchor.


DRILLDOWN_TAG_PATTERN

public static final Pattern DRILLDOWN_TAG_PATTERN
Method Detail

generateDrilldownId

public static Integer generateDrilldownId(Set<Integer> actualIds)
Generates a temporary drilldown component id based on actual ids.

Parameters:
actualIds - Used ids
Returns:
A generated id

parseHtmlTag

public static Pair<String,Map<String,String>> parseHtmlTag(String tag,
                                                           boolean spanStyle)
                                                    throws Exception
This method parses a HTML tag. Each (i.e. href) tag that has been identified is later transformed to a report generation link or drilldown. The parameters it contains are passed to an Embedded instance holding the report.

Parameters:
tag - A HTML tag
spanStyle - TRUE to include span styles
Returns:
A pair of tag text and the parameters
Throws:
Exception - On XML exception

parseHyperlinkParameters

public static Map<String,List<String>> parseHyperlinkParameters(String hyperlink)
                                                         throws UnsupportedEncodingException
This method parses a href HTML tag's parameters. These are used as a report generation request parameters when a drilldown link was clicked.

Parameters:
hyperlink - Input hyperlink
Returns:
Map of request parameters
Throws:
UnsupportedEncodingException - On encoding error

getReportConfigIds

public static Set<Integer> getReportConfigIds(String template)
Parses the input HTML and extracts the report tag. These are used as report config ids.

Parameters:
template - Input HTML
Returns:
A set of identified report configs

executeTemplateMatcher

public static void executeTemplateMatcher(String template,
                                          Pattern pattern,
                                          DashboardUtil.MatchHandler handler)
Searches a given template for a regexp pattern. If a match was found the result is passed to a DashboardUtil.MatchHandler instance. Extracts only 1 group.

Parameters:
template - Input template
pattern - Search pattern
handler - Match handler

executeTemplateMatcherWithList

public static void executeTemplateMatcherWithList(String template,
                                                  Pattern pattern,
                                                  DashboardUtil.MatchHandlerWithList handler)
Searches a given template for a regexp pattern. If a match was found the resulting groups are added to a list. The list is passed to given DashboardUtil.MatchHandlerWithList instance.

Parameters:
template - Input template
pattern - Search pattern
handler - Match handler

exportReportOrderData

public static byte[] exportReportOrderData(ReportOrder reportOrder,
                                           ReportConstants.ReportType format)
                                    throws AperteReportsException
Extracts the report data from given ReportOrder instance.

Parameters:
reportOrder - Input report order
format - Output format
Returns:
Bytes of a generated report
Throws:
org.apertereports.common.exception.ReportException - On JRExporter error
net.sf.jasperreports.engine.JRException - On JasperPrint load error
AperteReportsException


Copyright © 2011-2012. All Rights Reserved.