Class GPMLFormat

java.lang.Object
org.pathvisio.libgpml.io.AbstractPathwayModelFormat
org.pathvisio.libgpml.model.GPMLFormat
All Implemented Interfaces:
PathwayModelExporter, PathwayModelImporter, PathwayModelIO

public class GPMLFormat
extends AbstractPathwayModelFormat
Class responsible for interaction with Gpml format. Contains all gpml-specific constants, and should be the only class (apart from svgFormat) that needs to import jdom.

NB:

  1. Static read methods, both current and previous gpml formats can be read.
  2. Pathways are saved/written in the current gpml format.
  3. Export allows writing to the previous gpml format.
Author:
unknown, finterly
  • Field Details

  • Constructor Details

    • GPMLFormat

      public GPMLFormat​(GPMLFormatWriter writer)
      Instantiates a GpmlFormat.
      Parameters:
      writer -
  • Method Details

    • doImport

      public PathwayModel doImport​(java.io.File file) throws ConverterException
      Description copied from interface: PathwayModelImporter
      Imports the pathway model from given file.
      Parameters:
      file - the file that contains pathway model information
      Returns:
      the result of the import, a fresh Pathway instance
      Throws:
      ConverterException - if the input file could not be read or parsed, or doesn't contain correct pathway information.
    • doExport

      public void doExport​(java.io.File file, PathwayModel pathwayModel) throws ConverterException
      Description copied from interface: PathwayModelExporter
      Exports the given pathway to the file
      Parameters:
      file - the file to export to
      pathwayModel - the pathway model to export
      Throws:
      ConverterException - when there is a fatal conversion problem. Implementations should only throw in case there is a non-recoverable error. Otherwise, it should emit a warning.
    • getExtensions

      public java.lang.String[] getExtensions()
      Description copied from interface: PathwayModelIO
      Get the possible extensions this importer/exporter can read (e.g. txt). The extensions do not have to be unique. In case two importers use the same extension, the correct one will be chosen based on the result of PathwayImporter.isCorrectFileType(). If that doesn't help, the user may be asked to pick an importer. The first item in the array is assumed to be the preferred extension.
      Returns:
      An array with the possible extensions (without '.')
    • getName

      public java.lang.String getName()
    • createJdom

      public org.jdom2.Document createJdom​(PathwayModel data) throws ConverterException
      Parameters:
      data -
      Returns:
      Throws:
      ConverterException
    • writeToXml

      public void writeToXml​(PathwayModel pathwayModel, java.io.File file, boolean validate) throws ConverterException
      Writes the JDOM document to the file specified
      Parameters:
      pathwayModel - the pathway model.
      file - the file to which the JDOM document should be saved
      validate - if true, validate the dom structure before writing to file. If there is a validation error, or the xsd is not in the classpath, an exception will be thrown.
      Throws:
      ConverterException
    • writeToXml

      public void writeToXml​(PathwayModel pathwayModel, java.io.OutputStream out, boolean validate) throws ConverterException
      Writes the pathway model to output stream.
      Parameters:
      pathwayModel - the pathway model.
      out - the file to which the JDOM document should be saved
      validate - if true, validate the dom structure before writing to file. If there is a validation error, or the xsd is not in the classpath, an exception will be thrown.
      Throws:
      ConverterException
    • readFromXml

      public static void readFromXml​(PathwayModel pathwayModel, java.io.File file, boolean validate) throws ConverterException
      Reads the JDOM document from the file specified
      Parameters:
      pathwayModel - the pathway model.
      file - the file from which the JDOM document should be read.
      validate - if true, validate the dom structure during/after reading.
      Throws:
      ConverterException
    • readFromXml

      public static void readFromXml​(PathwayModel pathwayModel, java.io.InputStream in, boolean validate) throws ConverterException
      Reads the JDOM document from the string specified
      Parameters:
      pathwayModel - the pathway model.
      in - the file from which the JDOM document should be read.
      validate - if true, validate the dom structure during/after reading.
      Throws:
      ConverterException
    • readFromXml

      public static void readFromXml​(PathwayModel pathwayModel, java.io.Reader in, boolean validate) throws ConverterException
      Reads the JDOM document from the string specified
      Parameters:
      pathwayModel - the pathway model.
      in - the file from which the JDOM document should be read.
      validate - if true, validate the dom structure during/after reading.
      Throws:
      ConverterException
    • getReaderForNamespace

      public static GPMLFormatReader getReaderForNamespace​(org.jdom2.Namespace ns)
      Returns GPML reader given namespace.
      Parameters:
      ns - the given namespace.
      Returns:
      the correct GPML reader for the given namespace.
    • readFromXmlImpl

      private static void readFromXmlImpl​(PathwayModel pathwayModel, org.xml.sax.InputSource is, boolean validate) throws ConverterException
      Reads a pathway model from given input source.
      Parameters:
      pathwayModel - the pathway model.
      is - the file from which the JDOM document should be read.
      validate - if true, validate the dom structure during/after reading.
      Throws:
      ConverterException
    • isCorrectType

      public boolean isCorrectType​(java.io.File f)
      Returns true if file type is correct.
      Specified by:
      isCorrectType in interface PathwayModelImporter
      Overrides:
      isCorrectType in class AbstractPathwayModelFormat
      Parameters:
      f - the file.
      Returns:
      true if file type correct.
    • doExport

      public void doExport​(java.io.File file, PathwayModel pathwayModel, int zoom) throws ConverterException
      Description copied from interface: PathwayModelExporter
      Exports the given pathway to the file
      Parameters:
      file - the file to export to
      pathwayModel - the pathway model to export
      zoom - the zoom factor.
      Throws:
      ConverterException - when there is a fatal conversion problem. Implementations should only throw in case there is a non-recoverable error. Otherwise, it should emit a warning.