silk.performer
Interface FileEx


public interface FileEx

FileEx interface defines all methods needed to provide the extended file functions of BDL. Use the File load functions of SilkPerformer to open and load a file. These functions return objects that implement FileEx which can be used to access a loaded file. Every method that starts with an upper case letter has a complement in BDL, the benchmark description language of Segue's SilkPerformer.

Example: Prints first column of every line of the file c:/MyCustomers.txt


    ...
    // Load the file
    FileEx customers = silkPerformer.FileCSVLoad("c:/MyCustomers.txt", ";");
    // Retrieve the number of rows the file contains
    int numRows = customers.FileGetNumRows();
    // Print all rows, begin with first row
    for(int i = 1; i <= numRows; i++)
    {
      customers.FileGetRow(i);
      // Print the first column of every row
      silkPerformer.Print("Row #" + i + ": " + customers.FileGetCol(1,256));
    }
    // Discard the file
    customers.FileUnload();
    customers = null;
    ...
    

Author:
Gerald Ehmayer
See Also:
SilkPerformer.FileCSVLoad(String,String), SilkPerformer.FileCSVLoadGlobal(String,String), SilkPerformer.FileFixedLoad(String,String), SilkPerformer.FileFixedLoadGlobal(String,String), SilkPerformer

Method Summary
 java.lang.String FileGetCol(int col, int max)
          Retrieves a column value of the current row.
 void FileGetFirstRow()
          Sets the current row pointer to the first row in the file.
 int FileGetNextRow()
          Sets the row pointer to the row after the current row.
 int FileGetNumRows()
          Calculates the number of rows the file contains.
 int FileGetRndRow()
          Sets the row pointer to a randomly selected row of the file.
 int FileGetRow(int row)
          Sets the current row pointer to the row number specified.
 void FileUnload()
          Discards all resources of a loaded file.
 java.lang.String getFileName()
          Retrieves the name of the file that is represented by this FileEx object.
 boolean isGlobal()
          Retrieves if a file has a global row pointer.
 

Method Detail

getFileName


public java.lang.String getFileName()
Retrieves the name of the file that is represented by this FileEx object.

Returns:
File name.

isGlobal


public boolean isGlobal()
Retrieves if a file has a global row pointer.

Returns:
true if the file has a global row pointer.

FileGetFirstRow


public void FileGetFirstRow()
                     throws java.lang.Exception
Sets the current row pointer to the first row in the file.

Throws:
java.lang.Exception

FileGetNextRow


public int FileGetNextRow()
                   throws java.lang.Exception
Sets the row pointer to the row after the current row. If the current row is the last row in a file, then the current row is set to the first row of the file.

Returns:
Current row pointer with 1 for the first row.
Throws:
java.lang.Exception

FileGetRndRow


public int FileGetRndRow()
                  throws java.lang.Exception
Sets the row pointer to a randomly selected row of the file.

Returns:
Current row pointer with 1 for the first row.
Throws:
java.lang.Exception

FileGetNumRows


public int FileGetNumRows()
                   throws java.lang.Exception
Calculates the number of rows the file contains.

Returns:
Number of rows in the file.
Throws:
java.lang.Exception

FileGetRow


public int FileGetRow(int row)
               throws java.lang.Exception
Sets the current row pointer to the row number specified.

Parameters:
row - Wanted number of the row with 1 for the first row.
Returns:
Current row pointer.
Throws:
java.lang.Exception

FileGetCol


public java.lang.String FileGetCol(int col,
                                   int max)
                            throws java.lang.Exception
Retrieves a column value of the current row.

Parameters:
col - Wanted number of the column with 1 for the first column.
max - Maximum length of the returned string, if it is longer it would be truncated.
Returns:
The column string.
Throws:
java.lang.Exception

FileUnload


public void FileUnload()
                throws java.lang.Exception
Discards all resources of a loaded file.

Throws:
java.lang.Exception
See Also:
SilkPerformer.FileCSVLoad(String,String), SilkPerformer.FileCSVLoadGlobal(String,String), SilkPerformer.FileFixedLoad(String,String), SilkPerformer.FileFixedLoadGlobal(String,String)