Package org.graphstream.stream.file
Class FileSourceXML
java.lang.Object
org.graphstream.stream.SourceBase
org.graphstream.stream.file.FileSourceXML
- All Implemented Interfaces:
XMLStreamConstants,FileSource,Source
- Direct Known Subclasses:
FileSourceGEXF,FileSourceGPX,FileSourceGraphML
public abstract class FileSourceXML extends SourceBase implements FileSource, XMLStreamConstants
Base for XML-based file format. It uses an xml events stream (
javax.xml.stream). One who want to define a new xml-based fiel source
has to define actions after the document start and before the document end.
The nextEvents(), called between start and end, has to be defined
too.- Author:
- Guilhelm Savin
-
Nested Class Summary
Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase
SourceBase.ElementType -
Field Summary
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT -
Method Summary
Modifier and Type Method Description voidbegin(InputStream stream)Begin reading the file stopping as soon as possible.voidbegin(Reader reader)Begin reading the file stopping as soon as possible.voidbegin(String fileName)Begin reading the file stopping as soon as possible.voidbegin(URL url)Begin reading the file stopping as soon as possible.voidend()Finish the reading process (even ifFileSource.nextEvents()orFileSource.nextStep()did not returned false).booleanisStrictMode()If strict mode is enabled, will produce errors while encountering unexpected attributes or elements.abstract booleannextEvents()Try to process one graph event, or as few as possible, if more must be read at once.booleannextStep()Try to process all the events occurring during one time step.voidreadAll(InputStream stream)Read the whole file in one big non-interruptible operation.voidreadAll(Reader reader)Read the whole file in one big non-interruptible operation.voidreadAll(String fileName)Read the whole file in one big non-interruptible operation.voidreadAll(URL url)Read the whole file in one big non-interruptible operation.voidsetStrictMode(boolean strictMode)Methods inherited from class org.graphstream.stream.SourceBase
addAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, 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, sendStepBeginsMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.graphstream.stream.Source
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
-
Method Details
-
isStrictMode
public boolean isStrictMode()If strict mode is enabled, will produce errors while encountering unexpected attributes or elements. This is enabled by default.- Returns:
- true if strict mode is enabled
-
setStrictMode
public void setStrictMode(boolean strictMode) -
readAll
Description copied from interface:FileSourceRead the whole file in one big non-interruptible operation.- Specified by:
readAllin interfaceFileSource- Parameters:
fileName- Name of the file to read.- Throws:
IOException- If an I/O error occurs while reading.
-
readAll
Description copied from interface:FileSourceRead the whole file in one big non-interruptible operation.- Specified by:
readAllin interfaceFileSource- Parameters:
url- The URL of the file to read.- Throws:
IOException- If an I/O error occurs while reading.
-
readAll
Description copied from interface:FileSourceRead the whole file in one big non-interruptible operation.- Specified by:
readAllin interfaceFileSource- Parameters:
stream- The input stream to use for reading.- Throws:
IOException- If an I/O error occurs while reading.
-
readAll
Description copied from interface:FileSourceRead the whole file in one big non-interruptible operation.- Specified by:
readAllin interfaceFileSource- Parameters:
reader- The reader to use.- Throws:
IOException- If an I/O error occurs while reading.
-
begin
Description copied from interface:FileSourceBegin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingFileSource.nextEvents()orFileSource.nextStep(). Once begin() has been called, you must finish the reading process usingFileSource.end(). You cannot call begin() twice without having calledFileSource.end()in between.- Specified by:
beginin interfaceFileSource- Parameters:
fileName- Name of the file to read.- Throws:
IOException- If an I/O error occurs while reading.
-
begin
Description copied from interface:FileSourceBegin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingFileSource.nextEvents()orFileSource.nextStep(). Once begin() has been called, you must finish the reading process usingFileSource.end(). You cannot call begin() twice without having calledFileSource.end()in between.- Specified by:
beginin interfaceFileSource- Parameters:
url- The URL of the file to read.- Throws:
IOException- If an I/O error occurs while reading.
-
begin
Description copied from interface:FileSourceBegin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingFileSource.nextEvents()orFileSource.nextStep(). Once begin() has been called, you must finish the reading process usingFileSource.end(). You cannot call begin() twice without having calledFileSource.end()in between.- Specified by:
beginin interfaceFileSource- Parameters:
stream- The input stream to use for reading.- Throws:
IOException- If an I/O error occurs while reading.
-
begin
Description copied from interface:FileSourceBegin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by callingFileSource.nextEvents()orFileSource.nextStep(). Once begin() has been called, you must finish the reading process usingFileSource.end(). You cannot call begin() twice without having calledFileSource.end()in between.- Specified by:
beginin interfaceFileSource- Parameters:
reader- The file reader to use.- Throws:
IOException- If an I/O error occurs while reading.
-
nextEvents
Description copied from interface:FileSourceTry 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 calledFileSource.begin(InputStream)orFileSource.begin(String)before. This method return true while there are still events to read.- Specified by:
nextEventsin interfaceFileSource- 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
Description copied from interface:FileSourceTry 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.- Specified by:
nextStepin interfaceFileSource- 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
Description copied from interface:FileSourceFinish the reading process (even ifFileSource.nextEvents()orFileSource.nextStep()did not returned false). You must call this method after reading.- Specified by:
endin interfaceFileSource- Throws:
IOException- If an I/O error occurs while closing the file.
-