public class URLRenderData extends java.lang.Object implements RenderData
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);
...
getExportChunkCount
and getNextExportChunk
.CASE_SENSITIVE, REGULAR_EXPRESSION, WHOLE_WORD
Constructor and Description |
---|
URLRenderData(java.lang.String requestURL)
Creates a URLRenderData object with the given URL as the location to connect to to fetch the report.
|
URLRenderData(java.net.URL url)
Creates a URLRenderData object with the given URL as the location to connect to to fetch the report.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCookie()
Returns the cookie set for the next connections made by URLRenderData.
|
RenderData |
getCopy()
"Clones" this RenderData object with all its properties and returns the copy.
|
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.
|
byte[] |
getNextExportChunk()
Returns the next chunk of the exported report if there is at least one more chunk available.
|
int |
getPageCount()
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.
|
java.util.Properties |
getProperties()
Returns the Properties object used by this RenderData object.
|
java.lang.String |
getReportLocation()
Returns the URL this report is to be found at, without any attached properties.
|
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 |
isForceUseGET()
Returns whether or not GET requests are set as forced.
|
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()
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[] |
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.
|
void |
setCookie(java.lang.String cookie)
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(javax.net.ssl.HostnameVerifier hostnameVerifier)
Sets a
HostnameVerifier 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(java.lang.String url)
Sets the URL to connect to to fetch the report, e.g. http://localhost:9000/?
|
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 |
setSslSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Sets a
SSLSocketFactory that is used if the report has an HTTPS url. |
void |
stop()
Sends the command "stop" to the server.
|
public URLRenderData(java.lang.String requestURL)
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!RenderData.setReportLocation(java.lang.String)
,
URLRenderData(URL)
public URLRenderData(java.net.URL url)
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!RenderData.setReportLocation(java.lang.String)
,
URLRenderData(String)
public void setReportLocation(java.lang.String url)
setReportLocation
in interface RenderData
url
- URL to connect to to fetch the report (Properties should be URL-encoded in the UTF-8 code page). May not be null.RenderData.setReportLocation(java.lang.String)
public java.lang.String getReportLocation()
getReportLocation
in interface RenderData
RenderData.getReportLocation()
public byte[] getPageData(int page) throws ViewerException
getPageData
in interface RenderData
page
- Number of page to fetch data for, 1-based.ViewerException
- If the given page index is less than 1RenderData.getPageData(int)
public 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 int getPageCount() throws ViewerException
getPageCount
in interface RenderData
ViewerException
- If there are rendering problems, etc.RenderData.getPageData(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 there are connection problems or other issues while fetching the dataRenderData.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 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 final 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.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 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 RenderData getCopy()
getCopy
in interface RenderData
ReportViewer.addNewReportView(RenderData)
,
RenderData.getProperties()
public void stop()
stop
in interface RenderData
RenderData.stop()
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()
This method will be called in regular intervals (default is every 5 minutes) by its corresponding ReportView(s).
resetServerCacheTimeout
in interface RenderData
public void setForceUseGET(boolean force)
force
- Whether or not to force the use of a GET requestisForceUseGET()
public boolean isForceUseGET()
setForceUseGET(boolean)
public void setCookie(java.lang.String cookie)
cookie
- Cookie to set for the connection If null, removes any cookie
set for URLRenderData.public java.lang.String getCookie()
public void setSslSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
SSLSocketFactory
that is used if the report has an HTTPS url. An own factory can e.g. accept
self-signed certificates.sslSocketFactory
- the SSLSocketFactory
to be set for HTTPS connection. Set to null
(default) to use the default factory.public void setHostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
HostnameVerifier
that is used if the report has an HTTPS url. An own verifier can e.g. accept
self-signed certificates for other hostnames.hostnameVerifier
- the HostnameVerifier
to be set for HTTPS connection. Set to null
(default) to use the default verifier.Copyright © 1999-2020 by i-net software GmbH