org.graphstream.stream.file
Class FileSinkBase

java.lang.Object
  extended by org.graphstream.stream.file.FileSinkBase
All Implemented Interfaces:
AttributeSink, ElementSink, FileSink, Sink
Direct Known Subclasses:
FileSinkDGS, FileSinkDOT, FileSinkGEXF, FileSinkGML, FileSinkGraphML, FileSinkSVG, FileSinkTikZ

public abstract class FileSinkBase
extends Object
implements FileSink

Base implementation for graph output to files.

This class provides base services to write graphs into files using a specific file format. It allows to create an output stream. By default a print stream for easy text output, but binary files are possible.

It handles completely the writeAll(Graph, OutputStream), writeAll(Graph, String), begin(OutputStream), begin(String), flush() and end() methods. You should not have to modify or override these.

In order to implement an output you have to:


Constructor Summary
FileSinkBase()
           
 
Method Summary
 void begin(OutputStream stream)
          Begin the output of the given stream of graph events.
 void begin(String fileName)
          Begin the output of the given stream of graph events.
 void begin(Writer writer)
          Begin the output of the given stream of graph events.
 void end()
          End the writing process started with FileSink.begin(OutputStream) or FileSink.begin(String).
 void flush()
          Ensure all data sent to the output are correctly written.
 void writeAll(Graph graph, OutputStream stream)
          Write the current graph state in one big non-interruptible operation.
 void writeAll(Graph graph, String fileName)
          Write the current graph state in one big non-interruptible operation.
 void writeAll(Graph graph, Writer writer)
          Write the current graph state in one big non-interruptible operation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.graphstream.stream.AttributeSink
edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, nodeAttributeAdded, nodeAttributeChanged, nodeAttributeRemoved
 
Methods inherited from interface org.graphstream.stream.ElementSink
edgeAdded, edgeRemoved, graphCleared, nodeAdded, nodeRemoved, stepBegins
 

Constructor Detail

FileSinkBase

public FileSinkBase()
Method Detail

writeAll

public void writeAll(Graph graph,
                     String fileName)
              throws IOException
Description copied from interface: FileSink
Write the current graph state in one big non-interruptible operation. This operation is a "snapshot" of the graph, it will never convey the dynamics of the graph. To ensure you store the graph "as it evolves in time" you must use the FileSink.begin(OutputStream) or FileSink.begin(String) as soon as the graph appears (or any source of graph event, any descendant of Source will do).

Specified by:
writeAll in interface FileSink
Parameters:
graph - The graph to send as events to the file.
fileName - Name of the file to write.
Throws:
IOException - if an I/O error occurs while writing.

writeAll

public void writeAll(Graph graph,
                     OutputStream stream)
              throws IOException
Description copied from interface: FileSink
Write the current graph state in one big non-interruptible operation. This operation is a "snapshot" of the graph, it will never convey the dynamics of the graph. To ensure you store the graph "as it evolves in time" you must use the FileSink.begin(Writer) or FileSink.begin(OutputStream) or FileSink.begin(String) as soon as the graph appears (or any source of graph event, any descendant of Source will do).

Specified by:
writeAll in interface FileSink
Parameters:
graph - The graph to send as events to the file.
stream - The stream where the graph is sent.
Throws:
IOException - if an I/O error occurs while writing.

writeAll

public void writeAll(Graph graph,
                     Writer writer)
              throws IOException
Description copied from interface: FileSink
Write the current graph state in one big non-interruptible operation. This operation is a "snapshot" of the graph, it will never convey the dynamics of the graph. To ensure you store the graph "as it evolves in time" you must use the FileSink.begin(Writer) or FileSink.begin(OutputStream) or FileSink.begin(String) as soon as the graph appears (or any source of graph event, any descendant of Source will do).

Specified by:
writeAll in interface FileSink
Parameters:
graph - The graph to send as events to the file.
writer - The writer where the graph is sent.
Throws:
IOException - if an I/O error occurs while writing.

begin

public void begin(String fileName)
           throws IOException
Description copied from interface: FileSink
Begin the output of the given stream of graph events. The graph events can come from any input (implementation of Source or you can directly use the methods inherited from Sink. Once the writing is started using begin(), you must close it using FileSink.end() when done to ensure data is correctly stored in the file.

Specified by:
begin in interface FileSink
Parameters:
fileName - The name of the file where to output the graph events.
Throws:
IOException - If an I/O error occurs while writing.

begin

public void begin(OutputStream stream)
           throws IOException
Description copied from interface: FileSink
Begin the output of the given stream of graph events. The graph events can come from any input (implementation of Source or you can directly use the methods inherited from Sink. Once the writing is started using begin(), you must close it using FileSink.end() when done to ensure data is correctly stored in the file.

Specified by:
begin in interface FileSink
Parameters:
stream - The file stream where to output the graph events.
Throws:
IOException - If an I/O error occurs while writing.

begin

public void begin(Writer writer)
           throws IOException
Description copied from interface: FileSink
Begin the output of the given stream of graph events. The graph events can come from any input (implementation of Source or you can directly use the methods inherited from Sink. Once the writing is started using begin(), you must close it using FileSink.end() when done to ensure data is correctly stored in the file.

Specified by:
begin in interface FileSink
Parameters:
writer - The writer where to output the graph events.
Throws:
IOException - If an I/O error occurs while writing.

flush

public void flush()
           throws IOException
Description copied from interface: FileSink
Ensure all data sent to the output are correctly written.

Specified by:
flush in interface FileSink
Throws:
IOException - If an I/O error occurs during write.

end

public void end()
         throws IOException
Description copied from interface: FileSink
End the writing process started with FileSink.begin(OutputStream) or FileSink.begin(String).

Specified by:
end in interface FileSink
Throws:
IOException


Copyright © 2013. All Rights Reserved.