Skip to content

Commit

Permalink
Bail out early with a simple file ending check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Jul 2, 2021
1 parent 7dea2b8 commit 9bf76cf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Lablicate GmbH.
* Copyright (c) 2016, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -15,17 +15,12 @@

import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher;
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher;
import org.eclipse.chemclipse.msd.converter.supplier.amdis.internal.converter.SpecificationValidatorMSL;

public class MagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher {

@Override
public boolean checkFileFormat(File file) {

file = SpecificationValidatorMSL.validateSpecification(file);
if(file.exists()) {
return true;
}
return false;
return checkFileExtension(file, ".MSL");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Lablicate GmbH.
* Copyright (c) 2016, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -15,17 +15,12 @@

import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher;
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher;
import org.eclipse.chemclipse.msd.converter.supplier.amdis.internal.converter.SpecificationValidatorMSP;

public class MagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher {

@Override
public boolean checkFileFormat(File file) {

file = SpecificationValidatorMSP.validateSpecification(file);
if(file.exists()) {
return true;
}
return false;
return checkFileExtension(file, ".MSP");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Lablicate GmbH.
* Copyright (c) 2016, 2021 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -15,22 +15,12 @@

import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher;
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher;
import org.eclipse.chemclipse.msd.converter.supplier.excel.internal.converter.SpecificationValidator;

public class MagicNumberMatcher extends AbstractMagicNumberMatcher implements IMagicNumberMatcher {

@Override
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
try {
file = SpecificationValidator.validateSpecification(file);
if(file.exists()) {
isValidFormat = true;
}
} catch(Exception e) {
// Print no exception.
}
return isValidFormat;
return checkFileExtension(file, ".XLSX");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Lablicate GmbH.
* Copyright (c) 2016, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -15,27 +15,12 @@

import org.eclipse.chemclipse.converter.core.AbstractMagicNumberMatcher;
import org.eclipse.chemclipse.converter.core.IMagicNumberMatcher;
import org.eclipse.chemclipse.xxd.converter.supplier.jcampdx.internal.converter.SpecificationValidator;

public class MagicNumberMatcherChromatogram extends AbstractMagicNumberMatcher implements IMagicNumberMatcher {

@Override
public boolean checkFileFormat(File file) {

boolean isValidFormat = false;
try {
file = SpecificationValidator.validateSpecification(file, "JDX");
if(file.exists()) {
return true;
} else {
file = SpecificationValidator.validateSpecification(file, "JDL");
if(file.exists()) {
return true;
}
}
} catch(Exception e) {
// Print no exception.
}
return isValidFormat;
return checkFileExtension(file, ".JDX") || checkFileExtension(file, ".JDL");
}
}

0 comments on commit 9bf76cf

Please sign in to comment.