|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.archive.crawler.util.LogReader
public class LogReader
This class contains a variety of methods for reading log files (or other text files containing repeated lines with similar information).
All methods are static.
Constructor Summary | |
---|---|
LogReader()
|
Method Summary | |
---|---|
static java.lang.String |
buildDisplayingHeader(int len,
long logsize)
|
static int |
findFirstLineBeginning(java.io.InputStreamReader reader,
java.lang.String prefix)
Return the line number of the first line in the log/file that that begins with the given string. |
static int |
findFirstLineBeginningFromSeries(java.lang.String aFileName,
java.lang.String prefix)
Return the line number of the first line in the log/file that begins with the given string. |
static int |
findFirstLineContaining(java.io.InputStreamReader reader,
java.lang.String regExpr)
Return the line number of the first line in the log/file that matches a given regular expression. |
static int |
findFirstLineContaining(java.lang.String aFileName,
java.lang.String regExpr)
Return the line number of the first line in the log/file that matches a given regular expression. |
static int |
findFirstLineContainingFromSeries(java.lang.String aFileName,
java.lang.String regExpr)
Return the line number of the first line in the log/file that matches a given regular expression. |
static java.lang.String |
get(java.io.InputStreamReader reader)
Reads entire contents of reader, returns as string. |
static java.lang.String[] |
get(java.io.InputStreamReader reader,
int lineNumber,
int n,
long logsize)
Gets a portion of a log file. |
static java.lang.String |
get(java.lang.String aFileName)
Returns the entire file. |
static java.lang.String[] |
get(java.lang.String aFileName,
int lineNumber,
int n)
Gets a portion of a log file. |
static java.lang.String[] |
getByRegExpr(java.io.InputStreamReader reader,
java.lang.String regExpr,
int addLines,
boolean prependLineNumbers,
int skipFirstMatches,
int numberOfMatches,
long logsize)
Returns all lines in a log/file matching a given regular expression. |
static java.lang.String[] |
getByRegExpr(java.io.InputStreamReader reader,
java.lang.String regExpr,
java.lang.String addLines,
boolean prependLineNumbers,
int skipFirstMatches,
int numberOfMatches,
long logsize)
Returns all lines in a log/file matching a given regular expression. |
static java.lang.String[] |
getByRegExpr(java.lang.String aFileName,
java.lang.String regExpr,
int addLines,
boolean prependLineNumbers,
int skipFirstMatches,
int numberOfMatches)
Returns all lines in a log/file matching a given regular expression. |
static java.lang.String[] |
getByRegExpr(java.lang.String aFileName,
java.lang.String regExpr,
java.lang.String addLines,
boolean prependLineNumbers,
int skipFirstMatches,
int numberOfMatches)
Returns all lines in a log/file matching a given regular expression. |
static java.lang.String[] |
getByRegExprFromSeries(java.lang.String aFileName,
java.lang.String regExpr,
int addLines,
boolean prependLineNumbers,
int skipFirstMatches,
int numberOfMatches)
Returns all lines in a log/file matching a given regular expression. |
static java.lang.String[] |
getByRegExprFromSeries(java.lang.String aFileName,
java.lang.String regExpr,
java.lang.String addLines,
boolean prependLineNumbers,
int skipFirstMatches,
int numberOfMatches)
Returns all lines in a log/file matching a given regular expression. |
static java.lang.String[] |
getFromSeries(java.lang.String aFileName,
int lineNumber,
int n)
Gets a portion of a log spread across a numbered series of files. |
static java.lang.String[] |
tail(java.io.RandomAccessFile raf,
int n)
Implementation of a unix-like 'tail -n' command |
static java.lang.String[] |
tail(java.lang.String aFileName)
Implementation of a unix-like 'tail' command |
static java.lang.String[] |
tail(java.lang.String aFileName,
int n)
Implementation of a unix-like 'tail -n' command |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LogReader()
Method Detail |
---|
public static java.lang.String get(java.lang.String aFileName)
aFileName
- a file name
public static java.lang.String get(java.io.InputStreamReader reader)
reader
-
public static java.lang.String[] get(java.lang.String aFileName, int lineNumber, int n)
aFileName
- The filename of the log/filelineNumber
- The number of the first line to get (if larger then the
file an empty string will be returned)n
- How many lines to return (total, including the one indicated by
lineNumber). If smaller then 1 then an empty string
will be returned.
public static java.lang.String[] getFromSeries(java.lang.String aFileName, int lineNumber, int n)
aFileName
- The filename of the log/filelineNumber
- The number of the first line to get (if larger then the
file an empty string will be returned)n
- How many lines to return (total, including the one indicated by
lineNumber). If smaller then 1 then an empty string
will be returned.
public static java.lang.String buildDisplayingHeader(int len, long logsize)
public static java.lang.String[] get(java.io.InputStreamReader reader, int lineNumber, int n, long logsize)
reader
- source to scan for lineslineNumber
- The number of the first line to get (if larger then the
file an empty string will be returned)n
- How many lines to return (total, including the one indicated by
lineNumber). If smaller then 1 then an empty string
will be returned.logsize
- total size of source
public static int findFirstLineContaining(java.lang.String aFileName, java.lang.String regExpr)
aFileName
- The filename of the log/fileregExpr
- The regular expression that is to be used
public static int findFirstLineBeginningFromSeries(java.lang.String aFileName, java.lang.String prefix)
aFileName
- The filename of the log/fileprefix
- The prefix string to match
public static int findFirstLineBeginning(java.io.InputStreamReader reader, java.lang.String prefix)
reader
- The reader of the log/fileprefix
- The prefix string to match
public static int findFirstLineContainingFromSeries(java.lang.String aFileName, java.lang.String regExpr)
aFileName
- The filename of the log/fileregExpr
- The regular expression that is to be used
public static int findFirstLineContaining(java.io.InputStreamReader reader, java.lang.String regExpr)
reader
- The reader of the log/fileregExpr
- The regular expression that is to be used
public static java.lang.String[] getByRegExpr(java.lang.String aFileName, java.lang.String regExpr, int addLines, boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches)
aFileName
- The filename of the log/fileregExpr
- The regular expression that is to be usedaddLines
- How many lines (in addition to the matched line) to add.
A value less then 1 will mean that only the matched line
will be included. If another matched line is hit before
we reach this limit it will be included and this counter
effectively reset for it.prependLineNumbers
- If true, then each line will be prepended by
it's line number in the file.skipFirstMatches
- The first number of matches up to this value will
be skipped over.numberOfMatches
- Once past matches that are to be skipped this many
matches will be added to the return value. A
value of 0 will cause all matching lines to be
included.
public static java.lang.String[] getByRegExprFromSeries(java.lang.String aFileName, java.lang.String regExpr, int addLines, boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches)
aFileName
- The filename of the log/fileregExpr
- The regular expression that is to be usedaddLines
- How many lines (in addition to the matched line) to add.
A value less then 1 will mean that only the matched line
will be included. If another matched line is hit before
we reach this limit it will be included and this counter
effectively reset for it.prependLineNumbers
- If true, then each line will be prepended by
it's line number in the file.skipFirstMatches
- The first number of matches up to this value will
be skipped over.numberOfMatches
- Once past matches that are to be skipped this many
matches will be added to the return value. A
value of 0 will cause all matching lines to be
included.
public static java.lang.String[] getByRegExpr(java.io.InputStreamReader reader, java.lang.String regExpr, int addLines, boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches, long logsize)
reader
- The reader of the log/fileregExpr
- The regular expression that is to be usedaddLines
- How many lines (in addition to the matched line) to add.
A value less then 1 will mean that only the matched line
will be included. If another matched line is hit before
we reach this limit it will be included and this counter
effectively reset for it.prependLineNumbers
- If true, then each line will be prepended by
it's line number in the file.skipFirstMatches
- The first number of matches up to this value will
be skipped over.numberOfMatches
- Once past matches that are to be skipped this many
matches will be added to the return value. A
value of 0 will cause all matching lines to be
included.logsize
- Size of the log in bytes
public static java.lang.String[] getByRegExpr(java.lang.String aFileName, java.lang.String regExpr, java.lang.String addLines, boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches)
aFileName
- The filename of the log/fileregExpr
- The regular expression that is to be usedaddLines
- Any lines following a match that begin with this
string will also be included. We will stop including new
lines once we hit the first that does not match.prependLineNumbers
- If true, then each line will be prepended by
it's line number in the file.skipFirstMatches
- The first number of matches up to this value will
be skipped over.numberOfMatches
- Once past matches that are to be skipped this many
matches will be added to the return value. A
value of 0 will cause all matching lines to be
included.
public static java.lang.String[] getByRegExprFromSeries(java.lang.String aFileName, java.lang.String regExpr, java.lang.String addLines, boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches)
aFileName
- The filename of the log/fileregExpr
- The regular expression that is to be usedaddLines
- Any lines following a match that begin with this
string will also be included. We will stop including new
lines once we hit the first that does not match.prependLineNumbers
- If true, then each line will be prepended by
it's line number in the file.skipFirstMatches
- The first number of matches up to this value will
be skipped over.numberOfMatches
- Once past matches that are to be skipped this many
matches will be added to the return value. A
value of 0 will cause all matching lines to be
included.
public static java.lang.String[] getByRegExpr(java.io.InputStreamReader reader, java.lang.String regExpr, java.lang.String addLines, boolean prependLineNumbers, int skipFirstMatches, int numberOfMatches, long logsize)
reader
- The reader of the log/fileregExpr
- The regular expression that is to be usedaddLines
- Any lines following a match that begin with this
string will also be included. We will stop including new
lines once we hit the first that does not match.prependLineNumbers
- If true, then each line will be prepended by
it's line number in the file.skipFirstMatches
- The first number of matches up to this value will
be skipped over.numberOfMatches
- Once past matches that are to be skipped this many
matches will be added to the return value. A
value of 0 will cause all matching lines to be
included.logsize
- Size of the log in bytes
public static java.lang.String[] tail(java.lang.String aFileName)
aFileName
- a file name String
public static java.lang.String[] tail(java.lang.String aFileName, int n)
aFileName
- a file name Stringn
- int number of lines to be returned
public static java.lang.String[] tail(java.io.RandomAccessFile raf, int n)
raf
- a RandomAccessFile to tailn
- int number of lines to be returned
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |