com.gestalt.scribe
Class Connector

java.lang.Object
  |
  +--com.gestalt.scribe.Connector

public class Connector
extends java.lang.Object

Connector class provides the API to the Scribe server. With the help of Connector an application can request generation of a report from the server, and either display the report in its own graphical interface, or save it in a file.

Connector's constructor logs the calling application in the server, turning it into a client. Once the connection to the server is established, the client can use the methods of Connector instance to request execution of reports. The client application can display the report in a window automatically created by Connector, or use ReportPrintView class to place the report in a custom-made AWT Container. Alternatively, the client application can use getReportAsPDF method to receive a byte array that represents the report in PDF format, or getReportAsHTML methods to receive an HTMLData object with the HTML-formatted report. The following code sample shows how the application can use Connector to create reports:

 import java.io.*;
 import com.gestalt.scribe.*;
public class Controller implements DrillDownReportListener { public static void main(String args[]) { new Controller(); } public Controller() { try // The Scribe server runs on host 192.168.1.12, listening on port 6541 { // The calling app logs in as user "heidi", with password "hello" Connector conn = new Connector("192.168.1.12", 6541, "heidi", "hello"); String reportName = "Customer"; Vector parameterList = conn.getReportParameters(reportName); ParameterPacket packet = (ParameterPacket) parameterList.elementAt(0); packet.setValue("VINET"); byte[] data = conn.getReportAsPDF(reportName, parameterList); try // Save the report in a file { String fileName = "C:\\temp\\Customer.pdf"; FileOutputStream f = new FileOutputStream(fileName); f.write(data); f.flush(); f.close(); } catch (IOException e) { System.out.println(e); } } catch (ServerConnectionException e) { System.out.println(e); } } }
See Also:
DrillDownReportListener

Constructor Summary
Connector(java.lang.String serverIPAddress, int serverPort, java.lang.String userName, java.lang.String password)
          Returns a Connector object.
 
Method Summary
 void disconnect()
          Logs the client application off the Scribe server and breaks the connection.
 void displayReport(java.lang.String reportName, java.util.Vector parameters)
          Displays the report in a new window.
 void displayReport(java.lang.String reportName, java.util.Vector parameters, java.awt.Image img)
          Displays the report in a new window.
 java.util.Vector getReport(java.lang.String reportName, java.util.Vector parameters)
          Returns a Vector of objects that can be forwarded to ReportPanel object for display.
 HTMLData getReportAsHTML(java.lang.String reportName, java.util.Vector parameters)
          Returns an HTMLData object carrying the HTML-formatted report.
 HTMLData getReportAsHTML(java.lang.String reportName, java.util.Vector parameters, String imageDir)
          Returns an HTMLData object carrying the HTML-formatted report with images
 byte[] getReportAsPDF(java.lang.String reportName, java.util.Vector parameters)
          Returns a byte array representing the PDF-formatted report.
 java.util.Vector getReportParameters(java.lang.String reportName)
          Returns a Vector of Parameter objects that describe the report input parameters.
 void setCompression(boolean compress)
          Sets a compression option at the server side.
 void setDelegate(DrillDownReportListener delegate)
          Sets a reference to a DrillDownReportListener object that will be called by Connector if a drill-down field is clicked on in the report.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connector

public Connector(java.lang.String serverIPAddress,
                 int serverPort,
                 java.lang.String userName,
                 java.lang.String password)
          throws ServerConnectionException
Returns a Connector object.

Parameters:
serverIPAddress - Scribe server IP address
serverPort - Scribe server port
userName - Login ID of the user that is entitled to connect to Scribe server
password - User login password in clear text
Throws:
ServerConnectionException - if the connection cannot be established
 
Method Detail

setCompression

public void setCompression(boolean compress)
                    throws java.rmi.RemoteException
Sets a compression option at the server side. If the compression is on, the reports are compressed before being sent to the client, and decompressed in the client upon arrival. Since the compression involves significant processing overhead, this option should be used only when the client is connected to the server via a slow Internet line. The default server compression setting is false.

Parameters:
compress - true to turn the compression on, false otherwise
Throws:
java.rmi.RemoteException - if the server could not be contacted

setDelegate

public void setDelegate(DrillDownReportListener delegate)
Sets a reference to a DrillDownReportListener object that will be called by Connector if a drill-down field is clicked on in the report.

Parameters:
delegate - an object that implements DrillDownReportListener interface
See Also:
DrillDownReportListener

getReportParameters

public java.util.Vector getReportParameters(java.lang.String reportName)
                                     throws java.rmi.RemoteException
Returns a Vector of Parameter objects that describe the report input parameters.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
Returns:
a Vector of Parameter objects
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReport(), getReportAsPDF(), getReportAsHTML() and displayReport()

getReport

public java.util.Vector getReport(java.lang.String reportName,
                                  java.util.Vector parameters)
                           throws java.rmi.RemoteException
Returns a Vector of objects that can be forwarded to ReportPanel object for display.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
parameters - a Vector of Parameter objects as returned by getReportParameters method, with values of Parameter objects set by the client application according to the requirements of the report
Returns:
a Vector of objects to be passed to ReportPanel
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReportParameters()

getReportAsPDF

public byte[] getReportAsPDF(java.lang.String reportName,
                             java.util.Vector parameters)
                      throws java.rmi.RemoteException
Returns a byte array representing the PDF-formatted report.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
parameters - a Vector of Parameter objects as returned by getReportParameters method, with values of Parameter objects set by the client application according to the requirements of the report.
Returns:
a byte array with the PDF content.
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReportParameters()

getReportAsHTML

public HTMLData getReportAsHTML(java.lang.String reportName,
                                java.util.Vector parameters)
                         throws java.rmi.RemoteException
Returns an HTMLData object carrying the HTML-formatted report.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
parameters - a Vector of Parameter objects as returned by getReportParameters method, with values of Parameter objects set by the client application according to the requirements of the report.
Returns:
a HTMLData with the HTML content.
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReportParameters()

getReportAsHTML

public HTMLData getReportAsHTML(java.lang.String reportName,
                                java.util.Vector parameters,
                                java.lang.String imageDir)
                         throws java.rmi.RemoteException
Returns an HTMLData object carrying the HTML-formatted report with images. The images are saved as JPEG files in the directory specified in the imageDir parameter.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
parameters - a Vector of Parameter objects as returned by getReportParameters method, with values of Parameter objects set by the client application according to the requirements of the report.
imageDir - location of the images embedded in the HTML code as "imageDir"/imgN. The images are located in "imageDir" relative to the location of the saved HTML file.
Returns:
a HTMLData with the HTML content.
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReportParameters(java.lang.String)

displayReport

public void displayReport(java.lang.String reportName,
                          java.util.Vector parameters)
                   throws java.rmi.RemoteException
Displays the report in a new window. The window's title is set to the name of the report, and the image in the title bar is set to the standard Java coffee cup.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
parameters - a Vector of Parameter objects as returned by getReportParameters method, with values of Parameter objects set by the client application according to the requirements of the report.
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReportParameters()

displayReport

public void displayReport(java.lang.String reportName,
                          java.util.Vector parameters,
                          java.awt.Image img)
                   throws java.rmi.RemoteException
Displays the report in a new window. The window's title is set to the name of the report, with the custom image in the title bar.

Parameters:
reportName - name of the report. If the report name is hierarchical, then the full name with all qualifiers and slash (/) separators must be specified.
parameters - a Vector of Parameter objects as returned by getReportParameters method, with values of Parameter objects set by the client application according to the requirements of the report.
img - image to be displayed in the window's title bar.
Throws:
java.rmi.RemoteException - if the server could not be contacted
See Also:
getReportParameters()

disconnect

public void disconnect()
Logs the client application off the Scribe server and breaks the connection. Once disconnected, the Connector object cannot be re-used, and must be discarded.