public class EngineRenderData extends java.lang.Object implements RenderData
RenderData
uses a created Engine
to provide all render data to the i-net Clear Reports viewer.
When the report viewer requires data, either a new Engine
is created if necessary, or an already existing one is used,
and then the data requirement is simply passed on to the Engine
.EngineRenderData
is that it allows you to set your own PropertiesChecker
which is used
before rendering to check and handle whichever properties you'd like to create custom behavior for.
See the documentation of the PropertiesChecker
interface for more information.
getExportChunkCount
and getNextExportChunk
.ReportView
can have its own instance of RenderData
, so the RenderData
methods
may be called simultaneously for different ReportView
s and different RenderData
instances.PropertiesChecker
,
setPropertiesChecker(PropertiesChecker)
CASE_SENSITIVE, REGULAR_EXPRESSION, WHOLE_WORD
Constructor and Description |
---|
EngineRenderData(java.lang.String props)
Creates an instance of
EngineRenderData , decoding any properties in the String . |
Modifier and Type | Method and Description |
---|---|
protected Engine |
checkEngine(java.util.Properties props)
Constructs a new
Engine according to the given properties and cache it. |
void |
clearEngineCache()
Clears the local engine cache of this
EngineRenderData , so that new engines
will be created at the next request for report data. |
protected Engine |
createEngine(java.util.Properties props)
Creates or load an
Engine and set all needed properties. |
RenderData |
getCopy()
"Clones" this RenderData object with all its properties and returns the copy.
|
protected Engine |
getEngine(java.lang.String key)
Get the
Engine from the cache if exists. |
int |
getExportChunkCount(java.util.Properties expProps)
Returns the total number of export "chunks" for the report for the specified export format.
|
byte[] |
getFontData(int fontID)
Returns the byte array of the embedded font at the specified fontId,
which is encoded in the Viewer's protocol.
|
byte[] |
getGroupTree()
Returns the group tree which can be sent to the java viewer as a byte array.
|
protected java.lang.String |
getKey(java.util.Properties props)
Create a key for the given properties.
|
byte[] |
getNextExportChunk()
Returns the current export chunk.
|
int |
getPageCount()
Returns the number of pages in the report.
|
byte[] |
getPageData(int page)
Returns the binary data of one page for the Java Viewer.
|
java.util.Properties |
getProperties()
Returns the Properties object used by this RenderData object.
|
PropertiesChecker |
getPropertiesChecker()
Returns the
PropertiesChecker currently set for this render data. |
java.lang.String |
getReportLocation()
Returns the location of the report set by setReportLocation.
|
java.lang.String |
getReportProperty(java.lang.String key)
Returns the chosen property value which has been set either via setReportProperty or otherwise.
|
java.lang.String |
getReportTitle()
Returns the manually set title of the report if there is one, that is, what would be typically displayed in a title bar, e.g.
|
boolean |
isPageLimitExceeded()
Check if the rendering of the report ran into a page limit.
|
boolean |
isPromptOnRefresh()
Returns the property "promptOnRefresh", that is, whether prompts are to be shown
whenever new data is fetched from the server.
|
byte[] |
refreshPageData(int page)
Enforces the whole report to be re-rendered on server side and returns the refreshed binary data of one page for the Java Viewer.
|
void |
resetServerCacheTimeout()
Since this
RenderData works with fully rendered Engines, there is no timeout to reset,
therefore the implementation of this method does not need to do anything. |
byte[] |
search(java.lang.String phrase,
int startPage,
int flags)
Searches the given phrase in the report, starting at a certain page and using
the search options given in the flags.
|
protected Engine |
setEngineParams(Engine engine,
java.util.Properties props)
Overrides the properties stored in the
Engine with the properties stored in props. |
protected Engine |
setEngineParams(Engine engine,
java.util.Properties props,
boolean rdc)
Overrides the properties stored in the
Engine with the properties stored in props. |
void |
setPromptOnRefresh(boolean promptOnRefresh)
Sets the property "promptOnRefresh", that is, whether prompts are to be shown whenever the report is refreshed, that is,
whenever new data is fetched from the server.
|
void |
setPropertiesChecker(PropertiesChecker propChecker)
Enables you to set your own
PropertiesChecker which will be used before the rendering process to handle certain properties. |
void |
setReportLocation(java.lang.String location)
Sets the location of the report which this RenderData is to obtain its data for.
|
void |
setReportProperty(java.lang.String key,
java.lang.String value)
Sets the given property for the report.
|
void |
setReportTitle(java.lang.String title)
Sets the title of the report.
|
void |
stop()
Stops and cancels the rendering process if one is running.
|
public EngineRenderData(java.lang.String props)
EngineRenderData
, decoding any properties in the String
. An example props string would be:
"report=Test.rpt&promptTest=12&promptBlue=Red&promptonrefresh=true"props
- A String
specifying any properties wanted for the connection, in the form "prop1=value1&prop2=value2&..."public void setReportLocation(java.lang.String location)
setReportLocation
in interface RenderData
location
- The location at which the report can be found. May not be null. *public java.lang.String getReportLocation()
getReportLocation
in interface RenderData
*
public void clearEngineCache()
EngineRenderData
, so that new engines
will be created at the next request for report data.protected Engine createEngine(java.util.Properties props) throws ReportException
Engine
and set all needed properties. Do NOT execute the Engine
here!props
- Properties to use for creating the engine.ReportException
- if the specified export format is invalid.protected java.lang.String getKey(java.util.Properties props) throws ReportException
HashTable
.props
- Properties to use for creating the engine.ReportException
- If an error occurred during checking the supplied properties with the current PropertiesChecker.protected Engine getEngine(java.lang.String key)
Engine
from the cache if exists.key
- the key of the EnginegetKey(java.util.Properties)
protected Engine checkEngine(java.util.Properties props) throws ReportException
Engine
according to the given properties and cache it.Engine
with this properties (see props above) already exists.refreshPageData(int)
.Engine
does not exist, it calls createEngine(exportFormat)
.engine.execute()
.Engine
props
- Properties to use for creating the engine.ReportException
- If:
PropertiesChecker
,Engine
is not initialized or finished.protected Engine setEngineParams(Engine engine, java.util.Properties props)
Engine
with the properties stored in props.engine
- The uninitialized report Engine
props
- The stored properties from the request (report=...&prompt<...>=...)Engine
java.lang.RuntimeException
- If it could not set the engine properties.protected Engine setEngineParams(Engine engine, java.util.Properties props, boolean rdc)
Engine
with the properties stored in props.engine
- The uninitialized report Engine
props
- The stored properties from the request (report=...&prompt<...>=...)rdc
- true if the report should not load because the engine was created with the RDC API.java.lang.RuntimeException
- If it could not set the engine properties.public void setPropertiesChecker(PropertiesChecker propChecker)
PropertiesChecker
which will be used before the rendering process to handle certain properties.
For example, you could implement the following method in the PropertiesChecker
you pass here in order to check and
handle certain custom properties as you wish:
public void checkProperties(Properties reportProperties, Object servletRequest) {
String currentReportName;
currentReportName = ((String)reportProperties.get("report")).toLowerCase();
// check report name
if (currentReportName.indexOf("report1.rpt") != -1) {
// change report parameter values
// for report1 we change password and the RecordSelectionFormula
reportProperties.put("password", "Password");
reportProperties.put("sf", "{List.UserID} = 404");
} else if (currentReportName.indexOf("report2.rpt") != -1) {
// change report parameter values
// for report2 we set a date in a parameter field
reportProperties.put("prompt0", "Date(2000,05,18)");
} else if (currentReportName.indexOf("report3.rpt") != -1) {
// change report parameter values
// for report3 we change the database
// Example: report3 was designed with the ODBC driver
// Now we will use this report with the MS SQL Server
// To do this we set another Data Source Configuration
reportProperties.put("datasource", "SqlServerDataSource");
}
}
propChecker
- PropertiesChecker to set for this EngineRenderData, may not be null.java.lang.IllegalArgumentException
- If propChecker is nullPropertiesChecker
public PropertiesChecker getPropertiesChecker()
PropertiesChecker
currently set for this render data. See setPropertiesChecker(PropertiesChecker)
for more information about
properties checkers.public byte[] getPageData(int page) throws ViewerException
getPageData
in interface RenderData
page
- The number of the page. The first page is 1, the second is 2, ... .
ViewerException
- If an exception is returned from the server, it is wrapped in a ViewerException.
Often this will be a com.inet.report.ReportExceptionRenderData.getPageCount()
public int getPageCount() throws ViewerException
getPageCount
in interface RenderData
ViewerException
- If a problem occurs while rendering the report, the exception is wrapped in a ViewerExceptiongetPageData(int)
public boolean isPageLimitExceeded() throws ViewerException
isPageLimitExceeded
in interface RenderData
ViewerException
- If there are rendering problems, etc.public byte[] getNextExportChunk() throws ViewerException
getNextExportChunk
in interface RenderData
ViewerException
- If an error occurs while rendering the report,
the exception is wrapped in a ViewerExceptionRenderData.getExportChunkCount(Properties)
public int getExportChunkCount(java.util.Properties expProps) throws ViewerException
getExportChunkCount
in interface RenderData
expProps
- Properties to be appended to the current report properties for this export.
The properties should contain at least the export format with the key "export_fmt". The following
formats are valid:ViewerException
- If there are connection problems or other issues while fetching the dataRenderData.getNextExportChunk()
,
RenderData.getProperties()
public byte[] getGroupTree() throws ViewerException
getGroupTree
in interface RenderData
ViewerException
- If there are connection problems or other issues while fetching the datapublic byte[] refreshPageData(int page) throws ViewerException
refreshPageData
in interface RenderData
page
- The number of the page. The first page is 1, the second is 2, ... .
If the page number is bigger than the page count the data from the last page will be returned.ViewerException
- If there are connection problems or other issues while
fetching the dataRenderData.getPageCount()
public void setReportProperty(java.lang.String key, java.lang.String value)
setReportProperty
in interface RenderData
key
- Name of property to set, will be converted to lower casevalue
- Value of property to set, null to remove this propertypublic final java.lang.String getReportProperty(java.lang.String key)
getReportProperty
in interface RenderData
key
- Name of property to get value forpublic void setPromptOnRefresh(boolean promptOnRefresh)
setPromptOnRefresh
in interface RenderData
promptOnRefresh
- Value to set for this propertypublic boolean isPromptOnRefresh()
isPromptOnRefresh
in interface RenderData
public void setReportTitle(java.lang.String title)
setReportTitle
in interface RenderData
title
- Title of the report as simple string.public java.lang.String getReportTitle()
getReportTitle
in interface RenderData
public RenderData getCopy()
getCopy
in interface RenderData
ReportViewer.addNewReportView(RenderData)
,
RenderData.getProperties()
public java.util.Properties getProperties()
Note also that any key values should be set in lower case. This Properties object will never be null, at most it will be empty.
getProperties
in interface RenderData
public void stop()
stop
in interface RenderData
public byte[] search(java.lang.String phrase, int startPage, int flags)
WHOLE_WORD : search only the word in its entirety, not parts of words.
CASE_SENSITIVE : observe upper and lower cases in the search, that is "Search" != "search"
REGULAR_EXPRESSION : The search phrase is to be handled as a regular expression (using Java's Regex
methods for the search).
Desired flags should be connected by the OR operator "|". So, for example, to search with the flags WHOLE_WORD and CASE_SENSITIVE, simply use WHOLE_WORD | CASE_SENSITIVE as the flags option.
Note that phrases going over more than one page will not be found, nor will text parts with formatting inside the word itself, such as this word. Note that this method is thread-safe, that is, two or more threads concurrently calling this method and the other thread-safe methods in RenderData should cause no problems.
search
in interface RenderData
phrase
- Word or phrase to search. Should be a regular expression if this flag is set.startPage
- Page to start searching on (1-based)flags
- Desired search options (see above)RenderData.WHOLE_WORD
,
RenderData.CASE_SENSITIVE
,
RenderData.REGULAR_EXPRESSION
public byte[] getFontData(int fontID)
The fontID is 1-based. null
will be returned if there are no fonts embedded for the
report of this Engine. If fontID is greater than the number of embedded
fonts available it will return the last font available. This method is the mirror method to com.inet.report.Engine.getFontData(int),
so implementations can either call that if an engine is available, or a running i-net Clear Reports server
also returns the font data with an HTTP request of the form
"http://server:9000/?report=report.rpt&export_fmt=font&page=FONTID&cmd=get_pg" where FONTID is replaced with the given font ID.
Note that this method is thread-safe, that is, two or more threads concurrently calling
this method and the other thread-safe methods in RenderData should cause no problems.
getFontData
in interface RenderData
fontID
- ID of font as specified in the i-net Clear Reports protocolpublic void resetServerCacheTimeout()
RenderData
works with fully rendered Engines, there is no timeout to reset,
therefore the implementation of this method does not need to do anything.resetServerCacheTimeout
in interface RenderData
ViewerException
- always so the viewer only tries onceRenderData.resetServerCacheTimeout()
Copyright © 1999-2020 by i-net software GmbH