contents   index   previous   next



interface: SEGetSourceFunction

 

public boolean seGetSourceFunc(SEContext se,SESourceInfo 

                               info,int mode);

 

The seGetSourceFunc callback is used to read script files. If you do not provide the callback, files are read using the normal Java File I/O methods. By defining this interface and the SEFileLocation interface above, you can completely virtualize your files. Although you can handle the virtualizing of files in this function alone, error reporting is based on the filename returned from seFindFileFunc so implementing it is recommended for the user's ease.

 

The mode parameter tells you what the call is intended to do. It can be one of these values:

 

SE.seSourceOpen    open a new file

SE.seSourceGetLine get the next line from the file

SE.seSourceClose close the file

 

In each case, the seGetSourceFunc method is called with seSourceOpen. Returning false results in an 'unable to open file' error in the script. Next the method is repeatedly called with seSourceGetLine to get the individual lines of the source, until you return false to indicate no more lines. Finally, the method is called with seSourceClose to close down the file. The info parameter points to an object that you use to accomplish these tasks. Each file will be given its own SESourceInfo object to work with.

 

The SESourceInfo class defines the following public methods:

 

public String getName();

public void setCode(String code);

public int getLineNumber();

public void setLineNumber(int lineNumber);

public void setUserData(Object userData);

public Object getUserData();

 

The getName method is used to access the name of the file, which is the result of your seFileFindFunc if you have implemented the SEFileLocation interface. The setCode method is where to application puts the successive lines of the file. The setLineNumber and getLineNumber methods are used by the application to update and retrieve the current line number. Finally, the setUserData and getUserData methods are used to store and retrieve whatever information the application needs to process the file. A simple implementation would use an InputStream for userdata, but a more complex one might need to point to an object keeping necessary data.

 

 

 


interface: SEGetResourceFunction