org.graphstream.stream.file
Interface FileSource

All Superinterfaces:
Source
All Known Implementing Classes:
FileSourceBase, FileSourceDGS, FileSourceDGS1And2, FileSourceDOT, FileSourceEdge, FileSourceGEXF, FileSourceGML, FileSourceGPX, FileSourceGraphML, FileSourceLGL, FileSourceNCol, FileSourcePajek, FileSourceParser, FileSourceTLP, FileSourceXML, OldFileSourceDGS

public interface FileSource
extends Source

Source of graph events coming from a file.

The file input interface is an input with specific methods that deals with files. File inputs are designed to handle graphs stored under the form of a textual or binary file either under the form of a file name or a Java input stream. If the file comes from an URL, convert the URL to an input stream.

The file package is designed under the idea that it provides graph inputs from files that store the graph under a given file format and encoding. The package provides decoders for all these formats.

Do not confuse the file package with the net package that can also read from URLs, but build graph not from encoded description of a graph, but from web services like Flickr or Amazon, or simply networks of web pages tied by web links. The graph construction task is entirely different.

Although not all graph format handle dynamic graphs, all file inputs must provide both the readAll() and begin()/nextEvents()/end() methods. The later must read one graph modification at a time.


Method Summary
 void begin(InputStream stream)
          Begin reading the file stopping as soon as possible.
 void begin(Reader reader)
          Begin reading the file stopping as soon as possible.
 void begin(String fileName)
          Begin reading the file stopping as soon as possible.
 void begin(URL url)
          Begin reading the file stopping as soon as possible.
 void end()
          Finish the reading process (even if nextEvents() or nextStep() did not returned false).
 boolean nextEvents()
          Try to process one graph event, or as few as possible, if more must be read at once.
 boolean nextStep()
          Try to process all the events occurring during one time step.
 void readAll(InputStream stream)
          Read the whole file in one big non-interruptible operation.
 void readAll(Reader reader)
          Read the whole file in one big non-interruptible operation.
 void readAll(String fileName)
          Read the whole file in one big non-interruptible operation.
 void readAll(URL url)
          Read the whole file in one big non-interruptible operation.
 
Methods inherited from interface org.graphstream.stream.Source
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
 

Method Detail

readAll

void readAll(String fileName)
             throws IOException
Read the whole file in one big non-interruptible operation.

Parameters:
fileName - Name of the file to read.
Throws:
IOException - If an I/O error occurs while reading.

readAll

void readAll(URL url)
             throws IOException
Read the whole file in one big non-interruptible operation.

Parameters:
url - The URL of the file to read.
Throws:
IOException - If an I/O error occurs while reading.

readAll

void readAll(InputStream stream)
             throws IOException
Read the whole file in one big non-interruptible operation.

Parameters:
stream - The input stream to use for reading.
Throws:
IOException - If an I/O error occurs while reading.

readAll

void readAll(Reader reader)
             throws IOException
Read the whole file in one big non-interruptible operation.

Parameters:
reader - The reader to use.
Throws:
IOException - If an I/O error occurs while reading.

begin

void begin(String fileName)
           throws IOException
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling nextEvents() or nextStep(). Once begin() has been called, you must finish the reading process using end(). You cannot call begin() twice without having called end() in between.

Parameters:
fileName - Name of the file to read.
Throws:
IOException - If an I/O error occurs while reading.

begin

void begin(URL url)
           throws IOException
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling nextEvents() or nextStep(). Once begin() has been called, you must finish the reading process using end(). You cannot call begin() twice without having called end() in between.

Parameters:
url - The URL of the file to read.
Throws:
IOException - If an I/O error occurs while reading.

begin

void begin(InputStream stream)
           throws IOException
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling nextEvents() or nextStep(). Once begin() has been called, you must finish the reading process using end(). You cannot call begin() twice without having called end() in between.

Parameters:
stream - The input stream to use for reading.
Throws:
IOException - If an I/O error occurs while reading.

begin

void begin(Reader reader)
           throws IOException
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling nextEvents() or nextStep(). Once begin() has been called, you must finish the reading process using end(). You cannot call begin() twice without having called end() in between.

Parameters:
reader - The file reader to use.
Throws:
IOException - If an I/O error occurs while reading.

nextEvents

boolean nextEvents()
                   throws IOException
Try to process one graph event, or as few as possible, if more must be read at once. For this method to work, you must have called begin(InputStream) or begin(String) before. This method return true while there are still events to read.

Returns:
true if there are still events to read, false as soon as the file is finished.
Throws:
IOException - If an I/O error occurs while reading.

nextStep

boolean nextStep()
                 throws IOException
Try to process all the events occurring during one time step. In GraphStream, a time step is a group of events that are considered occurring at the same time. Most file formats do not have this notion of step. The DGS format designed for GraphStream handles steps. This method return true while there are still events to read.

Returns:
true if there are still events to read, false as soon as the file is finished.
Throws:
IOException - If an I/O error occurs while reading.

end

void end()
         throws IOException
Finish the reading process (even if nextEvents() or nextStep() did not returned false). You must call this method after reading.

Throws:
IOException - If an I/O error occurs while closing the file.


Copyright © 2012. All Rights Reserved.