Class URLRenderData
- All Implemented Interfaces:
RenderData
Here are a couple of very simple examples of what could be done by creating certain URLRenderData objects and manipulating them.
Create a URLRenderData, set two prompt values, and export the report to PDF
URLRenderData data = new URLRenderData("http://server:9000/?report=C:/report.rpt");
File file = new File("C:/test.pdf");
FileOutputStream fos = new FileOutputStream(file);
Properties props = data.getProperties();
props.setProperty( "export_fmt", "pdf" );
props.setProperty( "file", "c:/test.pdf" );
int count = data.getExportChunkCount( props );
for(int i=1;count == 0 || i<=count;i++){ // count can be 0 if there is gzip compression
byte[] pageData = data.getNextExportChunk();
if( pageData != null ) {
fos.write( pageData );
} else {
break;
}
}
fos.close();
Create a URLRenderData and pass it to the constructor of a ReportView as a data source
URLRenderData data = new URLRenderData("http://server:9000/?report=C:/abc.rpt");
SwingReportViewer viewer = new SwingReportViewer();
viewer.addNewReportView(data);
...
Notes for overriding
- The methods of this class must be thread safe except for the methods
getExportChunkCount
andgetNextExportChunk
. - Each ReportView can have its own instance of RenderData, so the different RenderData methods may be called simultaneously for different ReportViews and different RenderData instances.
- Since:
- 7.0
-
Field Summary
Fields inherited from interface com.inet.viewer.RenderData
CASE_SENSITIVE, REGULAR_EXPRESSION, WHOLE_WORD
-
Constructor Summary
ConstructorDescriptionURLRenderData
(String requestURL) Creates a URLRenderData object with the given URL as the location to connect to to fetch the report.URLRenderData
(URL url) Creates a URLRenderData object with the given URL as the location to connect to to fetch the report. -
Method Summary
Modifier and TypeMethodDescriptionReturns the cookie set for the next connections made by URLRenderData.getCopy()
"Clones" this RenderData object with all its properties and returns the copy.int
getExportChunkCount
(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[]
Returns the group tree which can be sent to the java viewer as a byte array.byte[]
Returns the next chunk of the exported report if there is at least one more chunk available.int
Returns the number of pages in the report.byte[]
getPageData
(int page) Any page number greater than 0 is viewed as valid - if the page number is higher than the number of pages in the report, this will return the data from the last page.final Properties
Returns the Properties object used by this RenderData object.Returns the URL this report is to be found at, without any attached properties.final String
getReportProperty
(String key) Returns the chosen property value which has been set either via setReportProperty or otherwise.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
Returns whether or not GET requests are set as forced.boolean
Check if the rendering of the report ran into a page limit.boolean
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
Notifies the server that the report with the currently set properties is still being viewed and therefore should not be removed from the cache yet if there is one.byte[]
Searches the given phrase in the report, starting at a certain page and using the search options given in the flags.void
Sets the cookie for the next connections made by URLRenderData.void
setForceUseGET
(boolean force) If you set this to true, the URL request will never send parameters as POST parameters but only as a GET request.void
setHostnameVerifier
(HostnameVerifier hostnameVerifier) Sets aHostnameVerifier
that is used if the report has an HTTPS url.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
setReportLocation
(String url) Sets the URL to connect to to fetch the report, e.g. http://localhost:9000/?final void
setReportProperty
(String key, String value) Sets the given property for the report.void
setReportTitle
(String title) Sets the title of the report.void
setSslSocketFactory
(SSLSocketFactory sslSocketFactory) Sets aSSLSocketFactory
that is used if the report has an HTTPS url.void
stop()
Sends the command "stop" to the server.
-
Constructor Details
-
URLRenderData
Creates a URLRenderData object with the given URL as the location to connect to to fetch the report. Note that any properties should be URL-encoded with the UTF-8 code page. Properties within this URL (such as "http://server:9000/?report=report1.rpt&prompt0=12&init=pdf") are extracted and placed into this RenderData object's properties, which can be retrieved using getProperties.- Parameters:
requestURL
- URL to connect to to fetch the report (Properties should be URL-encoded with the UTF-8 code page) If this is null, before connecting to fetch a report, setReportLocation must be called!- Since:
- 7.0
- See Also:
-
URLRenderData
Creates a URLRenderData object with the given URL as the location to connect to to fetch the report. Note that any properties should be encoded within the URL in the UTF-8 code page. Properties within this URL (such as "http://server:9000/?report=report1.rpt&prompt0=12&init=pdf") are extracted and placed into this RenderData object's properties, which can be retrieved using getProperties.- Parameters:
url
- URL to connect to to fetch the report (Properties should be URL-encoded in the UTF-8 code page.) If this is null, before connecting to fetch a report, setReportLocation must be called!- Since:
- 7.0
- See Also:
-
-
Method Details
-
setReportLocation
Sets the URL to connect to to fetch the report, e.g. http://localhost:9000/?report=C:/report1.rpt Note that any properties should be URL-encoded in the UTF-8 code page. Properties within this URL (such as "http://server:9000/?report=report1.rpt&prompt0=12&init=pdf") are extracted and placed into this RenderData object's properties, which can be retrieved using getProperties. The location may not be null.- Specified by:
setReportLocation
in interfaceRenderData
- Parameters:
url
- URL to connect to to fetch the report (Properties should be URL-encoded in the UTF-8 code page). May not be null.- Since:
- 7.0
- See Also:
-
getReportLocation
Returns the URL this report is to be found at, without any attached properties. That is, this need not return the same URL as was given in setReportLocation, however it should return a URL at which the same report is found. This will never be null. An uninitialized location will be returned as an empty string.- Specified by:
getReportLocation
in interfaceRenderData
- Returns:
- The URL the report is to be found at. No properties are attached.
- Since:
- 7.0
- See Also:
-
getPageData
Any page number greater than 0 is viewed as valid - if the page number is higher than the number of pages in the report, this will return the data from the last page. This is for performance reasons, so that the page count does not need to be requested.- Specified by:
getPageData
in interfaceRenderData
- Parameters:
page
- Number of page to fetch data for, 1-based.- Returns:
- Serialized page data for the chosen page.
- Throws:
ViewerException
- If the given page index is less than 1- Since:
- 7.0
- See Also:
-
refreshPageData
Enforces the whole report to be re-rendered on server side and returns the refreshed binary data of one page for the Java Viewer. This page is rendered anew rather than possibly taking a cached version.- Specified by:
refreshPageData
in interfaceRenderData
- Parameters:
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.- Returns:
- the binary data for the Java Viewer
- Throws:
ViewerException
- If there are connection problems or other issues while fetching the data- Since:
- 7.0
- See Also:
-
getPageCount
Returns the number of pages in the report.
This method blocks until the rendering process is finished. This is useful if you use i-net Clear Reports with external result sets or connections and you want to know when the rendering process is finished and you can close these external result sets or connections - once this method returns, the rendering process is finished. 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.- Specified by:
getPageCount
in interfaceRenderData
- Returns:
- number of pages (1-based)
- Throws:
ViewerException
- If there are rendering problems, etc.- Since:
- 7.0
- See Also:
-
isPageLimitExceeded
Check if the rendering of the report ran into a page limit. This means does not all possible pages exist.- Specified by:
isPageLimitExceeded
in interfaceRenderData
- Returns:
- true, if there is a limit
- Throws:
ViewerException
- If there are rendering problems, etc.- Since:
- 10.0
-
getNextExportChunk
Returns the next chunk of the exported report if there is at least one more chunk available. It is required that getExportChunkCount(Properties) has been called once for this report.
This method blocks until the rendering process of the requested chunk or the complete report is finished.- Specified by:
getNextExportChunk
in interfaceRenderData
- Returns:
- Next chunk of the report, or null if the export is finished.
- Throws:
ViewerException
- If there are connection problems or other issues while fetching the data- Since:
- 7.0
- See Also:
-
getExportChunkCount
Returns the total number of export "chunks" for the report for the specified export format.
A "chunk" is a unit of export data which can be retrieved using getNextExportChunk(). This method blocks until the rendering process is finished on the server. 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.
In case of gzip compression, the number of chunks can not be determined and "0" is returned. The chunks can be retrieved in a loop until getNextExportChunk() returns NULL.- Specified by:
getExportChunkCount
in interfaceRenderData
- Parameters:
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:
"pdf" - pdf file
"rtf" - rtf file
"xls" - xls file
"csv" - csv file
"ps" - ps file
"xml" -xml file
"htm" - html files, The file name is the base filename, because there are more files with links.
For a complete list of report URL properties see the documentation.- Returns:
- Total number of export "chunks" (i.e. units) which can be fetched using getNextExportChunk()
- Throws:
ViewerException
- If there are connection problems or other issues while fetching the data- Since:
- 7.0
- See Also:
-
getGroupTree
Returns the group tree which can be sent to the java viewer as a byte array. 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.- Specified by:
getGroupTree
in interfaceRenderData
- Returns:
- byte[] Group Tree as byte array, encoded by i-net Clear Reports.
- Throws:
ViewerException
- If there are connection problems or other issues while fetching the data- Since:
- 7.0
-
setReportTitle
Sets the title of the report. This title is what would be typically displayed in a title bar, e.g. "Employee Report 2005". Note that if this is not manually set, the title will be whatever the report has set as its title. If a title is set, it overrides the "actual" report title.- Specified by:
setReportTitle
in interfaceRenderData
- Parameters:
title
- Title of the report as simple string.- Since:
- 7.0
-
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. "Employee Report 2005". This will return null if no title was manually set.- Specified by:
getReportTitle
in interfaceRenderData
- Returns:
- Title of report
- Since:
- 7.0
-
setReportProperty
Sets the given property for the report. See https://www.inetsoftware.de/documentation/clear-reports/plugins/clear-reports/documentation/en/report-url-parameters for a list of possible properties to set here and what they mean.
Setting null as the value will cause the removal of the property. If a prompt property is to be explicitly set to the value "null", simply set the string "formula:null" as the value.- Specified by:
setReportProperty
in interfaceRenderData
- Parameters:
key
- Name of property to set, will be converted to lower casevalue
- Value of property to set, null to remove this property- Since:
- 7.0
-
getProperties
Returns the Properties object used by this RenderData object. Note this is NOT a clone but rather the exact object used by RenderData - any changes made to this Properties object will influence the RenderData. See https://www.inetsoftware.de/documentation/clear-reports/plugins/clear-reports/documentation/en/report-url-parameters for a list of possible properties to set here and what they mean.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.
- Specified by:
getProperties
in interfaceRenderData
- Returns:
- Properties object used by RenderData, never null
- Since:
- 7.0
-
getReportProperty
Returns the chosen property value which has been set either via setReportProperty or otherwise.- Specified by:
getReportProperty
in interfaceRenderData
- Parameters:
key
- Name of property to get value for- Returns:
- Value of property with the given name
- Since:
- 7.0
-
setPromptOnRefresh
public 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.- Specified by:
setPromptOnRefresh
in interfaceRenderData
- Parameters:
promptOnRefresh
- Value to set for this property- Since:
- 7.0
-
isPromptOnRefresh
public boolean isPromptOnRefresh()Returns the property "promptOnRefresh", that is, whether prompts are to be shown whenever new data is fetched from the server.- Specified by:
isPromptOnRefresh
in interfaceRenderData
- Returns:
- The property "promptOnRefresh"
- Since:
- 7.0
-
getCopy
"Clones" this RenderData object with all its properties and returns the copy. Useful for deriving from existing RenderData objects by copying them and adding or changing properties. This method is called by the viewer for drilling down, for example - the drilldown property is set on the copy while all other properties remain the same, and the copy is used to open a new report view.- Specified by:
getCopy
in interfaceRenderData
- Returns:
- A cloned copy of this RenderData object with all its properties.
- Since:
- 7.0
- See Also:
-
stop
public void stop()Sends the command "stop" to the server. Note that as of i-net Crystal-Clear 7.0, this has no effect.- Specified by:
stop
in interfaceRenderData
- Since:
- 7.0
- See Also:
-
search
Searches the given phrase in the report, starting at a certain page and using the search options given in the flags. These flags are: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.
- Specified by:
search
in interfaceRenderData
- Parameters:
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)- Returns:
- Search result by the server, encoded in the i-net Clear Reports protocol.
- Since:
- 7.0
- See Also:
-
getFontData
public byte[] getFontData(int fontID) Returns the byte array of the embedded font at the specified fontId, which is encoded in the Viewer's protocol. You need not and should not call this method yourself - rather the Viewer will call this method on its own when an embedded font needs to be fetched for the report.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.- Specified by:
getFontData
in interfaceRenderData
- Parameters:
fontID
- ID of font as specified in the i-net Clear Reports protocol- Returns:
- Partial or whole font with the ID, and with the most current version of this font known to the server.
- Since:
- 7.0
-
resetServerCacheTimeout
public void resetServerCacheTimeout()Notifies the server that the report with the currently set properties is still being viewed and therefore should not be removed from the cache yet if there is one. This method does NOT cause the report to be re-rendered under any circumstance, rather it resets the cache timeout on the server if there is one.This method will be called in regular intervals (default is every 5 minutes) by its corresponding ReportView(s).
- Specified by:
resetServerCacheTimeout
in interfaceRenderData
- Since:
- 7.8
-
setForceUseGET
public void setForceUseGET(boolean force) If you set this to true, the URL request will never send parameters as POST parameters but only as a GET request. This is useful if your server cannot handle POST parameters, or if there are other connection problems causing trouble with POST parameters. Note that this may cause problems if there are too many parameters.- Parameters:
force
- Whether or not to force the use of a GET request- Since:
- 7.4
- See Also:
-
isForceUseGET
public boolean isForceUseGET()Returns whether or not GET requests are set as forced.- Returns:
- whether or not GET requests are set as forced.
- Since:
- 7.4
- See Also:
-
setCookie
Sets the cookie for the next connections made by URLRenderData. If a connection has already been opened by URLRenderData, this will not change the cookie of that connection.- Parameters:
cookie
- Cookie to set for the connection If null, removes any cookie set for URLRenderData.- Since:
- 7.5
-
getCookie
Returns the cookie set for the next connections made by URLRenderData. Can return null if no cookie has been set.- Returns:
- The cookie set for the next connections made by URLRenderData.
- Since:
- 7.5
-
setSslSocketFactory
Sets aSSLSocketFactory
that is used if the report has an HTTPS url. An own factory can e.g. accept self-signed certificates.- Parameters:
sslSocketFactory
- theSSLSocketFactory
to be set for HTTPS connection. Set tonull
(default) to use the default factory.- Since:
- 9.2
-
setHostnameVerifier
Sets aHostnameVerifier
that is used if the report has an HTTPS url. An own verifier can e.g. accept self-signed certificates for other hostnames.- Parameters:
hostnameVerifier
- theHostnameVerifier
to be set for HTTPS connection. Set tonull
(default) to use the default verifier.- Since:
- 9.2
-