public abstract class LogReformatProcessor extends Object implements Processor
SimpleDateFormat
.
default: A substring with this flag will default to the value following an
equals sign, as shown in the example above.
emptyvalue: A substring with this flag will treat the value following an
equals sign as a null value (e.g. Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ERRORS_ALLOWED |
protected int |
errorLinesAllowed |
protected Map<String,LogDetail> |
inputDetailMap |
protected Map<String,LogDetail> |
outputDetailMap |
protected List<String> |
segmentedInput |
protected List<String> |
segmentedOutput |
Constructor and Description |
---|
LogReformatProcessor() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(Properties props,
String inputSpecKey,
String outputSpecKey,
boolean allowFlags)
This is a convenience method to assist sub-classes in configuring
their log detail maps and means of parsing input and structuring output.
|
protected void |
determineErrorTolerance()
TODO: Change this into an actual javadoc
Using the system properties during execution, determine how many lines
in an input log can cause errors before the logs is discarded.
|
protected String |
formatOutputLine()
Following the output pattern, create the reformatted version of the log
line, using the log detail values from the input log line.
|
protected abstract void |
parseInputLine(String line)
Parse a line from an input file and extract the values for presented
details (e.g.
|
protected void |
parseInputSpec(String inputLineSpec,
boolean allowFlags)
Parse the line specification used for input.
|
protected void |
parseOutputSpec(String outputLineSpec,
boolean allowFlags)
Parse the line specification used for output.
|
void |
process(File in,
File out)
Read in a log file, reformat it as per configured, and place the output
in the given directory.
|
void |
process(List<File> in,
File out)
Read in the log files in the given directory, reformat them as per
configured, and place the output in the given directory.
|
protected void |
processFile(File in,
File outputDir)
Process a given
File , placing the reformatted version inside a
given directory. |
protected void |
processFileList(List<File> files,
File out)
|
protected boolean |
processLine(ReadWriter rw)
Use the provided reader to read in a line, reformat it, then write the
new version of the line using the provided writer.
|
protected void |
resetDetailMaps()
Set the maps that store value of details back to null so that values for
previous lines aren't carried forward.
|
protected void |
validateLineSpecs(boolean allowFlags)
Validate the line specifications.
|
boolean |
verifyConfiguration()
Verify that the Processor has been properly configured.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure, getDirName, getOutputFileName
protected int errorLinesAllowed
public static final String DEFAULT_ERRORS_ALLOWED
public void process(File in, File out) throws ProcessingException
process
in interface Processor
in
- The File
that will be reformatted.out
- The directory where output will be placed,
represented as a File
.ProcessingException
- If any parameters are null or invalid, if
the processor hasn't been configured, or if
an error occurs during processing.public void process(List<File> in, File out) throws ProcessingException
process
in interface Processor
in
- A List
of File
s that will
be reformatted.out
- The directory where output will be placed,
represented as a File
.ProcessingException
- If any parameters are null or invalid, if
the processor hasn't been configured, or if
an error occurs during processing.public boolean verifyConfiguration()
Processor
verifyConfiguration
in interface Processor
gov.nasa.pds.report.processing.Processor.verifyConfiguration()
protected void configure(Properties props, String inputSpecKey, String outputSpecKey, boolean allowFlags) throws ProcessingException
props
- The Properties
containing the configuration
for the log source.inputSpecKey
- The key in the properties storing the input line
specification.outputSpecKey
- The key in the properties storing the output line
specification.allowFlags
- A boolean specifying whether flags are allowed in
the input and output line specifications.ProcessingException
gov.nasa.pds.report.processing.Processor.configure()
protected void processFileList(List<File> files, File out) throws ProcessingException
files
- A list of File objects pointing to log
files to be processed.out
- A File
object pointing to the
directory where output will be placed.ProcessingException
- If an error occurs.protected void processFile(File in, File outputDir) throws ProcessingException
File
, placing the reformatted version inside a
given directory.in
- The File that will be processed.outputDir
- The directory where the output will be
placed, represented as a File
.ProcessingException
- If an error occurs while parsing the input
file or while writing output.protected String formatOutputLine() throws ProcessingException
ProcessingException
protected void resetDetailMaps()
protected boolean processLine(ReadWriter rw) throws ProcessingException
rw
- A ReadWriter
that is already
initialized to read and write from the input
and output files.ProcessingException
- If an error occurs.protected void parseInputSpec(String inputLineSpec, boolean allowFlags) throws ProcessingException
inputLineSpec
- The input line specification as a String.allowFlags
- A boolean indicating whether flags are allowed in
the input line specification.ProcessingException
protected void parseOutputSpec(String outputLineSpec, boolean allowFlags) throws ProcessingException
outputLineSpec
- The output line specification as a String.allowFlags
- A boolean indicating whether flags are allowed
in the output line specification.ProcessingException
protected void validateLineSpecs(boolean allowFlags) throws ProcessingException
allowFlags
- A boolean indicating whether flags are
allowed in the line specifications for the
sub-class.ProcessingException
- If the line specifications are invalid.gov.nasa.pds.report.processing.Processor.configure()
protected void determineErrorTolerance()
protected abstract void parseInputLine(String line) throws ProcessingException
line
- The input line, presented as a String.ProcessingException
- If a required detail is not defined, or if
the line cannot be properly parsed using
the pattern provided during configuration.Copyright © 2010–2017 Planetary Data System. All rights reserved.