shell
Interface Executable

All Superinterfaces:
java.lang.Runnable
All Known Subinterfaces:
NativeExecutable, ShellExecutable
All Known Implementing Classes:
cd, Command, cp, del, echo, kill, ls, mkdir, ps, pwd, set, ShellCommand, type

public interface Executable
extends java.lang.Runnable

Runtime command is a base class that all apps must extend to work inside Freelance. It provides basic functionality for the apps including and output stream and switch handling.

See Also:
TerminalThread

Method Summary
 void addActiveSwitch(java.lang.Object obj)
          Functionality will need to be provided in child classes.
 void addSwitch(java.lang.String key, Switch value)
           
 void addThreadListener(ThreadListener threadListener)
           
 boolean containsSwitch(java.lang.String key)
           
 boolean equals(Executable e)
           
 boolean equals(java.lang.String s)
           
 boolean getActive()
          Provides external access to the active boolean.
 int getId()
           
 java.lang.String getName()
           
 java.io.PrintStream getOutStream()
           
 java.io.Reader getReader()
           
 Switch getSwitch(java.lang.String key)
           
 boolean isPipeable()
          Not all apps will be able to accept data from a piped inputstream.
 boolean lock()
           
 void processSwitches(java.util.Vector args)
          This method takes in a Vector of a broken up command line.
 void removeThreadListener(ThreadListener threadListener)
           
 void run()
           
 void setActive(boolean active)
          Provides external access to the active boolean.
 void setArgs(java.util.Vector args)
           
 void setArgs(java.util.Vector args, java.io.PrintStream out)
           
 void setId(int id)
           
 void setIncomming(boolean income)
           
 void setInputStream(java.io.InputStream inStream)
           
 void setLock(Lock lock)
           
 void setOutputStream(java.io.OutputStream outStream)
           
 void setOutStream(java.io.PrintStream o)
           
 boolean stillIncomming()
           
 void unlock()
           
 

Method Detail

isPipeable

public boolean isPipeable()
Not all apps will be able to accept data from a piped inputstream. For a command to be able to be recognised as a pipeable app, they must override this method and return true.

Returns:
Whether the app can accept piped data.
See Also:
Pipe

setActive

public void setActive(boolean active)
Provides external access to the active boolean. This should be called when an app is first run, then set to false when finished. The application's process controller can use the getter and setter for the active variable to terminate a thread prematurely, or just to keep track of what is active and what is not.

Parameters:
active - - To set the state of the RuntimeCommand.
See Also:

getActive

public boolean getActive()
Provides external access to the active boolean. This should be called when an app is first run, then set to false when finished. The application's process controller can use the getter and setter for the active variable to terminate a thread prematurely, or just to keep track of what is active and what is not.

Returns:
The current state of the RuntimeCommand.
See Also:

setLock

public void setLock(Lock lock)

lock

public boolean lock()

unlock

public void unlock()

getReader

public java.io.Reader getReader()

setInputStream

public void setInputStream(java.io.InputStream inStream)

getOutStream

public java.io.PrintStream getOutStream()

setOutStream

public void setOutStream(java.io.PrintStream o)

setOutputStream

public void setOutputStream(java.io.OutputStream outStream)

setArgs

public void setArgs(java.util.Vector args)

setArgs

public void setArgs(java.util.Vector args,
                    java.io.PrintStream out)

addSwitch

public void addSwitch(java.lang.String key,
                      Switch value)

getSwitch

public Switch getSwitch(java.lang.String key)

containsSwitch

public boolean containsSwitch(java.lang.String key)

getName

public java.lang.String getName()

stillIncomming

public boolean stillIncomming()

setIncomming

public void setIncomming(boolean income)

setId

public void setId(int id)

getId

public int getId()

addThreadListener

public void addThreadListener(ThreadListener threadListener)

removeThreadListener

public void removeThreadListener(ThreadListener threadListener)

addActiveSwitch

public void addActiveSwitch(java.lang.Object obj)
Functionality will need to be provided in child classes. Will takes an object and add it to an ArrayList of currently active switches.

Parameters:
obj - - Object to add to activeSwitches ArrayList.

processSwitches

public void processSwitches(java.util.Vector args)
                     throws java.io.IOException
This method takes in a Vector of a broken up command line. It checks each element to see if it is a switch, then checks the switch against the switches HashMap, setting it's values where necessary, then adding the switch id ("-f","-r", etc) into the activeSwitches ArrayList.

Parameters:
args - - A vector of arguments to process
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable

equals

public boolean equals(Executable e)

equals

public boolean equals(java.lang.String s)