fi.helsinki.dacopan.model
Class DefaultDataView

java.lang.Object
  extended by fi.helsinki.dacopan.model.DefaultDataView
All Implemented Interfaces:
DataView

public class DefaultDataView
extends java.lang.Object
implements DataView

Default DataView implementation.

Note: this class is not thread-safe, it should be populated once and thereafter it can be accessed by multiple concurrent threads.

Version:
$Id: DefaultDataView.java,v 1.21 2005/04/06 16:54:25 pamietti Exp $

Field Summary
protected  java.util.Map endTimes
          cached values for end times of each layer
protected  java.util.Map flows
          flows by id
protected  java.util.Map hosts
          hosts by id
protected  java.util.Map layers
          layers by id
protected  java.util.Map layersToUnits
          maps layers to lists of units on that level
protected  java.util.Map links
          links by id
protected  java.util.Map protocols
          protocols by id
protected  float scenarioEndTime
          end time of the whole scenario
protected  java.util.Map units
          all the transfer units by id
protected  java.util.Map variableLengths
          maps variable definitions to the maximum lengths of their values
 
Constructor Summary
DefaultDataView()
           
 
Method Summary
 void addFlow(Flow flow)
          Adds the given flow to this view.
 void addHost(Host host)
          Adds the given host to this view.
 void addLayer(Layer layer)
          Adds the given layer to this view.
 void addLink(Link link)
          Adds the given link to this view.
 void addProtocol(Protocol protocol)
          Adds the given protocol to this view.
 void addTransferUnit(TransferUnit unit, boolean recurse)
          Adds a transfer unit to the view.
 boolean equals(java.lang.Object o)
          Mostly for unit testing purposes, does huge amounts of comparisons.
 java.util.List getAvailableVariables(Layer layer)
          Returns a list of all the available variables (those that have values longer than zero characters) on the specified layer.
 float getEndTime()
          Returns the end time of the network exchange data, as the timestamp of the last event included in the data, regardless of the type of event, layer etc.
 float getEndTimeForLayer(Layer layer)
          Returns the end time of the network exchange data for a particular layer, as the timestamp of the last event in the layer.
 Flow getFlowById(long id)
          Returns the flow by the given id, if any.
 java.util.List getFlows()
          Returns all the flows present in the scenario.
 Host getHostById(long id)
          Returns the host by the id.
 java.util.List getHosts()
          Returns all the hosts present in the scenario.
 Layer getLayerById(long id)
          Returns the layer with the given id.
 java.util.List getLayers()
          Returns all the layers present in the scenario, ordered from lower to higher.
 Link getLinkById(long id)
          Returns the link with the given id, if any.
 java.util.List getLinks()
          Returns a list of all the links in the scenario.
protected  java.util.List getOrCreateUnitList(TransferUnit unit)
          Gets the unit list for the layer of the specified unit, creates a new list if none exists.
 Protocol getProtocolById(long id)
          Returns the protocol with the given id, if any.
 java.util.List getProtocols()
          Returns all the protocols present.
 StepIterator getStepIterator(Layer layer)
          Returns an iterator for the steps on the specified layer.
 TransferUnit getUnitById(long id)
          Returns the transfer unit with the given id, if any.
 java.util.List getUnitsForLayer(Layer layer)
          Returns a sorted list of all the units in the given layer.
 java.util.List getUnitsForLayer(Layer layer, float start, float end)
          Returns a collection of all the units in the given layer between the given timestamps (inclusive).
 int getValueMaxLength(VariableDefinition def)
          Returns the maximum length of all the values of the given variable.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hosts

protected java.util.Map hosts
hosts by id


flows

protected java.util.Map flows
flows by id


links

protected java.util.Map links
links by id


layers

protected java.util.Map layers
layers by id


protocols

protected java.util.Map protocols
protocols by id


units

protected java.util.Map units
all the transfer units by id


layersToUnits

protected java.util.Map layersToUnits
maps layers to lists of units on that level


endTimes

protected java.util.Map endTimes
cached values for end times of each layer


scenarioEndTime

protected float scenarioEndTime
end time of the whole scenario


variableLengths

protected java.util.Map variableLengths
maps variable definitions to the maximum lengths of their values

Constructor Detail

DefaultDataView

public DefaultDataView()
Method Detail

getOrCreateUnitList

protected java.util.List getOrCreateUnitList(TransferUnit unit)
Gets the unit list for the layer of the specified unit, creates a new list if none exists.


addHost

public void addHost(Host host)
Description copied from interface: DataView
Adds the given host to this view.

Specified by:
addHost in interface DataView

addFlow

public void addFlow(Flow flow)
Description copied from interface: DataView
Adds the given flow to this view.

Specified by:
addFlow in interface DataView

addLink

public void addLink(Link link)
Description copied from interface: DataView
Adds the given link to this view.

Specified by:
addLink in interface DataView

addLayer

public void addLayer(Layer layer)
Description copied from interface: DataView
Adds the given layer to this view.

Specified by:
addLayer in interface DataView

addProtocol

public void addProtocol(Protocol protocol)
Description copied from interface: DataView
Adds the given protocol to this view.

Specified by:
addProtocol in interface DataView

addTransferUnit

public void addTransferUnit(TransferUnit unit,
                            boolean recurse)
Description copied from interface: DataView
Adds a transfer unit to the view. If recurse is true, the method will recurse to the children of the unit and add them to the view as well.

Specified by:
addTransferUnit in interface DataView
Parameters:
unit - to add
recurse - whether to recurse

getUnitsForLayer

public java.util.List getUnitsForLayer(Layer layer)
Description copied from interface: DataView
Returns a sorted list of all the units in the given layer.

Specified by:
getUnitsForLayer in interface DataView
Parameters:
layer - whose units to return

getUnitsForLayer

public java.util.List getUnitsForLayer(Layer layer,
                                       float start,
                                       float end)
Description copied from interface: DataView
Returns a collection of all the units in the given layer between the given timestamps (inclusive).

Specified by:
getUnitsForLayer in interface DataView
Parameters:
layer - whose units to return
start - timestamps
end - timestamps

getUnitById

public TransferUnit getUnitById(long id)
Description copied from interface: DataView
Returns the transfer unit with the given id, if any.

Specified by:
getUnitById in interface DataView

getHosts

public java.util.List getHosts()
Description copied from interface: DataView
Returns all the hosts present in the scenario.

Specified by:
getHosts in interface DataView

getHostById

public Host getHostById(long id)
Description copied from interface: DataView
Returns the host by the id.

Specified by:
getHostById in interface DataView

getFlows

public java.util.List getFlows()
Description copied from interface: DataView
Returns all the flows present in the scenario.

Specified by:
getFlows in interface DataView

getFlowById

public Flow getFlowById(long id)
Description copied from interface: DataView
Returns the flow by the given id, if any.

Specified by:
getFlowById in interface DataView

getLayers

public java.util.List getLayers()
Description copied from interface: DataView
Returns all the layers present in the scenario, ordered from lower to higher. (for instance Network -> Transport -> Application)

Specified by:
getLayers in interface DataView

getLayerById

public Layer getLayerById(long id)
Description copied from interface: DataView
Returns the layer with the given id.

Specified by:
getLayerById in interface DataView

getProtocols

public java.util.List getProtocols()
Description copied from interface: DataView
Returns all the protocols present.

Specified by:
getProtocols in interface DataView

getProtocolById

public Protocol getProtocolById(long id)
Description copied from interface: DataView
Returns the protocol with the given id, if any.

Specified by:
getProtocolById in interface DataView

getLinks

public java.util.List getLinks()
Description copied from interface: DataView
Returns a list of all the links in the scenario.

Specified by:
getLinks in interface DataView

getLinkById

public Link getLinkById(long id)
Description copied from interface: DataView
Returns the link with the given id, if any.

Specified by:
getLinkById in interface DataView

getValueMaxLength

public int getValueMaxLength(VariableDefinition def)
Description copied from interface: DataView
Returns the maximum length of all the values of the given variable.

Specified by:
getValueMaxLength in interface DataView

getAvailableVariables

public java.util.List getAvailableVariables(Layer layer)
Description copied from interface: DataView
Returns a list of all the available variables (those that have values longer than zero characters) on the specified layer.

Specified by:
getAvailableVariables in interface DataView

getStepIterator

public StepIterator getStepIterator(Layer layer)
Description copied from interface: DataView
Returns an iterator for the steps on the specified layer.

Specified by:
getStepIterator in interface DataView
Parameters:
layer - to step thru
Returns:
iterator for stepping

getEndTime

public float getEndTime()
Description copied from interface: DataView
Returns the end time of the network exchange data, as the timestamp of the last event included in the data, regardless of the type of event, layer etc.

Specified by:
getEndTime in interface DataView

getEndTimeForLayer

public float getEndTimeForLayer(Layer layer)
Description copied from interface: DataView
Returns the end time of the network exchange data for a particular layer, as the timestamp of the last event in the layer.

Specified by:
getEndTimeForLayer in interface DataView

equals

public boolean equals(java.lang.Object o)
Mostly for unit testing purposes, does huge amounts of comparisons.

Overrides:
equals in class java.lang.Object


© Dacopan2 team, 2005-