question: public Serializable processCommand ( String sessionID , String commandLine ) throws Exception { Command cmd = parser . parseOne ( commandLine ) ; if ( cmd == null ) { throw new Exception ( "Cannot execute null command" ) ; } String command = cmd . getTokens ( ) [ 0 ] ; String [ ] params = getParams ( cmd . getTokens ( ) , true ) ; String result = null ; if ( command . equals ( CD ) ) { String path = ( params != null ? params [ 0 ] : null ) ; cd ( sessionID , path ) ; } else if ( command . equals ( LIST ) ) { String path = ( params != null ? params [ 0 ] : null ) ; ResourceNode startNode = getStartNode ( sessionID , path ) ; List < ResourceNode > entries = ls ( sessionID , path , cmd . isRecursive ( ) ) ; result = formatEntries ( entries , startNode , cmd . isLong ( ) , cmd . isAbsolute ( ) ) ; } else if ( command . equals ( CREATE ) ) { String path = ( params != null ? params [ 0 ] : null ) ; create ( sessionID , path , cmd . includeParents ( ) ) ; } else if ( command . equals ( RM ) ) { String path = ( params != null ? params [ 0 ] : null ) ; rm ( sessionID , path ) ; } else if ( command . equals ( CP ) ) { String source = ( params != null ? params [ 0 ] : null ) ; String destination = ( source != null && params . length == 2 ) ? params [ 1 ] : null ; cp ( sessionID , source , destination ) ; } else if ( command . equals ( PWD ) ) { result = pwd ( sessionID ) ; } else if ( command . equals ( CHKEXEC ) ) { String path = ( params != null ? params [ 0 ] : null ) ; return String . format ( "%s" , isExecutable ( sessionID , path ) ) ; } else if ( command . equals ( WHICH ) ) { String path = ( params != null ? params [ 0 ] : null ) ; return String . format ( "%s" , which ( sessionID , path ) ) ; } else if ( command . equals ( CONNECT ) ) { throw new Exception ( "This interface to CONNECT is no longer supported" ) ; } else if ( command . equals ( SERVICE ) ) { String serviceSpec = ( params != null ? params [ 0 ] : null ) ; String serviceCmd = ( params != null && params . length > 1 ? params [ 1 ] : null ) ; return executeExtension ( ResourceType . SERVICE , serviceSpec , "command" , serviceCmd , null ) ; } else if ( command . equals ( LOCATE_SERVICE ) ) { String serviceSpec = ( params != null ? params [ 0 ] : null ) ; String serviceCmd = ( params != null && params . length > 1 ? params [ 1 ] : null ) ; return executeExtension ( ResourceType . SERVICE , serviceSpec , "command" , serviceCmd , null ) ; } else if ( command . equals ( EXECUTE ) ) { cmd = parser . parseOne ( commandLine , false ) ; params = getParams ( cmd . getTokens ( ) , false ) ; String type = ( params != null ? params [ 0 ] : null ) ; String extensionName = ( params != null ? params [ 1 ] : null ) ; String theCommand = ( params != null && params . length > 2 ? params [ 2 ] : null ) ; if ( type == null || extensionName == null || theCommand == null ) { throw new DirectoryException ( String . format ( "Incorrectly formed command for execute:'%s'." , command ) ) ; } ResourceType extensionType = ResourceType . valueOf ( type . toUpperCase ( ) ) ; String argList [ ] = null ; if ( params != null && params . length > 3 ) { argList = new String [ params . length - 3 ] ; for ( int i = 3 ; i < params . length ; i ++ ) argList [ i - 3 ] = params [ i ] ; } return executeExtension ( extensionType , extensionName , KEY_COMMAND , theCommand , argList ) ; } else { if ( isExecutable ( sessionID , command ) ) { throw new DirectoryException ( String . format ( "Cannot execute '%s' in this context." , command ) ) ; } } return result ; }
target:  This is the main interface for the directory with respect to text-based operations.