public abstract class LogReformatProcessor extends java.lang.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 java.lang.String |
DEFAULT_ERRORS_ALLOWED |
protected int |
errorLinesAllowed |
protected java.util.Map<java.lang.String,LogDetail> |
inputDetailMap |
protected java.util.Map<java.lang.String,LogDetail> |
outputDetailMap |
protected java.util.List<java.lang.String> |
segmentedInput |
protected java.util.List<java.lang.String> |
segmentedOutput |
Constructor and Description |
---|
LogReformatProcessor() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(java.util.Properties props,
java.lang.String inputSpecKey,
java.lang.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 java.lang.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(java.lang.String line)
Parse a line from an input file and extract the values for presented
details (e.g.
|
protected void |
parseInputSpec(java.lang.String inputLineSpec,
boolean allowFlags)
Parse the line specification used for input.
|
protected void |
parseOutputSpec(java.lang.String outputLineSpec,
boolean allowFlags)
Parse the line specification used for output.
|
void |
process(java.io.File in,
java.io.File out)
Read in a log file, reformat it as per configured, and place the output
in the given directory.
|
void |
process(java.util.List<java.io.File> in,
java.io.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(java.io.File in,
java.io.File outputDir)
Process a given
File , placing the reformatted version inside a
given directory. |
protected void |
processFileList(java.util.List<java.io.File> files,
java.io.File out)
Process the provided
List of File s. |
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 java.util.List<java.lang.String> segmentedInput
protected java.util.List<java.lang.String> segmentedOutput
protected java.util.Map<java.lang.String,LogDetail> inputDetailMap
protected java.util.Map<java.lang.String,LogDetail> outputDetailMap
protected int errorLinesAllowed
public static final java.lang.String DEFAULT_ERRORS_ALLOWED
public void process(java.io.File in, java.io.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(java.util.List<java.io.File> in, java.io.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(java.util.Properties props, java.lang.String inputSpecKey, java.lang.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(java.util.List<java.io.File> files, java.io.File out) throws ProcessingException
List
of File
s.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(java.io.File in, java.io.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 java.lang.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(java.lang.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(java.lang.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(java.lang.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-2018 Planetary Data System. All Rights Reserved.