Class Ls
java.lang.Object
|
+--Command
|
+--Ls
- public class Ls
- extends Command
The Ls class (a subclass of the abstract base class Command)
implements the familiar unix command ls, which does the
following: for each file that is a directory, ls outputs
the contents of the directory; for each file that is an
ordinary file, ls outputs its name.
This class implements the abstract methods execute and
getDescription inherited from the abstract base class
Command.
|
Method Summary |
java.lang.String |
execute(java.lang.String args)
Executes the ls command and returns the result in the form
of a String object. |
java.lang.String |
getDescription()
Returns a description of the command. |
java.lang.String |
processDirectory(java.lang.String directory)
A helper function that appends the contents of the given file
to a result String object to be returned
by execute. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Ls
public Ls()
execute
public java.lang.String execute(java.lang.String args)
- Executes the ls command and returns the result in the form
of a
String object.
- Specified by:
execute in class Command
- Parameters:
args - arguments for this command.
- Returns:
- the string result of executing the ls command.
processDirectory
public java.lang.String processDirectory(java.lang.String directory)
- A helper function that appends the contents of the given file
to a result
String object to be returned
by execute.
- Parameters:
directory - name of directory whose contents will be appended
to result string.
- Returns:
- a string containing contents of directory.
getDescription
public java.lang.String getDescription()
- Description copied from class:
Command
- Returns a description of the command.
- Specified by:
getDescription in class Command
- Returns:
- the name of the command.