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
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
Modifier and Type Method Description 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 ifnextEvents()
ornextStep()
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 Details
-
readAll
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
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
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
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
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingnextEvents()
ornextStep()
. Once begin() has been called, you must finish the reading process usingend()
. You cannot call begin() twice without having calledend()
in between.- Parameters:
fileName
- Name of the file to read.- Throws:
IOException
- If an I/O error occurs while reading.
-
begin
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingnextEvents()
ornextStep()
. Once begin() has been called, you must finish the reading process usingend()
. You cannot call begin() twice without having calledend()
in between.- Parameters:
url
- The URL of the file to read.- Throws:
IOException
- If an I/O error occurs while reading.
-
begin
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingnextEvents()
ornextStep()
. Once begin() has been called, you must finish the reading process usingend()
. You cannot call begin() twice without having calledend()
in between.- Parameters:
stream
- The input stream to use for reading.- Throws:
IOException
- If an I/O error occurs while reading.
-
begin
Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingnextEvents()
ornextStep()
. Once begin() has been called, you must finish the reading process usingend()
. You cannot call begin() twice without having calledend()
in between.- Parameters:
reader
- The file reader to use.- Throws:
IOException
- If an I/O error occurs while reading.
-
nextEvents
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 calledbegin(InputStream)
orbegin(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
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
Finish the reading process (even ifnextEvents()
ornextStep()
did not returned false). You must call this method after reading.- Throws:
IOException
- If an I/O error occurs while closing the file.
-