Package org.apache.felix.gogo.runtime
Class CommandSessionImpl
- java.lang.Object
-
- org.apache.felix.gogo.runtime.CommandSessionImpl
-
- All Implemented Interfaces:
CommandSession,Converter
public class CommandSessionImpl extends java.lang.Object implements CommandSession, Converter
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOMMANDSprotected java.io.InputStreaminprotected java.io.PrintStreamoutstatic java.lang.StringSESSION_CLOSEDprotected java.util.Map<java.lang.String,java.lang.Object>variablesstatic java.lang.StringVARIABLES-
Fields inherited from interface org.apache.felix.service.command.Converter
CONVERTER_CLASSES, INSPECT, LINE, PART
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCommandSessionImpl(CommandProcessorImpl shell, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this command session.java.lang.Objectconvert(java.lang.Class<?> desiredType, java.lang.Object in)Convert an object to another type.java.lang.Objectexecute(java.lang.CharSequence commandline)Execute a program in this session.java.lang.Objectexpr(java.lang.CharSequence expr)java.lang.CharSequenceformat(java.lang.Object result, int inspect)Convert an object to string form (CharSequence).java.lang.CharSequenceformat(java.lang.Object target, int level, Converter escape)Convert an objet to a CharSequence object in the requested format.java.lang.Objectget(java.lang.String name)Get the value of a variable.java.io.PrintStreamgetConsole()Return the PrintStream for the console.java.io.InputStreamgetKeyboard()Return the input stream that is the first of the pipeline.voidput(java.lang.String name, java.lang.Object value)Set the value of a variable.
-
-
-
Field Detail
-
SESSION_CLOSED
public static final java.lang.String SESSION_CLOSED
- See Also:
- Constant Field Values
-
VARIABLES
public static final java.lang.String VARIABLES
- See Also:
- Constant Field Values
-
COMMANDS
public static final java.lang.String COMMANDS
- See Also:
- Constant Field Values
-
in
protected java.io.InputStream in
-
out
protected java.io.PrintStream out
-
variables
protected final java.util.Map<java.lang.String,java.lang.Object> variables
-
-
Constructor Detail
-
CommandSessionImpl
protected CommandSessionImpl(CommandProcessorImpl shell, java.io.InputStream in, java.io.PrintStream out, java.io.PrintStream err)
-
-
Method Detail
-
close
public void close()
Description copied from interface:CommandSessionClose this command session. After the session is closed, it will throw IllegalStateException when it is used.- Specified by:
closein interfaceCommandSession
-
execute
public java.lang.Object execute(java.lang.CharSequence commandline) throws java.lang.ExceptionDescription copied from interface:CommandSessionExecute a program in this session.- Specified by:
executein interfaceCommandSession- Returns:
- the result of the execution
- Throws:
java.lang.Exception
-
getKeyboard
public java.io.InputStream getKeyboard()
Description copied from interface:CommandSessionReturn the input stream that is the first of the pipeline. This stream is sometimes necessary to communicate directly to the end user. For example, a "less" or "more" command needs direct input from the keyboard to control the paging.- Specified by:
getKeyboardin interfaceCommandSession- Returns:
- InpuStream used closest to the user or null if input is from a file.
-
get
public java.lang.Object get(java.lang.String name)
Description copied from interface:CommandSessionGet the value of a variable.- Specified by:
getin interfaceCommandSession- Returns:
-
put
public void put(java.lang.String name, java.lang.Object value)Description copied from interface:CommandSessionSet the value of a variable.- Specified by:
putin interfaceCommandSession- Parameters:
name- Name of the variable.value- Value of the variable
-
getConsole
public java.io.PrintStream getConsole()
Description copied from interface:CommandSessionReturn the PrintStream for the console. This must always be the stream "closest" to the user. This stream can be used to post messages that bypass the piping. If the output is piped to a file, then the object returned must be null.- Specified by:
getConsolein interfaceCommandSession- Returns:
-
format
public java.lang.CharSequence format(java.lang.Object target, int level, Converter escape) throws java.lang.ExceptionDescription copied from interface:ConverterConvert an objet to a CharSequence object in the requested format. The format can be INSPECT, LINE, or PART. Other values must throw IllegalArgumentException.
-
convert
public java.lang.Object convert(java.lang.Class<?> desiredType, java.lang.Object in)Description copied from interface:CommandSessionConvert an object to another type.- Specified by:
convertin interfaceCommandSession- Specified by:
convertin interfaceConverter- Parameters:
desiredType- The type that the returned object can be assigned toin- The object that must be converted- Returns:
- An object that can be assigned to the desired type or null.
-
format
public java.lang.CharSequence format(java.lang.Object result, int inspect)Description copied from interface:CommandSessionConvert an object to string form (CharSequence). The level is defined in the Converter interface, it can be one of INSPECT, LINE, PART. This function always returns a non null value. As a last resort, toString is called on the Object.- Specified by:
formatin interfaceCommandSession- Returns:
-
expr
public java.lang.Object expr(java.lang.CharSequence expr)
-
-