org.browsecode.helpers.controlcomputer
Class ControlThisComputer

java.lang.Object
  extended by org.browsecode.helpers.controlcomputer.ControlThisComputer
All Implemented Interfaces:
ControlComputerInterface

public class ControlThisComputer
extends java.lang.Object
implements ControlComputerInterface


Nested Class Summary
 class ControlThisComputer.LocalSearchForFile
           
 
Nested classes/interfaces inherited from interface org.browsecode.helpers.controlcomputer.ControlComputerInterface
ControlComputerInterface.ConfirmationHandler, ControlComputerInterface.FileMatches, ControlComputerInterface.RegexpFileMatches, ControlComputerInterface.SearchForFile
 
Field Summary
 
Fields inherited from interface org.browsecode.helpers.controlcomputer.ControlComputerInterface
NOT_UNIX, OS_UNKNOWN, UNIX, UNIX_LINUX, UNIX_MACOSX, UNIX_OTHER, WINDOWS
 
Constructor Summary
ControlThisComputer()
           
 
Method Summary
 void closeCurrentCommand()
           
 boolean copyTo(java.io.File[] files, java.lang.String toDir)
           
 void dispose()
           
 java.lang.String getAllOutput()
           
 java.lang.String getDirectorySeparator()
          Usually this is '\' for Windows and '/' for everything else.
static java.lang.String getDirectorySeparatorStatic()
           
 java.lang.String getHostname()
           
 java.lang.String getLastErrorMessage()
           
 int getOperatingSystem()
          Operating System Checks may or may not be implemented.
static int getOS()
           
 java.lang.String getOSVersion()
           
static java.lang.String getOSVersionStatic()
           
 java.lang.String getTempDirectory()
          Get a path for temporary files.
 int getUnixVariant()
           
static int getUnixVariantStatic()
           
static boolean isRunningOnMacOS()
           
static boolean isRunningOnWindows()
           
 boolean isStillRunningLastCommand()
           
static void main(java.lang.String[] args)
           
 void restart()
           
 boolean runCommand(java.lang.String line)
           
 boolean runCommand(java.lang.String[] line)
           
 boolean runCommand(java.lang.String[] line, boolean waitForFinish)
           
 int runCommand(java.lang.String[] line, java.lang.String[] phrasesToWaitFor)
           
 boolean runCommand(java.lang.String line, boolean waitForFinish)
           
 int runCommand(java.lang.String line, java.lang.String[] phrasesToWaitFor)
           
 ControlComputerInterface.SearchForFile searchForFile(ControlComputerInterface.FileMatches fileMatches, ControlComputerInterface.ConfirmationHandler confirmationHandler, java.lang.Runnable runWhenDone)
          This may return null if it's not possible to search for files on this operating system.
 int waitForResponse(java.lang.String[] waitFor)
           
 boolean willSpecialUnixCharactersBeConverted()
          On bash and other unix/linux shells, certain characters get changed to do something else besides themselves: - exclamation points get turned into old commands on the command prompt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlThisComputer

public ControlThisComputer()
Method Detail

isRunningOnMacOS

public static boolean isRunningOnMacOS()

isRunningOnWindows

public static boolean isRunningOnWindows()

getOperatingSystem

public int getOperatingSystem()
Description copied from interface: ControlComputerInterface
Operating System Checks may or may not be implemented. (i.e. it works with local controls but not over SSH, at least not yet)

Specified by:
getOperatingSystem in interface ControlComputerInterface
Returns:

getOS

public static int getOS()

getUnixVariant

public int getUnixVariant()
Specified by:
getUnixVariant in interface ControlComputerInterface

getUnixVariantStatic

public static int getUnixVariantStatic()

getOSVersion

public java.lang.String getOSVersion()
Specified by:
getOSVersion in interface ControlComputerInterface

getOSVersionStatic

public static java.lang.String getOSVersionStatic()

getDirectorySeparatorStatic

public static java.lang.String getDirectorySeparatorStatic()

getDirectorySeparator

public java.lang.String getDirectorySeparator()
Description copied from interface: ControlComputerInterface
Usually this is '\' for Windows and '/' for everything else.

Specified by:
getDirectorySeparator in interface ControlComputerInterface
Returns:

getTempDirectory

public java.lang.String getTempDirectory()
Description copied from interface: ControlComputerInterface
Get a path for temporary files.

Specified by:
getTempDirectory in interface ControlComputerInterface
Returns:

getLastErrorMessage

public java.lang.String getLastErrorMessage()
Specified by:
getLastErrorMessage in interface ControlComputerInterface

runCommand

public boolean runCommand(java.lang.String line)
Specified by:
runCommand in interface ControlComputerInterface

runCommand

public boolean runCommand(java.lang.String[] line)
Specified by:
runCommand in interface ControlComputerInterface

runCommand

public int runCommand(java.lang.String[] line,
                      java.lang.String[] phrasesToWaitFor)
Specified by:
runCommand in interface ControlComputerInterface

runCommand

public int runCommand(java.lang.String line,
                      java.lang.String[] phrasesToWaitFor)
Specified by:
runCommand in interface ControlComputerInterface

runCommand

public boolean runCommand(java.lang.String[] line,
                          boolean waitForFinish)
Specified by:
runCommand in interface ControlComputerInterface

runCommand

public boolean runCommand(java.lang.String line,
                          boolean waitForFinish)
Specified by:
runCommand in interface ControlComputerInterface

isStillRunningLastCommand

public boolean isStillRunningLastCommand()
Specified by:
isStillRunningLastCommand in interface ControlComputerInterface

dispose

public void dispose()
Specified by:
dispose in interface ControlComputerInterface

restart

public void restart()
Specified by:
restart in interface ControlComputerInterface

closeCurrentCommand

public void closeCurrentCommand()

waitForResponse

public int waitForResponse(java.lang.String[] waitFor)
Specified by:
waitForResponse in interface ControlComputerInterface

willSpecialUnixCharactersBeConverted

public boolean willSpecialUnixCharactersBeConverted()
Description copied from interface: ControlComputerInterface
On bash and other unix/linux shells, certain characters get changed to do something else besides themselves: - exclamation points get turned into old commands on the command prompt. - > and >> will write to the file mentioned after this point - | will pipe to a new command Some ControlComputerInterfaces have this property (like SSH) and others don't (like ControlThisComputer, even on linux). Calling method needs to know in case it tries to do 'echo "Hi!" ' or or 'echo "test" >> file' -- both will fail on ones where this method returns false, and work on ones where this methods return true. It's hard to pull this out in a standard way and do something better.

Specified by:
willSpecialUnixCharactersBeConverted in interface ControlComputerInterface

getAllOutput

public java.lang.String getAllOutput()
Specified by:
getAllOutput in interface ControlComputerInterface

copyTo

public boolean copyTo(java.io.File[] files,
                      java.lang.String toDir)
Specified by:
copyTo in interface ControlComputerInterface

searchForFile

public ControlComputerInterface.SearchForFile searchForFile(ControlComputerInterface.FileMatches fileMatches,
                                                            ControlComputerInterface.ConfirmationHandler confirmationHandler,
                                                            java.lang.Runnable runWhenDone)
Description copied from interface: ControlComputerInterface
This may return null if it's not possible to search for files on this operating system.

Specified by:
searchForFile in interface ControlComputerInterface
Returns:

main

public static final void main(java.lang.String[] args)

getHostname

public java.lang.String getHostname()
Specified by:
getHostname in interface ControlComputerInterface