ro.nextreports.engine.util
Class ReportUtil

Package class diagram package ReportUtil
java.lang.Object
  extended by ro.nextreports.engine.util.ReportUtil

public class ReportUtil
extends java.lang.Object

Utilities class for report


Field Summary
static byte REPORT_INVALID_NEWER
          Report has a version newer than current engine
static byte REPORT_INVALID_OLDER
          Report has an older invalid version than current engine (less than 2.0)
static byte REPORT_VALID
          Report has the version of current engine
 
Constructor Summary
ReportUtil()
           
 
Method Summary
static int compareVersions(java.lang.String v1, java.lang.String v2)
          Compare two report versions strings
static boolean foundFunctionInAnyGroupHeader(ReportLayout layout)
          Test to see if a function is found in any group header band
static boolean foundFunctionInGroupHeader(ReportLayout layout, java.lang.String groupName)
          Test to see if a function is found in group header band
static boolean foundFunctionInHeader(ReportLayout layout)
          Test to see if a function is found in header band
static ReportLayout getDynamicReportLayout(java.sql.Connection con, ReportLayout layout, ro.nextreports.engine.exporter.util.ParametersBean pBean)
          Get dynamic report layout Report layout is dynamically modified in some situations like: 1.
static java.util.List<ro.nextreports.engine.band.ExpressionBean> getExpressions(ReportLayout layout)
          Get expression elements from report layout
static java.util.List<ro.nextreports.engine.band.ExpressionBean> getExpressions(ReportLayout layout, java.lang.String bandName)
          Get expression elements for a band from report layout
static java.util.List<java.lang.String> getExpressionsNames(ReportLayout layout)
          Get expression names from report layout
static java.lang.String getFileName(java.lang.String filePath)
          Get file name from a file path
static java.lang.String getSql(Report report)
          Get sql string from report object
static java.lang.String getSql(Report report, java.util.Map<java.lang.String,java.lang.Object> parameterValues)
          Get sql string from report object with parameters values
static java.util.List<java.lang.String> getStaticImages(Report report)
          Get static images used by report
static java.lang.String getVersion(byte[] reportContent)
          Get report version from file byte content
static java.lang.String getVersion(java.io.InputStream is)
          Get report version from input stream to read report file
static java.lang.String getVersion(java.lang.String reportFile)
          Get report version from report file
static java.lang.String getVersionFromText(java.lang.String reportText)
          Get report version from xml text
static boolean isDetailBand(java.lang.String bandName)
           
static boolean isGroupBand(java.lang.String bandName)
           
static boolean isNewerUnsupportedVersion(java.lang.String version)
          Return true if version string is newer than version of the report engine
static boolean isOlderUnsupportedVersion(java.lang.String version)
          Return true if version string is less than 2.0
static boolean isPageHeaderBand(java.lang.String bandName)
           
static byte isValid(java.lang.String reportVersion)
          Test if string version given as parameter is valid, meaning is over 2.0 and no greater than current engine version
static byte isValidReportVersion(byte[] reportContent)
          Test if report content given as parameter has a valid version, meaning is over 2.0 and no greater than current engine version
static byte isValidReportVersion(Report report)
          Test if report given as parameter has a valid version, meaning is over 2.0 and no greater than current engine version
static byte isValidReportVersion(java.lang.String reportFile)
          Test if report file given as parameter has a valid version, meaning is over 2.0 and no greater than current engine version
static boolean isValidSql(java.sql.Connection con, Report report)
          Test if sql from a report object is valid
static Report loadConvertedReport(java.io.InputStream is)
          Create a report object from an input stream Use this method if you know your report version does not need any conversion from older versions, otherwise see loadReport(InputStream)
static Report loadConvertedReport(java.lang.String xml)
          Create a report object from xml Use this method if you know your report version does not need any conversion from older versions, otherwise see loadReport(String)
static Report loadReport(java.io.InputStream is)
          Create a report object from an input stream Do a conversion if it is needed
static Report loadReport(java.lang.String xml)
          Create a report object from xml Do a conversion if it is needed
static java.lang.String readAsString(java.io.InputStream is)
          Read data from input stream
static java.lang.String readAsString(java.lang.String reportPath)
          Read a report file as string
static java.lang.String reportToXml(Report report)
          Convert a report object to xml text
static void saveReport(Report report, java.io.OutputStream out)
          Write a report object to an output stream
static void saveReport(Report report, java.lang.String path)
          Write a report object to a file at specified path
static void saveReport(java.lang.String xml, java.lang.String path)
          Write a xml text to a file at specified path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPORT_VALID

public static byte REPORT_VALID
Report has the version of current engine


REPORT_INVALID_OLDER

public static byte REPORT_INVALID_OLDER
Report has an older invalid version than current engine (less than 2.0)


REPORT_INVALID_NEWER

public static byte REPORT_INVALID_NEWER
Report has a version newer than current engine

Constructor Detail

ReportUtil

public ReportUtil()
Method Detail

loadConvertedReport

public static Report loadConvertedReport(java.io.InputStream is)
Create a report object from an input stream Use this method if you know your report version does not need any conversion from older versions, otherwise see loadReport(InputStream)

Parameters:
is - input stream
Returns:
the report object created from the input stream or null if cannot be read

loadConvertedReport

public static Report loadConvertedReport(java.lang.String xml)
Create a report object from xml Use this method if you know your report version does not need any conversion from older versions, otherwise see loadReport(String)

Parameters:
xml - xml text
Returns:
the report object created from xml or null if cannot be read

loadReport

public static Report loadReport(java.lang.String xml)
                         throws ro.nextreports.engine.util.LoadReportException
Create a report object from xml Do a conversion if it is needed

Parameters:
xml - xml text
Returns:
the report object created from xml or null if cannot be read
Throws:
ro.nextreports.engine.util.LoadReportException - if report object cannot be created
Since:
5.2

loadReport

public static Report loadReport(java.io.InputStream is)
                         throws ro.nextreports.engine.util.LoadReportException
Create a report object from an input stream Do a conversion if it is needed

Parameters:
is - input stream
Returns:
the report object created from the input stream or null if cannot be read
Throws:
ro.nextreports.engine.util.LoadReportException - if report object cannot be created
Since:
5.2

saveReport

public static void saveReport(Report report,
                              java.io.OutputStream out)
Write a report object to an output stream

Parameters:
report - report object
out - output stream

saveReport

public static void saveReport(Report report,
                              java.lang.String path)
Write a report object to a file at specified path

Parameters:
report - report object
path - file path

saveReport

public static void saveReport(java.lang.String xml,
                              java.lang.String path)
Write a xml text to a file at specified path

Parameters:
xml - xml text
path - file path

reportToXml

public static java.lang.String reportToXml(Report report)
Convert a report object to xml text

Parameters:
report - report object
Returns:
xml text

isValidReportVersion

public static byte isValidReportVersion(byte[] reportContent)
Test if report content given as parameter has a valid version, meaning is over 2.0 and no greater than current engine version

Parameters:
reportContent - report byte content
Returns:
one of REPORT_VALID, REPORT_INVALID_OLDER, REPORT_INVALID_NEWER

isValidReportVersion

public static byte isValidReportVersion(Report report)
Test if report given as parameter has a valid version, meaning is over 2.0 and no greater than current engine version

Parameters:
report - report object
Returns:
one of REPORT_VALID, REPORT_INVALID_OLDER, REPORT_INVALID_NEWER

isValidReportVersion

public static byte isValidReportVersion(java.lang.String reportFile)
Test if report file given as parameter has a valid version, meaning is over 2.0 and no greater than current engine version

Parameters:
reportFile - report file
Returns:
one of REPORT_VALID, REPORT_INVALID_OLDER, REPORT_INVALID_NEWER

isValid

public static byte isValid(java.lang.String reportVersion)
Test if string version given as parameter is valid, meaning is over 2.0 and no greater than current engine version

Parameters:
reportVersion - version
Returns:
one of REPORT_VALID, REPORT_INVALID_OLDER, REPORT_INVALID_NEWER

isOlderUnsupportedVersion

public static boolean isOlderUnsupportedVersion(java.lang.String version)
Return true if version string is less than 2.0

Parameters:
version - version string
Returns:
true if version string is less than 2.0

isNewerUnsupportedVersion

public static boolean isNewerUnsupportedVersion(java.lang.String version)
Return true if version string is newer than version of the report engine

Parameters:
version - version string
Returns:
true if version string is newer than version of the report engine

compareVersions

public static int compareVersions(java.lang.String v1,
                                  java.lang.String v2)
Compare two report versions strings

Parameters:
v1 - first version string
v2 - second version string
Returns:
-1 if v1 less than v2, 0 if v1 equals v2, 1 if v1 greater than v2

getVersion

public static java.lang.String getVersion(java.lang.String reportFile)
Get report version from report file

Parameters:
reportFile - report file
Returns:
report version

getVersion

public static java.lang.String getVersion(java.io.InputStream is)
Get report version from input stream to read report file

Parameters:
is - input stream
Returns:
report version

getVersion

public static java.lang.String getVersion(byte[] reportContent)
Get report version from file byte content

Parameters:
reportContent - file byte content
Returns:
report version

getVersionFromText

public static java.lang.String getVersionFromText(java.lang.String reportText)
Get report version from xml text

Parameters:
reportText - xml text
Returns:
report version

readAsString

public static java.lang.String readAsString(java.lang.String reportPath)
                                     throws java.io.IOException
Read a report file as string

Parameters:
reportPath - file path
Returns:
string file content
Throws:
java.io.IOException - if file cannot be read

readAsString

public static java.lang.String readAsString(java.io.InputStream is)
                                     throws java.io.IOException
Read data from input stream

Parameters:
is - input stream
Returns:
string content read from input stream
Throws:
java.io.IOException - if cannot read from input stream

getFileName

public static java.lang.String getFileName(java.lang.String filePath)
Get file name from a file path

Parameters:
filePath - file path
Returns:
file name

getStaticImages

public static java.util.List<java.lang.String> getStaticImages(Report report)
Get static images used by report

Parameters:
report - report
Returns:
a list of static images used by report

getSql

public static java.lang.String getSql(Report report)
Get sql string from report object

Parameters:
report - report
Returns:
sql string from report object

getSql

public static java.lang.String getSql(Report report,
                                      java.util.Map<java.lang.String,java.lang.Object> parameterValues)
Get sql string from report object with parameters values

Parameters:
report - report
parameterValues - parameter values map
Returns:
sql string from report object with parameters values

getExpressions

public static java.util.List<ro.nextreports.engine.band.ExpressionBean> getExpressions(ReportLayout layout)
Get expression elements from report layout

Parameters:
layout - report layout
Returns:
list of expression elements from report layout

getExpressions

public static java.util.List<ro.nextreports.engine.band.ExpressionBean> getExpressions(ReportLayout layout,
                                                                                       java.lang.String bandName)
Get expression elements for a band from report layout

Parameters:
layout - report layout
bandName - band name
Returns:
list of expression elements for band from report layout

getExpressionsNames

public static java.util.List<java.lang.String> getExpressionsNames(ReportLayout layout)
Get expression names from report layout

Parameters:
layout - report layout
Returns:
list of expression names from report layout

isValidSql

public static boolean isValidSql(java.sql.Connection con,
                                 Report report)
Test if sql from a report object is valid

Parameters:
con - database connection
report - report object
Returns:
true if sql is valid, false if it is not valid

isGroupBand

public static boolean isGroupBand(java.lang.String bandName)

isDetailBand

public static boolean isDetailBand(java.lang.String bandName)

isPageHeaderBand

public static boolean isPageHeaderBand(java.lang.String bandName)

getDynamicReportLayout

public static ReportLayout getDynamicReportLayout(java.sql.Connection con,
                                                  ReportLayout layout,
                                                  ro.nextreports.engine.exporter.util.ParametersBean pBean)
                                           throws java.lang.Exception
Get dynamic report layout Report layout is dynamically modified in some situations like: 1. FOR Report Band Element 2. Functions in Header or Group Header

Parameters:
con - database connection
layout - report layout
pBean - parameters bean
Returns:
dynamic report layout
Throws:
java.lang.Exception

foundFunctionInHeader

public static boolean foundFunctionInHeader(ReportLayout layout)
Test to see if a function is found in header band

Parameters:
layout - report layout
Returns:
true if a function is found in header band, false otherwise

foundFunctionInGroupHeader

public static boolean foundFunctionInGroupHeader(ReportLayout layout,
                                                 java.lang.String groupName)
Test to see if a function is found in group header band

Parameters:
layout - report layout
groupName - group name
Returns:
true if a function is found in group header band, false otherwise

foundFunctionInAnyGroupHeader

public static boolean foundFunctionInAnyGroupHeader(ReportLayout layout)
Test to see if a function is found in any group header band

Parameters:
layout - report layout
Returns:
true if a function is found in any group header band, false otherwise