|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ow2.jasmine.monitoring.mbeancmd.Outer
A pipe consists of a pair of channels: a writable channel (called "sink", where information is written to) and a readable channel (called "source", where information is obtained from). The general idea is that once some bytes are available on the source: 1. The pipe reads those bytes. 2. If required, does some action with some or all of these bytes (for example, write them to a file). 3. If a sink is present, writes the exact same bytes in the exact same order on the sink. An Outer instance can retrieve information from (=use as source) a PrintStream or a File and outputs information to (=uses as sink) a PipedOutputStream. The main difference between an Outer and an Iner is that an Outer can also filter out (@see Outer.setRegexp and Outer.setTimeFilter) information and output it on a target. Note that the sink still keeps on receiving unmodified data from the source.
Field Summary | |
private int[] |
colIndexes
Column indexes is message. |
private static java.lang.String |
COLSEP
Default column separator. |
private java.lang.String[] |
columns
Message columns (data). |
private long |
fromTime
Time from which to start outputting data. |
private java.lang.String[] |
heading
Message headers. |
private java.lang.String |
id
Outer id. |
private boolean |
isFilter
Whether regular expression filtering is enabled. |
private boolean |
isFormat
Whether format reading is enabled. |
private boolean |
isTimeFilter
Whether time filtering is enabled. |
private java.lang.String |
regexp
Regular expression used as filter. |
private java.io.LineNumberReader |
rsource
Reader for the source. |
private static java.lang.String |
separator
Current column separator. |
private java.text.SimpleDateFormat |
simpleDateFormat
Time format used to parse the boundaries of the time interval: - fromTime - toTime It is fixed to the following human readable format: "yyyy/MM/dd HH:mm:ss" |
private java.io.PipedOutputStream |
sink
Sink. |
private java.io.PipedInputStream |
source
Source. |
private java.io.PrintWriter |
target
Target writer. |
private java.lang.String |
timeField
Default column name for the time. |
private java.text.SimpleDateFormat |
timeFormat
Time format used to parse the time field. |
private int |
timeIx
Time filter column index. |
private long |
toTime
Time at which to stop outputting data. |
private java.io.PrintWriter |
wsink
Writer on the sink. |
Constructor Summary | |
Outer(java.io.PipedOutputStream src,
java.io.File file)
Creates an Outer using a PipedOutputStream as source and a File as output. |
|
Outer(java.io.PipedOutputStream src,
java.io.PrintStream target)
Creates an Outer using a PipedOutputStream as source and a PrintStream as output. |
Method Summary | |
private boolean |
buildIndex()
Builds the index. |
java.lang.String |
getId()
|
static java.lang.String |
getSeparator()
|
java.io.PipedOutputStream |
getSink()
|
private long |
getTime(java.lang.String t)
Gets the long representation of a time based on the time format. |
static void |
main(java.lang.String[] args)
Tests the Outer implementation. |
private boolean |
matches(java.lang.String ln)
|
void |
resetTimeFilter()
Resets the time filter. |
void |
run()
Starts the activity on the Outer (as described in the class header). |
void |
setFormatter(java.lang.String[] columns)
|
private void |
setHeading(java.lang.String h)
|
void |
setId(java.lang.String id)
|
void |
setRegexp(java.lang.String exp)
|
static void |
setSeparator(java.lang.String s)
|
void |
setSink(java.io.PipedOutputStream sink)
|
void |
setTimeFilter(java.lang.String field,
java.lang.String fieldFormat,
java.lang.String from,
java.lang.String to)
|
private boolean |
timeMatches(java.lang.String ln)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.io.PipedInputStream source
private java.io.LineNumberReader rsource
private java.io.PipedOutputStream sink
private java.io.PrintWriter wsink
private java.io.PrintWriter target
private boolean isFormat
private java.lang.String[] heading
private java.lang.String[] columns
private int[] colIndexes
private boolean isFilter
private java.lang.String regexp
private static final java.lang.String COLSEP
private static java.lang.String separator
private boolean isTimeFilter
private java.lang.String timeField
private java.text.SimpleDateFormat timeFormat
private int timeIx
private java.text.SimpleDateFormat simpleDateFormat
private long fromTime
private long toTime
private java.lang.String id
Constructor Detail |
public Outer(java.io.PipedOutputStream src, java.io.PrintStream target) throws java.io.IOException
getSink()
and
that can be used an input to any pipe) will be created by default.
src
- PipedOutputStream to use as source.target
- PrintStream to use as target (can be null).
java.io.IOException
- If construction or pipe connection fails.setSink(PipedOutputStream)
public Outer(java.io.PipedOutputStream src, java.io.File file) throws java.io.IOException
getSink()
and
that can be used an input to any pipe) will be created by default.
src
- PipedOutputStream to use as source.file
- File to use as output.
java.io.IOException
- If construction or pipe connection fails.setSink(PipedOutputStream)
Method Detail |
public void setSink(java.io.PipedOutputStream sink)
sink
- Sink to set. A dummy sink will be created if null.public java.io.PipedOutputStream getSink()
public java.lang.String getId()
public void setId(java.lang.String id)
id
- The id to set.public static void main(java.lang.String[] args) throws java.io.IOException
args
- Ignored.
java.io.IOException
- When there's a problem with the source or sink.public void run()
run
in interface java.lang.Runnable
private void setHeading(java.lang.String h)
h
- Heading to set. Heading defines the output format and is the
first line sent out on any pipe.public void setFormatter(java.lang.String[] columns)
columns
- Name of the columns to set in the formatter.public void setRegexp(java.lang.String exp)
exp
- Regular expression to use as filter for the target.public void setTimeFilter(java.lang.String field, java.lang.String fieldFormat, java.lang.String from, java.lang.String to)
field
- Which field to use for time filtering.fieldFormat
- Format of the time field as described in
SimpleDateFormat
.from
- Time from which to start outputting data.to
- Time at which to stop outputting data.resetTimeFilter()
public void resetTimeFilter()
setTimeFilter(String, String, String, String)
public static java.lang.String getSeparator()
public static void setSeparator(java.lang.String s)
s
- New field separator to use.private boolean matches(java.lang.String ln)
ln
- String to try to match.
setRegexp(String)
private boolean timeMatches(java.lang.String ln)
ln
- String to try to match.
setTimeFilter(String, String, String, String)
private long getTime(java.lang.String t) throws java.text.ParseException
t
- String to convert into a time.
java.text.ParseException
- If parsing fails.private boolean buildIndex()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |