epfl.io
Class TagVectorReader

java.lang.Object
  |
  +--epfl.io.TagVectorReader
All Implemented Interfaces:
VectorReader

public class TagVectorReader
extends java.lang.Object
implements VectorReader

A vector reader plugged on a tag reader.


Constructor Summary
TagVectorReader(TagReader in, java.lang.String streamName)
          Creates a new VectorReader from the underlying TagReader
 
Method Summary
 int capacity()
          Returns the stream capacity (number of vectors)
 void close()
          Closes the stream
 int nRead()
          Returns the number of vectors actually read
 int period()
          Returns the stream period
 double[] read()
          Reads a vector in stream
 int size()
          Returns the stream size (vector size)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagVectorReader

public TagVectorReader(TagReader in,
                       java.lang.String streamName)
                throws java.io.IOException
Creates a new VectorReader from the underlying TagReader
Parameters:
in - the underlying TagReader
streamName - the tag name enclosing the data to read
Throws:
java.io.IOException - if the data format is not :
<streamName>
  <capacity> int </capacity>
  <size> int </size>
  <data> {double} size * capacity </data>
</streamName>
Method Detail

read

public double[] read()
              throws java.io.IOException
Reads a vector in stream
Specified by:
read in interface VectorReader
Throws:
java.io.IOException - if the stream is closed or if it is unable to read size doubles

size

public int size()
Returns the stream size (vector size)
Specified by:
size in interface VectorReader

period

public int period()
Returns the stream period
Specified by:
period in interface VectorReader
Returns:
0 if the stream is not periodic

capacity

public int capacity()
Returns the stream capacity (number of vectors)

nRead

public int nRead()
Returns the number of vectors actually read

close

public void close()
           throws java.io.IOException
Closes the stream
Specified by:
close in interface VectorReader
Throws:
java.io.IOException - if the end tag streamName doesn't exist