9.3 RFI例
RFI例では、RFIサービスを使用して、リモートJSMサーバーからRFIDataSourceオブジェクトを受信する方法を示します。このデータ・ソースの内容は、RFI Example Viewerで表示されます。
Properties properties = new Properties ();
properties.put ( "rfi.server", "http://your.own.url:port" ) ;
RFIService service = RFIService.getInstance ( properties ) ;
RFIDataSource dataSource = (RFIDataSource)service.getObject ( "EMPLOYEE-FETCH" ) ;
if ( dataSource == null )
{
printStream.println ( "No object was returned" ) ;
return ;
}
if ( dataSource.equals ( "EMPLOYEE" ) )
{
printStream.println ( "Data source fields :" ) ;
printStream.println ( "" ) ;
/*
Access fields
*/
String[] fields = dataSource.getFieldNames () ;
for ( int i=0; i < fields.length; i++ )
{
printStream.println ( fields[i] + "\t\t" + dataSource.getFieldValue ( fields[i] ) ) ;
}
printStream.println ( "" ) ;
if ( dataSource.containsTable ( "SKILLS" ) )
{
printStream.println ( "Data source table : SKILLS" ) ;
printStream.println ( "" ) ;
/*
Access table
*/
RFIDataTable table = dataSource.getTable ( "SKILLS" ) ;
/*
Access table columns
*/
String[] columns = table.getColumns () ;
for ( int i=0; i < columns.length; i++ )
{
printStream.print ( columns[i] + "\t" ) ;
}
/*
Access table rows
*/
int rowCount = table.getRowCount () ;
for ( int i=0; i < rowCount; i++ )
{
printStream.println ( "" ) ;
for ( int j=0; j < columns.length; j++ )
{
printStream.print ( table.getValueAt ( i, j ) + "\t" ) ;
}
}
}
}