Package org.pathvisio.libgpml.model
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:
- Static read methods, both current and previous gpml formats can be read.
- Pathways are saved/written in the current gpml format.
- Export allows writing to the previous gpml format.
- Author:
- unknown, finterly
-
Field Summary
Fields Modifier and Type Field Description static GPML2013aWriter
GPML2013a
static GPML2021Writer
GPML2021
private GPMLFormatWriter
writer
-
Constructor Summary
Constructors Constructor Description GPMLFormat(GPMLFormatWriter writer)
Instantiates a GpmlFormat. -
Method Summary
Modifier and Type Method Description org.jdom2.Document
createJdom(PathwayModel data)
void
doExport(java.io.File file, PathwayModel pathwayModel)
Exports the given pathway to the filevoid
doExport(java.io.File file, PathwayModel pathwayModel, int zoom)
Exports the given pathway to the filePathwayModel
doImport(java.io.File file)
Imports the pathway model from given file.java.lang.String[]
getExtensions()
Get the possible extensions this importer/exporter can read (e.g.java.lang.String
getName()
static GPMLFormatReader
getReaderForNamespace(org.jdom2.Namespace ns)
Returns GPML reader given namespace.boolean
isCorrectType(java.io.File f)
Returns true if file type is correct.static void
readFromXml(PathwayModel pathwayModel, java.io.File file, boolean validate)
Reads the JDOM document from the file specifiedstatic void
readFromXml(PathwayModel pathwayModel, java.io.InputStream in, boolean validate)
Reads the JDOM document from the string specifiedstatic void
readFromXml(PathwayModel pathwayModel, java.io.Reader in, boolean validate)
Reads the JDOM document from the string specifiedprivate static void
readFromXmlImpl(PathwayModel pathwayModel, org.xml.sax.InputSource is, boolean validate)
Reads a pathway model from given input source.void
writeToXml(PathwayModel pathwayModel, java.io.File file, boolean validate)
Writes the JDOM document to the file specifiedvoid
writeToXml(PathwayModel pathwayModel, java.io.OutputStream out, boolean validate)
Writes the pathway model to output stream.Methods inherited from class org.pathvisio.libgpml.io.AbstractPathwayModelFormat
clearWarnings, emitWarning, getWarnings
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
GPML2021
-
GPML2013a
-
writer
-
-
Constructor Details
-
GPMLFormat
Instantiates a GpmlFormat.- Parameters:
writer
-
-
-
Method Details
-
doImport
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
Description copied from interface:PathwayModelExporter
Exports the given pathway to the file- Parameters:
file
- the file to export topathwayModel
- 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
- Parameters:
data
-- Returns:
- Throws:
ConverterException
-
writeToXml
public void writeToXml(PathwayModel pathwayModel, java.io.File file, boolean validate) throws ConverterExceptionWrites the JDOM document to the file specified- Parameters:
pathwayModel
- the pathway model.file
- the file to which the JDOM document should be savedvalidate
- 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 ConverterExceptionWrites the pathway model to output stream.- Parameters:
pathwayModel
- the pathway model.out
- the file to which the JDOM document should be savedvalidate
- 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 ConverterExceptionReads 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 ConverterExceptionReads 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 ConverterExceptionReads 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
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 ConverterExceptionReads 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 interfacePathwayModelImporter
- Overrides:
isCorrectType
in classAbstractPathwayModelFormat
- Parameters:
f
- the file.- Returns:
- true if file type correct.
-
doExport
public void doExport(java.io.File file, PathwayModel pathwayModel, int zoom) throws ConverterExceptionDescription copied from interface:PathwayModelExporter
Exports the given pathway to the file- Parameters:
file
- the file to export topathwayModel
- the pathway model to exportzoom
- 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.
-