|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.haefelingerit.tagmod.Parser
public class Parser
This class implements a parser to analyze a log file containing tag operations.
The format of the file is rather simple:
0x1 are ignored.0x1 lines must match the following format:
0x1 p=".." o=".." t=".." D=".." U=".."where
.. contains any character sequence other than ". In
addition, field D must match time
format YYYY-MM-DD HH:MM:SS UTC.
The following example shows such a line
0x1 p="foo/bar" o="add" t="r-1.0" D="2008-12-20 13:29:43 UTC" U="alibaba"The following code snippet shows a typical usage pattern of this class:
parser.open(file);
while (parser.advance())
if (parser.match(last, now)) {
// do something with parser.m
}
parser.close();
| Field Summary | |
|---|---|
protected boolean |
cont
A flag to indicate whether it makes sense to read further. |
protected String |
line
The current line - or null if no line has been read so far. |
protected int |
lineno
The current line. |
protected Matcher |
m
A line matcher. |
protected String |
pname
The project name. |
protected String |
re_tagaction
The regular expression to match tag actions. |
protected String |
re_tagvalue
The regular expression to match tag values. |
protected BufferedReader |
reader
The underlying text stream |
protected Pattern |
regex
The overall regular expression a line must comply to. |
protected SimpleDateFormat |
sdf
The standard date format. |
| Constructor Summary | |
|---|---|
Parser()
|
|
| Method Summary | |
|---|---|
boolean |
advance()
Digest on further line from the log file. |
void |
close()
Tell the parser to close the underlying reader. |
protected boolean |
match(Date last,
Date now)
Checks whether the current line matches. |
protected Date |
mkdate(String s)
A helper method to translate a date string into a date object. |
void |
open(File file)
Tell this parser to use this file for reading. |
static String |
quote(String s)
A helper method similar to Pattern.quote(String) found in Java 5. |
void |
reset()
A method to reset the parser in its initial state. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int lineno
protected boolean cont
protected BufferedReader reader
protected String line
protected SimpleDateFormat sdf
protected Matcher m
protected String re_tagaction
protected String re_tagvalue
protected String pname
protected Pattern regex
| Constructor Detail |
|---|
public Parser()
| Method Detail |
|---|
public void reset()
throws Exception
Exceptionpublic static String quote(String s)
public boolean advance()
throws IOException
IOException - if reading underlying reader or stream is not possible.public void open(File file)
file - not nullpublic void close()
protected Date mkdate(String s)
YYYY-MM-DD HH:MM:SS UTC. If translation is not possible, null
is returned.
s - not null
protected boolean match(Date last,
Date now)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||