public class FileSourceEdge extends FileSourceBase
The edge graph format is a very simple and lightweight format where each line describes an edge by giving two node names. The nodes are created implicitly.
This reader also understands the derivative format where a line contains a first node name, followed by several node names separated by spaces. In this case it links the first node with all other node name following on the line.
Also, the format does not specify any direction for edges. By default all
edges are undirected. You can choose to make all edges directed by passing
"true" as the first arguments to constructors
FileSourceEdge(boolean)
or FileSourceEdge(boolean, boolean)
. The direction of edges goes from the first node name on each line toward
the second (or more) node names on each line.
This format only contains edges. To ensure the "add node" events are sent before an edge referencing two nodes is created via an "add edge" event, this reader has a hash set of already encountered nodes. The hash set allows to issue "add node" events only when a node is encountered for the first time.
This hash set consumes memory, but is the only way to ensure "add node" events are correctly issued. If this input is directly connected to a graph, as graphs can create non-existing nodes automatically, you can disable the hash set of nodes using the constructorFileSourceEdge(boolean, boolean)
, and giving "false" for the second
argument.
The usual file name extension for this format is ".edge".FileSourceBase.CurrentFile
SourceBase.ElementType
Modifier and Type | Field and Description |
---|---|
protected boolean |
directed
By default, consider edges as undirected.
|
protected int |
edgeid
Allocator for edge identifiers.
|
protected String |
graphName |
protected HashSet<String> |
nodes
Set of existing nodes (if nodes are declared).
|
attribute_classes, COMMENT_CHAR, eol_is_significant, filename, QUOTE_CHAR, st, tok_stack
attrSinks, eltsSinks, eventProcessing, eventQueue, sourceId, sourceTime
Constructor and Description |
---|
FileSourceEdge()
New reader for the "edge" format.
|
FileSourceEdge(boolean edgesAreDirected)
New reader for the "edge" format.
|
FileSourceEdge(boolean edgesAreDirected,
boolean declareNodes)
New reader for the "edge" format.
|
Modifier and Type | Method and 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.
|
protected void |
continueParsingInInclude()
Must be implemented to read the content of an include.
|
protected void |
declareNode(String id) |
void |
end()
Finish the reading process (even if
FileSource.nextEvents() or
FileSource.nextStep() did not returned false). |
protected void |
init() |
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.
|
addAttributeClass, configureTokenizer, createReaderFrom, createReaderFrom, eatAllEols, eatAllUntilEol, eatEof, eatEol, eatEolOrEof, eatOneOfTwoWords, eatSymbol, eatSymbolOrPushback, eatSymbols, eatWord, eatWordOrPushbak, eatWords, getAllExceptedEof, getBoolean, getInteger, getNumber, getNumberExp, getPoint3, getReal, getString, getStringOrNumber, getStringOrWordOrNumber, getStringOrWordOrNumberO, getStringOrWordOrNumberOrPushback, getStringOrWordOrSymbolOrNumberO, getSymbol, getSymbolOrPushback, getWord, getWordOrNumber, getWordOrNumberOrStringOrEolOrEof, getWordOrString, getWordOrStringOrEolOrEof, getWordOrSymbol, getWordOrSymbolOrEof, getWordOrSymbolOrNumberOrStringOrEolOrEof, getWordOrSymbolOrPushback, getWordOrSymbolOrString, getWordOrSymbolOrStringOrEolOrEof, gotWhat, include, isFalse, isTrue, parseError, popTokenizer, pushBack, pushTokenizer, pushTokenizer, pushTokenizer, pushTokenizer, pushTokenizer, readAll, readAll, readAll, readAll
addAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, manageEvents, removeAttributeSink, removeElementSink, removeSink, sendAttributeChangedEvent, sendAttributeChangedEvent, sendEdgeAdded, sendEdgeAdded, sendEdgeAttributeAdded, sendEdgeAttributeAdded, sendEdgeAttributeChanged, sendEdgeAttributeChanged, sendEdgeAttributeRemoved, sendEdgeAttributeRemoved, sendEdgeRemoved, sendEdgeRemoved, sendGraphAttributeAdded, sendGraphAttributeAdded, sendGraphAttributeChanged, sendGraphAttributeChanged, sendGraphAttributeRemoved, sendGraphAttributeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeAttributeAdded, sendNodeAttributeAdded, sendNodeAttributeChanged, sendNodeAttributeChanged, sendNodeAttributeRemoved, sendNodeAttributeRemoved, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBegins
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
protected int edgeid
protected boolean directed
public FileSourceEdge()
public FileSourceEdge(boolean edgesAreDirected)
edgesAreDirected
- If true (default=false) edges are considered directed.public FileSourceEdge(boolean edgesAreDirected, boolean declareNodes)
edgesAreDirected
- If true (default=false) edges are considered directed.declareNodes
- If true (default=true) this reader outputs nodeAdded events.protected void continueParsingInInclude() throws IOException
FileSourceBase
continueParsingInInclude
in class FileSourceBase
IOException
public boolean nextEvents() throws IOException
FileSource
FileSource.begin(InputStream)
or FileSource.begin(String)
before. This method
return true while there are still events to read.nextEvents
in interface FileSource
nextEvents
in class FileSourceBase
IOException
- If an I/O error occurs while reading.protected void declareNode(String id)
public void begin(String filename) throws IOException
FileSource
FileSource.nextEvents()
or
FileSource.nextStep()
. Once begin() has been called, you must finish the
reading process using FileSource.end()
. You cannot call begin() twice
without having called FileSource.end()
in between.begin
in interface FileSource
begin
in class FileSourceBase
filename
- Name of the file to read.IOException
- If an I/O error occurs while reading.public void begin(URL url) throws IOException
FileSource
FileSource.nextEvents()
or
FileSource.nextStep()
. Once begin() has been called, you must finish the
reading process using FileSource.end()
. You cannot call begin() twice
without having called FileSource.end()
in between.begin
in interface FileSource
begin
in class FileSourceBase
url
- The URL of the file to read.IOException
- If an I/O error occurs while reading.public void begin(InputStream stream) throws IOException
FileSource
FileSource.nextEvents()
or
FileSource.nextStep()
. Once begin() has been called, you must finish the
reading process using FileSource.end()
. You cannot call begin() twice
without having called FileSource.end()
in between.begin
in interface FileSource
begin
in class FileSourceBase
stream
- The input stream to use for reading.IOException
- If an I/O error occurs while reading.public void begin(Reader reader) throws IOException
FileSource
FileSource.nextEvents()
or
FileSource.nextStep()
. Once begin() has been called, you must finish the
reading process using FileSource.end()
. You cannot call begin() twice
without having called FileSource.end()
in between.begin
in interface FileSource
begin
in class FileSourceBase
reader
- The file reader to use.IOException
- If an I/O error occurs while reading.protected void init() throws IOException
IOException
public boolean nextStep() throws IOException
FileSource
IOException
- If an I/O error occurs while reading.public void end() throws IOException
FileSource
FileSource.nextEvents()
or
FileSource.nextStep()
did not returned false). You must call this method
after reading.end
in interface FileSource
end
in class FileSourceBase
IOException
- If an I/O error occurs while closing the file.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses