com.cedarsoft.utils
Interface CmdLine

All Known Implementing Classes:
AbstractCmdLine, DefaultCmdLine, DummyCmdLine, StringCmdLine

public interface CmdLine

Provides access to the command line


Method Summary
 void error(java.lang.String message, java.lang.Object... objects)
          Prints an error on the console
 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
<T> T
read(java.lang.String message, java.util.List<? extends T> elements, Renderer<T,java.lang.Object> presenter, ObjectFactory<T> objectFactory)
          Reads a string from the console
 java.lang.String read(java.lang.String message, java.util.List<java.lang.String> elements)
          Reads a string
 java.lang.String read(java.lang.String message, java.util.List<java.lang.String> elements, java.lang.String preselected)
          Reads a string from 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
<T> T
readSelection(java.lang.String message, java.util.List<? extends T> elements)
          Selects an element
<T> T
readSelection(java.lang.String message, java.util.List<? extends T> elements, Renderer<? super T,java.lang.Object> presenter)
          Select an element from the list
 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
 

Method Detail

readBoolean

boolean readBoolean(@NotNull
                    java.lang.String message)
                    throws java.io.IOException
Reads a boolean from the command line

Parameters:
message - the message that is shown
Returns:
the value the user has entered
Throws:
java.io.IOException

error

void error(@NotNull
           java.lang.String message,
           @NotNull
           java.lang.Object... objects)
Prints an error on the console

Parameters:
message - the error message
objects - the objects

warning

void warning(@NotNull
             java.lang.String message,
             @NotNull
             java.lang.Object... objects)
Prints a warning

Parameters:
message - the message
objects - the objects

success

void success(@NotNull
             java.lang.String message,
             @NotNull
             java.lang.Object... objects)
Prints a success message

Parameters:
message - the message
objects - the objects

read

@NotNull
java.lang.String read(@NotNull
                              java.lang.String message)
Reads a string form the console

Parameters:
message - the mssage
Returns:
the string

read

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

Parameters:
message - the message
defaultValue - the default value
Returns:
the string

read

@NotNull
java.lang.String read(@NotNull
                              java.lang.String message,
                              @NotNull
                              java.util.List<java.lang.String> elements)
Reads a string

Parameters:
message - the message
elements - the elements that may be selected
Returns:
the entered value (a free value or one of the elements)

readInt

int readInt(@NotNull
            java.lang.String message,
            int lower,
            int upper)
Reads an int from the console

Parameters:
message - the message
lower - the lower bounds
upper - the upper bounds
Returns:
the read int

readInt

int readInt(@NotNull
            java.lang.String message)
            throws java.io.IOException
Reads an int from the console

Parameters:
message - the message
Returns:
the int
Throws:
java.io.IOException

readSelection

@NotNull
<T> T readSelection(@NotNull
                            java.lang.String message,
                            @NotNull
                            java.util.List<? extends T> elements,
                            @Nullable
                            Renderer<? super T,java.lang.Object> presenter)
Select an element from the list

Parameters:
message - the message
elements - the elements that may be choosen @return the selected element
presenter - an optional presenter that creates a string representation for the elements
Returns:
the selected element

readSelection

@NotNull
<T> T readSelection(@NotNull
                            java.lang.String message,
                            @NotNull
                            java.util.List<? extends T> elements)
Selects an element

Parameters:
message - the message
elements - the elements
Returns:
the selected element

pause

void pause(int seconds)
Pauses the script

Parameters:
seconds - the seconds that it is paused

outNl

void outNl()
Prints out a new line


out

void out(@NotNull
         java.lang.String message,
         @NotNull
         java.lang.Object... objects)
Prints a message

Parameters:
message - the message
objects - the objects

out

void out(@NotNull
         java.lang.Process process)
Redirect the output of the given process

Parameters:
process - the process the output for is redirected

read

@NotNull
<T> T read(@NotNull
                   java.lang.String message,
                   @NotNull
                   java.util.List<? extends T> elements,
                   @Nullable
                   Renderer<T,java.lang.Object> presenter,
                   @NotNull
                   ObjectFactory<T> objectFactory)
Reads a string from the console

Parameters:
message - the message
elements - the elements (the user may select one of them)
presenter - the presenter
Returns:
the string that has been entered manually or the object that has been selected (String or T)

read

@NotNull
java.lang.String read(@NotNull
                              java.lang.String message,
                              @NotNull
                              java.util.List<java.lang.String> elements,
                              @NotNull
                              java.lang.String preselected)
Reads a string from the console

Parameters:
message - the message
elements - the elements
preselected - the preselected string
Returns:
the read string from the console (one of the elements, the preselected value or a newly entered value)


Copyright © 2009 cedarsoft GmbH. All Rights Reserved.