Skip to content

Commit

Permalink
Merge pull request #215 from Mailaender/unrelated-animl
Browse files Browse the repository at this point in the history
Fixed AnIML converter reading unrelated files and crashing
  • Loading branch information
eselmeister authored Feb 25, 2022
2 parents 9c0d6ba + cb161a9 commit 1c87689
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class ChromatogramMagicNumberMatcher extends AbstractMagicNumberMatcher i
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
if(file.isDirectory() || !checkFileExtension(file, ".animl")) {
return isValidFormat;
}
try {
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public class MassSpectrumMagicNumberMatcher extends AbstractMagicNumberMatcher i
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
if(file.isDirectory() || !checkFileExtension(file, ".animl")) {
return isValidFormat;
}
try {
if(!checkFileExtension(file, ".animl")) {
return isValidFormat;
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class ChromatogramReader extends AbstractChromatogramMSDReader {
@Override
public IChromatogramMSD read(File file, IProgressMonitor monitor) throws IOException {

if(file.isDirectory() || !file.getName().endsWith(".animl")) {
return null;
}
IVendorChromatogram chromatogram = null;
try {
AnIMLType animl = XmlReader.getAnIML(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class MassSpectrumReader extends AbstractMassSpectraReader implements IMa
@Override
public IMassSpectra read(File file, IProgressMonitor monitor) throws IOException {

if(file.isDirectory() || !file.getName().endsWith(".animl")) {
return null;
}
IVendorStandaloneMassSpectrum massSpectrum = null;
//
try {
Expand Down

0 comments on commit 1c87689

Please sign in to comment.