com.java4less.rreport
Interface RSource

All Known Implementing Classes:
RArraySource, RJDBCSource, RJTableSource

public interface RSource

Data source for an area. Areas are programatically printed by:
1. Assigning a value to the elements in the area. The following command assigns the value "Article1" to the element "TextDescription".

DETAIL_PurchaseOrder.getItemByName("TextDescription").setruntimeValue("Article1");

and Calling the report's printArea() method:

rep.printArea(DETAIL_PurchaseOrder);

2. or if they are linked to a superarea, after the superarea is printed.

However you can also use a Rsource object. In this case the report will automatically assing the values to the fields and print the area as many times as need. There are 3 implemented Rsource classes, but you can implement your own class.

The following example uses the class RArraySource to print the lines of a Purchase Order:

private static void Example2() {


// example: array as data source
Win= new RReportWindow(rep,MainWindow);
DETAIL_PurchaseOrder.setDataSource(new RArraySource(columnsNames,columnsData));
rep.prepare();

//print here
rep.printArea(DETAIL_PurchaseOrder);

rep.endReport();
Win.show();

}

The array columnsNames contains the names of the fields and the array columnsData contanins the values. See Examples or exampleOrder.java.

Note: you can use a RAreaListener in order to execute your own java code before each repetition of the area is printed.

Note: objects defined as constant (see RObject.setConstant()) will not be modified by the data source (RSource).


Method Summary
 java.lang.String[] getFromFields()
          field names in the linked RSource used for the relationship (this is normally the primary key in a table or record).
 RSource getLinkSource()
          linked RSource (if the RSource supports nested RSources).
 java.lang.String[] getToFields()
          field names in this RSource used for the relationship (this is normally a foreign key).
 void rsource_end()
          called after printing all records.
 java.lang.Object rsource_getData(java.lang.String FieldName)
          used to retrieve an element's value.
 boolean rsource_nextRecord()
          used to require a new data record.
 boolean rsource_start()
          called before printing the first record.
 void setFromFields(java.lang.String[] s)
          field names in the linked RSource used for the relationship (this is normally the primary key).
 void setLinkSource(RSource l)
          linked RSource (if the RSource supports nested RSources).
 void setParameter(java.lang.String param, java.lang.String value)
          sets a value for a parameter.
 void setToFields(java.lang.String[] s)
          field names in this RSource used for the relationship (this is normally a foreign key).
 

Method Detail

rsource_getData

public java.lang.Object rsource_getData(java.lang.String FieldName)
used to retrieve an element's value.

rsource_nextRecord

public boolean rsource_nextRecord()
used to require a new data record. Must return false if there are no more records to be printed

rsource_start

public boolean rsource_start()
called before printing the first record. Can be used, for example to connect to a database. Must return true if the RSource is ready.

rsource_end

public void rsource_end()
called after printing all records. Can be used for example to close a connection to a database

getLinkSource

public RSource getLinkSource()
linked RSource (if the RSource supports nested RSources).

setLinkSource

public void setLinkSource(RSource l)
linked RSource (if the RSource supports nested RSources).

getFromFields

public java.lang.String[] getFromFields()
field names in the linked RSource used for the relationship (this is normally the primary key in a table or record).

getToFields

public java.lang.String[] getToFields()
field names in this RSource used for the relationship (this is normally a foreign key).

setFromFields

public void setFromFields(java.lang.String[] s)
field names in the linked RSource used for the relationship (this is normally the primary key).

setToFields

public void setToFields(java.lang.String[] s)
field names in this RSource used for the relationship (this is normally a foreign key).

setParameter

public void setParameter(java.lang.String param,
                         java.lang.String value)
sets a value for a parameter. Some RSource can accept parameters, for example the RJDBCSource can use parameters to create a database SQl query.