Skip to content

Commit

Permalink
Merge pull request #675 from Mailaender/extension-only
Browse files Browse the repository at this point in the history
Speedup the .msl .msp .xlsx .jdx .jdl detection
  • Loading branch information
eselmeister authored Jul 2, 2021
2 parents 1f0d272 + 9bf76cf commit acda040
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 acda040

Please sign in to comment.