Class BinarySimulationReader<U extends java.io.Serializable,I extends java.io.Serializable,P>
java.lang.Object
es.uam.eps.ir.relison.diffusion.io.backup.BinarySimulationReader<U,I,P>
- Type Parameters:
U
- Type of the users.I
- Type of the information pieces.P
- Type of the parameters.
- All Implemented Interfaces:
SimulationReader<U,I,P>
public class BinarySimulationReader<U extends java.io.Serializable,I extends java.io.Serializable,P> extends java.lang.Object implements SimulationReader<U,I,P>
Reads a simulation from a file. Data is retrieved using binary fields,
which contain the identifiers of each object.
-
Field Summary
Fields Modifier and Type Field Description private java.io.DataInputStream
ois
Object input stream for reading into file. -
Constructor Summary
Constructors Constructor Description BinarySimulationReader()
-
Method Summary
Modifier and Type Method Description boolean
close()
Closes the writing objects.boolean
initialize(java.lang.String file)
Initializes the simulation writing.Iteration<U,I,P>
readIteration(Data<U,I,P> data)
Writes a single iteration in a file.private java.util.Map<U,java.util.Map<I,java.util.Set<U>>>
readReceivedPiecesField(Data<U,I,P> data)
Reads a particular field concerning received data by users.Simulation<U,I,P>
readSimulation(Data<U,I,P> data)
Reads a simulation from a file.private java.util.Map<U,java.util.List<I>>
readUserActionField(Data<U,I,P> data)
Reads a particular field concerning actions made by the users.
-
Field Details
-
ois
private java.io.DataInputStream oisObject input stream for reading into file.
-
-
Constructor Details
-
BinarySimulationReader
public BinarySimulationReader()
-
-
Method Details
-
initialize
public boolean initialize(java.lang.String file)Description copied from interface:SimulationReader
Initializes the simulation writing.- Specified by:
initialize
in interfaceSimulationReader<U extends java.io.Serializable,I extends java.io.Serializable,P>
- Parameters:
file
- the name of the file where we want to store the simulation.- Returns:
- true if everything went OK, false if something failed while configuring the writer.
-
readSimulation
Description copied from interface:SimulationReader
Reads a simulation from a file.- Specified by:
readSimulation
in interfaceSimulationReader<U extends java.io.Serializable,I extends java.io.Serializable,P>
- Parameters:
data
- the simulation data.- Returns:
- the simulation if everything went OK, null if not.
-
readIteration
Description copied from interface:SimulationReader
Writes a single iteration in a file.- Specified by:
readIteration
in interfaceSimulationReader<U extends java.io.Serializable,I extends java.io.Serializable,P>
- Parameters:
data
- the simulation data.- Returns:
- true if everything went OK, false if something failed while writing.
-
close
public boolean close()Description copied from interface:SimulationReader
Closes the writing objects.- Specified by:
close
in interfaceSimulationReader<U extends java.io.Serializable,I extends java.io.Serializable,P>
- Returns:
- true if everything went OK, false if something failed while deconfiguring the writer.
-
readReceivedPiecesField
private java.util.Map<U,java.util.Map<I,java.util.Set<U>>> readReceivedPiecesField(Data<U,I,P> data)Reads a particular field concerning received data by users.- Parameters:
data
- the data.- Returns:
- a mapping between users and information pieces whole information, null if something went wrong.
-
readUserActionField
Reads a particular field concerning actions made by the users.- Parameters:
data
- the data.- Returns:
- a mapping between users and information pieces, null if something went wrong.
-