com.voytechs.jnetstream.codec
Class FlowImpl

java.lang.Object
  extended by com.voytechs.jnetstream.codec.FlowImpl
All Implemented Interfaces:
Flow

public class FlowImpl
extends java.lang.Object
implements Flow

Implementing class for Flow interface. Flow is a grouping of packets between a source and destination.

Flow has 2 directions, the "left" and "right". These are abstract directions and neither directions is of any greater importance then then the other. It is upto the Decoder to create in a certain way vs. another. Initial FlowDecoder implementation created flows so that left flow was client end while the right flow was the server end.

Please note that is not always possible to determine which direction is from the client end which from the server end.

Since:
0.3.0
Author:
Mark Bednarczyk

Field Summary
 
Fields inherited from interface com.voytechs.jnetstream.codec.Flow
LEFT, MAX_PACKETS, RIGHT
 
Constructor Summary
FlowImpl(FlowKey key)
          Initialize a new Flow
 
Method Summary
 void addLeftPacket(Packet packet)
          Adds a given packet to this flow.
 void addRightPacket(Packet packet)
          Adds a given packet to this flow.
 boolean equals(java.lang.Object key)
          Compares the FlowKeys between this flow and one being compared to.
 long getExpireTimeout()
          Returns the time when this flow needs to be expired.
 FlowKey getFlowKey()
          Returns the Flow key for this flow.
 java.util.List getLeftPackets()
          Returns a list of LEFT packets
 int getPacketCount()
          Returns the number of total packets in this flow.
 java.util.List getPackets()
          Returns a list of packets in their original sequence.
 java.util.List getRightPackets()
          Returns a list of RIGHT packets
 java.lang.String getSummaryLine()
          Returns a terse summary string of this flow.
 int hashCode()
           
 void resetExpireTimeout()
           
 void setExpireTimeout(long time)
          Sets the time from now when this flow is to be expired.
 java.lang.String toString()
          Turns into printable output.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlowImpl

public FlowImpl(FlowKey key)
Initialize a new Flow

Parameters:
key - flow key that uniquely identifies this flow.
Method Detail

getFlowKey

public FlowKey getFlowKey()
Returns the Flow key for this flow. A flow key uniquely identifies a particular flow.

Specified by:
getFlowKey in interface Flow
Returns:
the flow key for this flow.

getLeftPackets

public java.util.List getLeftPackets()
Returns a list of LEFT packets

Specified by:
getLeftPackets in interface Flow
Returns:
A list of all the LEFT packets in this flow.

getRightPackets

public java.util.List getRightPackets()
Returns a list of RIGHT packets

Specified by:
getRightPackets in interface Flow
Returns:
A list of all the RIGHT packets in this flow.

getPackets

public java.util.List getPackets()
Returns a list of packets in their original sequence.

Specified by:
getPackets in interface Flow
Returns:
A list of all packets in this flow.

getPacketCount

public int getPacketCount()
Returns the number of total packets in this flow.

Specified by:
getPacketCount in interface Flow
Returns:
number of packets in this flow.

equals

public boolean equals(java.lang.Object key)
Compares the FlowKeys between this flow and one being compared to.

Overrides:
equals in class java.lang.Object
Parameters:
key - Flow key to compare against.
Returns:
true if our flowkey is equivelent to the key being compared to. False for any other condition including if key is not of FlowKey type.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

addLeftPacket

public void addLeftPacket(Packet packet)
Adds a given packet to this flow.

Specified by:
addLeftPacket in interface Flow
Parameters:
packet - The packet to add to the flow.

addRightPacket

public void addRightPacket(Packet packet)
Adds a given packet to this flow.

Specified by:
addRightPacket in interface Flow
Parameters:
packet - The packet to add to the flow.

setExpireTimeout

public void setExpireTimeout(long time)
Sets the time from now when this flow is to be expired.

Parameters:
time - the time when this flow should be expired.

getExpireTimeout

public long getExpireTimeout()
Returns the time when this flow needs to be expired.

Returns:
the time when this flow should be retired.

resetExpireTimeout

public void resetExpireTimeout()

toString

public java.lang.String toString()
Description copied from interface: Flow
Turns into printable output. Summary of all packets are added as well. Packets summaries are grouped by the packet direction.

Specified by:
toString in interface Flow
Overrides:
toString in class java.lang.Object
Returns:
String representation of the flow.

getSummaryLine

public java.lang.String getSummaryLine()
Description copied from interface: Flow
Returns a terse summary string of this flow.

Specified by:
getSummaryLine in interface Flow
Returns:
String with summary information about this flow.