com.cedarsoft.utils
Class StringCmdLine

java.lang.Object
  extended by com.cedarsoft.utils.AbstractCmdLine
      extended by com.cedarsoft.utils.StringCmdLine
All Implemented Interfaces:
CmdLine

public class StringCmdLine
extends AbstractCmdLine
implements CmdLine

Command Line implementation that is based on strings.

Date: 25.09.2006
Time: 19:43:04

Author:
Johannes Schneider - Xore Systems

Constructor Summary
StringCmdLine()
           
 
Method Summary
 void addAnswer(java.lang.Object answer)
           
 void addExpectedOut(java.lang.String expected)
           
 void error(java.lang.String message, java.lang.Object... objects)
          Prints an error on the console
 java.util.List<java.lang.Object> getAnswers()
           
protected  ConsolePrinter getConsolePrinter()
           
 java.util.List<java.lang.String> getExpectedOut()
           
 java.util.List<java.lang.String> getMessages()
           
protected  java.lang.Object getNextAnswer()
           
 java.io.PrintStream getOut()
           
 void out(java.lang.Process process)
          Redirect the output of the given process
 void out(java.lang.String message, java.lang.Object... objects)
          Prints a message
 void outNl()
          Prints out a new line
 void pause(int seconds)
          Pauses the script
 java.lang.String read(java.lang.String message)
          Reads a string form the console
 java.lang.String read(java.lang.String message, java.lang.String defaultValue)
          Reads a string from the console.
 boolean readBoolean(java.lang.String message)
          Reads a boolean from the command line
 int readInt(java.lang.String message)
          Reads an int from the console
 int readInt(java.lang.String message, int lower, int upper)
          Reads an int from the console
 void removeAnswer(java.lang.Object answer)
           
 void setAnswers(java.util.List<java.lang.Object> answers)
           
 void success(java.lang.String message, java.lang.Object... objects)
          Prints a success message
 void warning(java.lang.String message, java.lang.Object... objects)
          Prints a warning
 
Methods inherited from class com.cedarsoft.utils.AbstractCmdLine
printPossibleElements, read, read, read, readSelection, readSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.cedarsoft.utils.CmdLine
read, read, read, readSelection, readSelection
 

Constructor Detail

StringCmdLine

public StringCmdLine()
Method Detail

getOut

@NotNull
public java.io.PrintStream getOut()
Specified by:
getOut in class AbstractCmdLine

getConsolePrinter

@NotNull
protected ConsolePrinter getConsolePrinter()
Specified by:
getConsolePrinter in class AbstractCmdLine

readBoolean

public boolean readBoolean(@NotNull
                           java.lang.String message)
                    throws java.io.IOException
Description copied from interface: CmdLine
Reads a boolean from the command line

Specified by:
readBoolean in interface CmdLine
Parameters:
message - the message that is shown
Returns:
the value the user has entered
Throws:
java.io.IOException

read

@NotNull
public java.lang.String read(@NotNull
                                     java.lang.String message)
Description copied from interface: CmdLine
Reads a string form the console

Specified by:
read in interface CmdLine
Parameters:
message - the mssage
Returns:
the string

getMessages

@NotNull
public java.util.List<java.lang.String> getMessages()

getNextAnswer

protected java.lang.Object getNextAnswer()

read

@NotNull
public java.lang.String read(@NotNull
                                     java.lang.String message,
                                     @Nullable
                                     java.lang.String defaultValue)
Description copied from interface: CmdLine
Reads a string from the console. The user may optinally select the given default value

Specified by:
read in interface CmdLine
Parameters:
message - the message
defaultValue - the default value
Returns:
the string

readInt

public int readInt(@NotNull
                   java.lang.String message,
                   int lower,
                   int upper)
Description copied from interface: CmdLine
Reads an int from the console

Specified by:
readInt in interface CmdLine
Parameters:
message - the message
lower - the lower bounds
upper - the upper bounds
Returns:
the read int

readInt

public int readInt(@NotNull
                   java.lang.String message)
            throws java.io.IOException
Description copied from interface: CmdLine
Reads an int from the console

Specified by:
readInt in interface CmdLine
Parameters:
message - the message
Returns:
the int
Throws:
java.io.IOException

pause

public void pause(int seconds)
Description copied from interface: CmdLine
Pauses the script

Specified by:
pause in interface CmdLine
Parameters:
seconds - the seconds that it is paused

out

public void out(@NotNull
                java.lang.String message,
                @NotNull
                java.lang.Object... objects)
Description copied from interface: CmdLine
Prints a message

Specified by:
out in interface CmdLine
Overrides:
out in class AbstractCmdLine
Parameters:
message - the message
objects - the objects

out

public void out(@NotNull
                java.lang.Process process)
Description copied from interface: CmdLine
Redirect the output of the given process

Specified by:
out in interface CmdLine
Overrides:
out in class AbstractCmdLine
Parameters:
process - the process the output for is redirected

error

public void error(@NotNull
                  java.lang.String message,
                  @NotNull
                  java.lang.Object... objects)
Description copied from interface: CmdLine
Prints an error on the console

Specified by:
error in interface CmdLine
Overrides:
error in class AbstractCmdLine
Parameters:
message - the error message
objects - the objects

warning

public void warning(@NotNull
                    java.lang.String message,
                    @NotNull
                    java.lang.Object... objects)
Description copied from interface: CmdLine
Prints a warning

Specified by:
warning in interface CmdLine
Overrides:
warning in class AbstractCmdLine
Parameters:
message - the message
objects - the objects

success

public void success(@NotNull
                    java.lang.String message,
                    @NotNull
                    java.lang.Object... objects)
Description copied from interface: CmdLine
Prints a success message

Specified by:
success in interface CmdLine
Overrides:
success in class AbstractCmdLine
Parameters:
message - the message
objects - the objects

outNl

public void outNl()
Description copied from interface: CmdLine
Prints out a new line

Specified by:
outNl in interface CmdLine
Overrides:
outNl in class AbstractCmdLine

addExpectedOut

public void addExpectedOut(@Nullable
                           java.lang.String expected)

getExpectedOut

@NotNull
public java.util.List<java.lang.String> getExpectedOut()

getAnswers

@NotNull
public java.util.List<java.lang.Object> getAnswers()

setAnswers

public void setAnswers(@NotNull
                       java.util.List<java.lang.Object> answers)

addAnswer

public void addAnswer(@NotNull
                      java.lang.Object answer)

removeAnswer

public void removeAnswer(@NotNull
                         java.lang.Object answer)


Copyright © 2009 cedarsoft GmbH. All Rights Reserved.