|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--Command
|
+--Wc
The Wc class (a subclass of the abstract base class Command)
implements the familiar unix command wc, which outputs
a count of lines, words, and characters in each file.
This class implements the abstract methods execute and
getDescription inherited from the abstract base class
Command.
| Field Summary | |
protected int |
myCharCount
Number of characters in file. |
protected int |
myLineCount
Number of lines in file. |
protected int |
myWordCount
Number of words in file. |
| Constructor Summary | |
Wc()
|
|
| Method Summary | |
protected void |
doCount(java.lang.String filename)
A helper function that counts the number of lines, words, and characters in the current file. |
java.lang.String |
execute(java.lang.String args)
Executes the wc command and returns the result in the form of a String object. |
java.lang.String |
getDescription()
Returns a description of the command. |
protected int |
getLineCount()
A helper function that returns the line count of the current file. |
protected java.lang.String |
Update(java.lang.String filename)
A helper function that updates the result to be passed back through execute with the counts of the
number of lines, words, and characters in the current file. |
| Methods inherited from class Command |
ExpandArgs |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int myLineCount
protected int myWordCount
protected int myCharCount
| Constructor Detail |
public Wc()
| Method Detail |
public java.lang.String execute(java.lang.String args)
String object.
execute in class Commandargs - arguments for this command.
protected void doCount(java.lang.String filename)
filename - name of file to be counted.protected java.lang.String Update(java.lang.String filename)
execute with the counts of the
number of lines, words, and characters in the current file.
filename - name of file just counted.
protected int getLineCount()
myLineCount.public java.lang.String getDescription()
Command
getDescription in class Command
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||