class Counters extends Object
Counter objects in a
map by CounterType. It depends on the argument options which counters
are actually maintained. The update(Line) method updates the
relevant counters based on a line.| Modifier and Type | Field and Description |
|---|---|
static int |
MIN_COUNT_PADDING |
| Constructor and Description |
|---|
Counters(WcArguments args)
Constructor initialising all relevant counters depending on the options
set in
args. |
| Modifier and Type | Method and Description |
|---|---|
int |
getFixedWidthOfColumnsInOutput() |
void |
reset()
Resets all counts to zero.
|
void |
update(Line line)
Updates all the relevant counters based on the specified
line. |
void |
updateTotal(Counters counters)
Updates the totals counter based on some other counter.
|
void |
writeCountsLine(LineProcessor output)
Writes the counts line to the specified
output. |
void |
writeCountsLineWithFileInfo(LineProcessor output,
String fileInfo)
Writes the counts line to the specified
output appending the
specified file information. |
void |
writeCountsLineWithFileInfo(LineProcessor output,
String fileInfo,
int fixedWidthOfColumnsInOutput)
Writes the counts line to the specified
output appending the
specified file information. |
public static final int MIN_COUNT_PADDING
public Counters(WcArguments args)
args.args - the arguments with the options indicating which counts are
desiredpublic void update(Line line)
line.line - the line to incorporate into the countspublic void updateTotal(Counters counters)
counters to the total counts of this
counter.counters - the counters with per-file countspublic void reset()
public int getFixedWidthOfColumnsInOutput()
public void writeCountsLine(LineProcessor output)
output.output - the output destinationpublic void writeCountsLineWithFileInfo(LineProcessor output, String fileInfo)
output appending the
specified file information.output - the output destinationfileInfo - the file information, usually a file name or pathpublic void writeCountsLineWithFileInfo(LineProcessor output, String fileInfo, int fixedWidthOfColumnsInOutput)
output appending the
specified file information.output - the output destinationfileInfo - the file information, usually a file name or pathfixedWidthOfColumnsInOutput - the fixed width of the outputted counts. Will usually be the width
of the widest count, plus two charactersCopyright © 2025. All rights reserved.