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
  • 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

      public void readAll​(String fileName) throws IOException
      Description copied from interface: FileSource
      Read the whole file in one big non-interruptible operation.
      Specified by:
      readAll in interface FileSource
      Parameters:
      fileName - Name of the file to read.
      Throws:
      IOException - If an I/O error occurs while reading.
    • readAll

      public void readAll​(URL url) throws IOException
      Description copied from interface: FileSource
      Read the whole file in one big non-interruptible operation.
      Specified by:
      readAll in interface FileSource
      Parameters:
      url - The URL of the file to read.
      Throws:
      IOException - If an I/O error occurs while reading.
    • readAll

      public void readAll​(InputStream stream) throws IOException
      Description copied from interface: FileSource
      Read the whole file in one big non-interruptible operation.
      Specified by:
      readAll in interface FileSource
      Parameters:
      stream - The input stream to use for reading.
      Throws:
      IOException - If an I/O error occurs while reading.
    • readAll

      public void readAll​(Reader reader) throws IOException
      Description copied from interface: FileSource
      Read the whole file in one big non-interruptible operation.
      Specified by:
      readAll in interface FileSource
      Parameters:
      reader - The reader to use.
      Throws:
      IOException - If an I/O error occurs while reading.
    • begin

      public void begin​(String fileName) throws IOException
      Description copied from interface: FileSource
      Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling 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.
      Specified by:
      begin in interface FileSource
      Parameters:
      fileName - Name of the file to read.
      Throws:
      IOException - If an I/O error occurs while reading.
    • begin

      public void begin​(URL url) throws IOException
      Description copied from interface: FileSource
      Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling 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.
      Specified by:
      begin in interface FileSource
      Parameters:
      url - The URL of the file to read.
      Throws:
      IOException - If an I/O error occurs while reading.
    • begin

      public void begin​(InputStream stream) throws IOException
      Description copied from interface: FileSource
      Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling 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.
      Specified by:
      begin in interface FileSource
      Parameters:
      stream - The input stream to use for reading.
      Throws:
      IOException - If an I/O error occurs while reading.
    • begin

      public void begin​(Reader reader) throws IOException
      Description copied from interface: FileSource
      Begin reading the file stopping as soon as possible. Next graph events stored in the file will be sent by calling 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.
      Specified by:
      begin in interface FileSource
      Parameters:
      reader - The file reader to use.
      Throws:
      IOException - If an I/O error occurs while reading.
    • nextEvents

      public abstract boolean nextEvents() throws IOException
      Description copied from interface: FileSource
      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 FileSource.begin(InputStream) or FileSource.begin(String) before. This method return true while there are still events to read.
      Specified by:
      nextEvents in interface FileSource
      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

      public boolean nextStep() throws IOException
      Description copied from interface: FileSource
      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.
      Specified by:
      nextStep in interface FileSource
      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

      public void end() throws IOException
      Description copied from interface: FileSource
      Finish the reading process (even if FileSource.nextEvents() or FileSource.nextStep() did not returned false). You must call this method after reading.
      Specified by:
      end in interface FileSource
      Throws:
      IOException - If an I/O error occurs while closing the file.