Search in sources :

Example 1 with SoftInfo

use of org.fagu.fmv.soft.find.SoftInfo in project fmv by f-agu.

the class IMSoftProvider method createSoftExecutor.

/**
 * @see org.fagu.fmv.soft.find.SoftProvider#createSoftExecutor(org.fagu.fmv.soft.Soft, java.io.File, java.util.List)
 */
@Override
public SoftExecutor createSoftExecutor(Soft soft, File execFile, List<String> parameters) {
    if (SOFT_MAGICK_NAME.equalsIgnoreCase(FilenameUtils.getBaseName(soft.getFile().getName()))) {
        SoftInfo softInfo = soft.getFirstInfo();
        if (softInfo instanceof VersionSoftInfo) {
            VersionSoftInfo versionSoftInfo = (VersionSoftInfo) softInfo;
            Optional<Version> version = versionSoftInfo.getVersion();
            if (version.isPresent() && version.get().isUpperOrEqualsThan(V7)) {
                List<String> newParams = new ArrayList<>(parameters);
                newParams.add(0, getName());
                return new SoftExecutor(this, execFile, newParams);
            }
        }
    }
    return super.createSoftExecutor(soft, execFile, parameters);
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) VersionSoftPolicy.minVersion(org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion) Version(org.fagu.version.Version) ArrayList(java.util.ArrayList) SoftExecutor(org.fagu.fmv.soft.SoftExecutor)

Example 2 with SoftInfo

use of org.fagu.fmv.soft.find.SoftInfo in project fmv by f-agu.

the class SoftInfoContributor method content.

// *********************************************
/**
 * @return
 */
private Map<String, String> content() {
    Map<String, String> map = new HashMap<>();
    for (Soft soft : Softs.getInfoContributors()) {
        String msg = null;
        if (soft.isFound()) {
            StringBuilder buf = new StringBuilder(100);
            SoftInfo softInfo = soft.getFirstInfo();
            if (softInfo instanceof VersionSoftInfo) {
                ((VersionSoftInfo) softInfo).getVersion().ifPresent(v -> buf.append(v).append(", "));
            }
            if (softInfo instanceof VersionDateSoftInfo) {
                ((VersionDateSoftInfo) softInfo).getDate().ifPresent(d -> {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    buf.append(dateFormat.format(d)).append(", ");
                });
            }
            buf.append(soft.getFile().getAbsolutePath());
            msg = buf.toString();
        } else {
            StringJoiner joiner = new StringJoiner(" ; ");
            for (SoftFound softFound : soft.getFounds()) {
                StringBuilder buf = new StringBuilder();
                FoundReason foundReason = softFound != null ? softFound.getFoundReason() : FoundReasons.NOT_FOUND;
                buf.append(foundReason.name());
                String reason = softFound.getReason();
                if (reason != null) {
                    buf.append(": ").append(reason);
                }
                joiner.add(buf.toString());
            }
            msg = joiner.toString();
        }
        map.put(soft.getName(), msg);
    }
    return map;
}
Also used : VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo) VersionSoftInfo(org.fagu.fmv.soft.find.info.VersionSoftInfo) FoundReason(org.fagu.fmv.soft.find.FoundReason) HashMap(java.util.HashMap) SoftFound(org.fagu.fmv.soft.find.SoftFound) VersionDateSoftInfo(org.fagu.fmv.soft.find.info.VersionDateSoftInfo) Soft(org.fagu.fmv.soft.Soft) SimpleDateFormat(java.text.SimpleDateFormat) StringJoiner(java.util.StringJoiner)

Example 3 with SoftInfo

use of org.fagu.fmv.soft.find.SoftInfo in project fmv by f-agu.

the class Soft method toString.

/**
 * @return
 */
@Override
public String toString() {
    StringBuilder buf = new StringBuilder();
    buf.append(getName());
    if (getFounds().isFound()) {
        SoftInfo softInfo = getFirstInfo();
        if (softInfo != null) {
            String info = softInfo.getInfo();
            if (StringUtils.isNotBlank(info)) {
                buf.append(' ').append(info);
            }
        }
        buf.append(" (").append(getFile().getAbsolutePath()).append(')');
    } else {
        buf.append(" <not found>");
    }
    return buf.toString();
}
Also used : SoftInfo(org.fagu.fmv.soft.find.SoftInfo)

Example 4 with SoftInfo

use of org.fagu.fmv.soft.find.SoftInfo in project fmv by f-agu.

the class PdfSoftProvider method getDefaultSoftPolicy.

// ***********************************************************************
/**
 * @return
 */
private static SoftPolicy getDefaultSoftPolicy() {
    Version v012 = new Version(0, 12);
    BiPredicate<SoftInfo, Provider> isProvider = (s, p) -> s instanceof XPdfVersionSoftInfo && ((XPdfVersionSoftInfo) s).getProvider() == p;
    return new VersionSoftPolicy().on("xpdf", s -> isProvider.test(s, Provider.XPDF), minVersion(Version.V3)).on("poppler", s -> isProvider.test(s, Provider.POPPLER), minVersion(v012)).onAllPlatforms(minVersion(v012));
}
Also used : Arrays(java.util.Arrays) VersionParserManager(org.fagu.version.VersionParserManager) SoftFound(org.fagu.fmv.soft.find.SoftFound) ProgramFilesLocatorSupplier(org.fagu.fmv.soft.win32.ProgramFilesLocatorSupplier) ArrayList(java.util.ArrayList) SoftProvider(org.fagu.fmv.soft.find.SoftProvider) BiPredicate(java.util.function.BiPredicate) Matcher(java.util.regex.Matcher) VersionSoftPolicy(org.fagu.fmv.soft.find.policy.VersionSoftPolicy) ObjectUtils(org.apache.commons.lang3.ObjectUtils) ExceptionKnownAnalyzer(org.fagu.fmv.soft.exec.exception.ExceptionKnownAnalyzer) XpdfExceptionKnownAnalyzer(org.fagu.fmv.soft.xpdf.exception.XpdfExceptionKnownAnalyzer) Soft(org.fagu.fmv.soft.Soft) SoftFoundFactory(org.fagu.fmv.soft.find.SoftFoundFactory) SoftLocator(org.fagu.fmv.soft.find.SoftLocator) SoftPolicy(org.fagu.fmv.soft.find.SoftPolicy) SystemUtils(org.apache.commons.lang3.SystemUtils) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) VersionSoftPolicy.minVersion(org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion) List(java.util.List) Parser(org.fagu.fmv.soft.find.ExecSoftFoundFactory.Parser) Pattern(java.util.regex.Pattern) Version(org.fagu.version.Version) Collections(java.util.Collections) SoftExecutor(org.fagu.fmv.soft.SoftExecutor) SoftInfo(org.fagu.fmv.soft.find.SoftInfo) VersionSoftPolicy(org.fagu.fmv.soft.find.policy.VersionSoftPolicy) VersionSoftPolicy.minVersion(org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion) Version(org.fagu.version.Version) SoftProvider(org.fagu.fmv.soft.find.SoftProvider)

Aggregations

SoftInfo (org.fagu.fmv.soft.find.SoftInfo)4 ArrayList (java.util.ArrayList)2 Soft (org.fagu.fmv.soft.Soft)2 SoftExecutor (org.fagu.fmv.soft.SoftExecutor)2 SoftFound (org.fagu.fmv.soft.find.SoftFound)2 VersionSoftInfo (org.fagu.fmv.soft.find.info.VersionSoftInfo)2 VersionSoftPolicy.minVersion (org.fagu.fmv.soft.find.policy.VersionSoftPolicy.minVersion)2 Version (org.fagu.version.Version)2 File (java.io.File)1 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 StringJoiner (java.util.StringJoiner)1 BiPredicate (java.util.function.BiPredicate)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1