jAER project on SourceForge

net.sf.jaer.eventio
Class AEInputStream

java.lang.Object
  extended by net.sf.jaer.eventio.AEInputStream
All Implemented Interfaces:
java.io.Closeable

public class AEInputStream
extends java.lang.Object
implements java.io.Closeable

An AE input stream that uses a generic InputStream such as a URL connection to an http server.

Author:
tobi

Field Summary
protected  java.util.ArrayList<java.lang.String> header
           
 
Constructor Summary
AEInputStream(java.io.InputStream is)
           
 
Method Summary
 void close()
           
 java.util.ArrayList<java.lang.String> getHeader()
          Gets the header strings from the file
protected  void parseFileFormatVersion(java.lang.String s)
          parses the file format version
 AEPacketRaw readAvailablePacket()
          Reads all available events from the stream
protected  void readHeader()
          reads the header comment lines.
 AEPacketRaw readPacketByNumber(int n)
          Reads a raw event packet of n events
 AEPacketRaw readPacketByTime(int dt)
          returns an AEPacketRaw at least dt long up to the max size of the buffer or until end-of-file.
protected  void skipHeader()
          skips the header lines (if any)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

header

protected java.util.ArrayList<java.lang.String> header
Constructor Detail

AEInputStream

public AEInputStream(java.io.InputStream is)
              throws java.io.IOException
Throws:
java.io.IOException
Method Detail

readAvailablePacket

public AEPacketRaw readAvailablePacket()
                                throws java.io.IOException
Reads all available events from the stream

Returns:
available event packet
Throws:
java.io.IOException

readPacketByNumber

public AEPacketRaw readPacketByNumber(int n)
                               throws java.io.IOException
Reads a raw event packet of n events

Parameters:
n - the number of events to read
Throws:
java.io.IOException - if there is a problem, e.g. end of file

readPacketByTime

public AEPacketRaw readPacketByTime(int dt)
                             throws java.io.IOException
returns an AEPacketRaw at least dt long up to the max size of the buffer or until end-of-file. Events are read as long as the timestamp until (and including) the event whose timestamp is greater (for dt>0) than startTimestamp+dt, where startTimestamp is the last timestamp from the previous call.

Parameters:
dt - the timestamp different in units of the timestamp (usually us)
Returns:
the packet, always at least one event even if there is no event in the interval dt.
Throws:
java.io.IOException - if there is any problem

skipHeader

protected void skipHeader()
                   throws java.io.IOException
skips the header lines (if any)

Throws:
java.io.IOException

readHeader

protected void readHeader()
                   throws java.io.IOException
reads the header comment lines. Assumes we are rewound to position(0).

Throws:
java.io.IOException

parseFileFormatVersion

protected void parseFileFormatVersion(java.lang.String s)
parses the file format version

See Also:
AEDataFile

getHeader

public java.util.ArrayList<java.lang.String> getHeader()
Gets the header strings from the file

Returns:
list of strings, one per line

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

jAER project on SourceForge