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 GPML2013aWriterGPML2013astatic GPML2021WriterGPML2021private GPMLFormatWriterwriter -
Constructor Summary
Constructors Constructor Description GPMLFormat(GPMLFormatWriter writer)Instantiates a GpmlFormat. -
Method Summary
Modifier and Type Method Description org.jdom2.DocumentcreateJdom(PathwayModel data)voiddoExport(java.io.File file, PathwayModel pathwayModel)Exports the given pathway to the filevoiddoExport(java.io.File file, PathwayModel pathwayModel, int zoom)Exports the given pathway to the filePathwayModeldoImport(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.StringgetName()static GPMLFormatReadergetReaderForNamespace(org.jdom2.Namespace ns)Returns GPML reader given namespace.booleanisCorrectType(java.io.File f)Returns true if file type is correct.static voidreadFromXml(PathwayModel pathwayModel, java.io.File file, boolean validate)Reads the JDOM document from the file specifiedstatic voidreadFromXml(PathwayModel pathwayModel, java.io.InputStream in, boolean validate)Reads the JDOM document from the string specifiedstatic voidreadFromXml(PathwayModel pathwayModel, java.io.Reader in, boolean validate)Reads the JDOM document from the string specifiedprivate static voidreadFromXmlImpl(PathwayModel pathwayModel, org.xml.sax.InputSource is, boolean validate)Reads a pathway model from given input source.voidwriteToXml(PathwayModel pathwayModel, java.io.File file, boolean validate)Writes the JDOM document to the file specifiedvoidwriteToXml(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, getWarningsMethods 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:PathwayModelImporterImports 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:PathwayModelExporterExports 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:PathwayModelIOGet 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:
isCorrectTypein interfacePathwayModelImporter- Overrides:
isCorrectTypein 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:PathwayModelExporterExports 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.
-