|
LiveGraph data visualisation and analysis framework |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.LiveGraph.dataCache.DataStreamToCacheReader
public class DataStreamToCacheReader
This reader will parse a data stream using DataStreamReader
and store all
information in a data cache for further processing by the application.
See DataStreamWriter
for the details of the data file format.
This product includes software developed by the
LiveGraph project and its contributors.
(http://www.live-graph.org)
Copyright (c) 2007 G. Paperin.
All rights reserved.
File: DataStreamToCacheReader.java
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:
1. Redistributions of source code must retain the above
acknowledgement of the LiveGraph project and its web-site, the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the
LiveGraph project and its web-site, the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with
the distribution.
3. All advertising materials mentioning features or use of this software or any derived
software must display the following acknowledgement:
This product includes software developed by the LiveGraph project and its
contributors.
(http://www.live-graph.org)
4. All advertising materials distributed in form of HTML pages or any other technology
permitting active hyper-links that mention features or use of this software or any
derived software must display the acknowledgment specified in condition 3 of this
agreement, and in addition, include a visible and working hyper-link to the LiveGraph
homepage (http://www.live-graph.org).
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Field Summary | |
---|---|
private DataCache |
cache
Cache for storage of extracted data. |
private DataStreamReader |
in
Data stream reader. |
Constructor Summary | |
---|---|
DataStreamToCacheReader(java.io.InputStream is,
DataCache cache)
Creates a data reader on the specified stream. |
Method Summary | |
---|---|
void |
close()
Closes the underlying data stream. |
void |
eventCommentLine(java.lang.String line,
DataStreamReader reader)
Used for callback by the DataStreamReader ; does nothing. |
void |
eventDataLineRead(java.util.List<java.lang.String> dataTokens,
int datasetIndex,
DataStreamReader reader)
Used for callback by the DataStreamReader ; adds a dataset to the cache. |
void |
eventFileInfoLine(java.lang.String info,
DataStreamReader reader)
Used for callback by the DataStreamReader ; adds a file info line to the cache. |
void |
eventLabelsSet(java.util.List<java.lang.String> labels,
DataStreamReader reader)
Used for callback by the DataStreamReader ; setts the data column labels in the cache. |
void |
eventSeparatorSet(java.lang.String separator,
DataStreamReader reader)
Used for callback by the DataStreamReader ; does nothing. |
DataCache |
getDataCache()
|
int |
readFromStream()
Reads as many data lines from the underlying stream as there are available, parses the lines and stores the extracted information (if any) in this reader's data cache. |
boolean |
ready()
Tells whether this reader's underlying data stream is ready to be read. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private DataStreamReader in
private DataCache cache
Constructor Detail |
---|
public DataStreamToCacheReader(java.io.InputStream is, DataCache cache)
is
- The stream from which to read.cache
- The data cache into which to store the data.Method Detail |
---|
public DataCache getDataCache()
public boolean ready() throws java.io.IOException
true
if the next readFromStream()
is guaranteed not to block for input,
false
otherwise. Note that returning false
does not guarantee that the next read will block.
java.io.IOException
- If an I/O error occurs.public void close() throws java.io.IOException
close
in interface java.io.Closeable
java.io.IOException
- If an I/O error occurs.public int readFromStream() throws java.io.IOException, DataFormatException
java.io.IOException
- If an I/O error occurs.
DataFormatException
- If the data stream contents do not conform with the expected data
stream format.DataStreamWriter
,
DataStreamReader
public void eventCommentLine(java.lang.String line, DataStreamReader reader)
DataStreamReader
; does nothing.
eventCommentLine
in interface DataStreamObserver
line
- The comment line.reader
- The reader which produced this event.public void eventDataLineRead(java.util.List<java.lang.String> dataTokens, int datasetIndex, DataStreamReader reader)
DataStreamReader
; adds a dataset to the cache.
eventDataLineRead
in interface DataStreamObserver
dataTokens
- An unmodifiable list containing all data tokens parsed from this line.datasetIndex
- The number of this data line in the stream (i.e. dataset file index).reader
- The reader which produced this event.public void eventFileInfoLine(java.lang.String info, DataStreamReader reader)
DataStreamReader
; adds a file info line to the cache.
eventFileInfoLine
in interface DataStreamObserver
info
- File description/info string.reader
- The reader which produced this event.public void eventLabelsSet(java.util.List<java.lang.String> labels, DataStreamReader reader)
DataStreamReader
; setts the data column labels in the cache.
eventLabelsSet
in interface DataStreamObserver
labels
- An unmodifiable list containing all parsed data series labels.reader
- The reader which produced this event.public void eventSeparatorSet(java.lang.String separator, DataStreamReader reader)
DataStreamReader
; does nothing.
eventSeparatorSet
in interface DataStreamObserver
separator
- The new data values separator string.reader
- The reader which produced this event.
|
LiveGraph data visualisation and analysis framework |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |