psengines
Class ProgramLoader

java.lang.Object
  extended bypsengines.ProgramLoader

public class ProgramLoader
extends java.lang.Object

It describes the Program loader component of PS-View.

Program Loader is responsible the loading of the code and it's (run-time) clarifaction of what kind of components will use be. The Program Loader class uses the reflection mechanism to add dynamically new operators.


Constructor Summary
ProgramLoader(java.io.PipedWriter pw)
          Creates an instance of Program Loader.
ProgramLoader(java.lang.String fileName)
          Creates an instance of Program Loader.
 
Method Summary
 void changeInputToKeyboard(java.io.PipedWriter pw)
          Changes the tokenizers input from file to keyboard.
 int findToken(java.lang.String str)
          Returns the first occurance of a token in the list where the names of the valid operator classes are saved(binary search).
 PSObject nextPSObject()
          Returns the next PSObject found in the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgramLoader

public ProgramLoader(java.lang.String fileName)
              throws java.lang.Throwable
Creates an instance of Program Loader.

Precondition : A valid path to a PS file.
Postcondition : A new program loader will be created.


ProgramLoader

public ProgramLoader(java.io.PipedWriter pw)
              throws java.lang.Throwable
Creates an instance of Program Loader.

Precondition : A valid pipe writer reference.
Postcondition : A new program loader will be created.

Method Detail

changeInputToKeyboard

public void changeInputToKeyboard(java.io.PipedWriter pw)
                           throws java.lang.Throwable
Changes the tokenizers input from file to keyboard.

Precondition : A valid instance of program loader.
Postcondition : Input will be changed.

Throws:
java.lang.Throwable

nextPSObject

public PSObject nextPSObject()
                      throws java.io.IOException
Returns the next PSObject found in the stream.

Precondition : A valid instance of program loader.
Postcondition : An instance of either a PSLiteral or a PSOperator.

Returns:
The next PSObject found in the stream.
Throws:
java.io.IOException

findToken

public int findToken(java.lang.String str)
Returns the first occurance of a token in the list where the names of the valid operator classes are saved(binary search).
Precondition : A string reference that is not null.
Postcondition : A number of the first position the string is stored in the list.

Returns:
The index where the string was found in the list.