/** * Create an instance of {@link FormatType } * */ public FormatType createFormatType() { return new FormatType(); }
public void printFormats() { conversionProvider.getFormat().getDestContexts().getMap().values().stream() .sorted(Comparator.comparing(DestContextTypeMap::getName)) .forEachOrdered(this::printFormat); }
/** * Gets a Format Configuration instance corresponding to the given format configuration name. * * @param configuration a format configuration name. * @return a format configuration instance. */ public FormatConfigurationType getFormatConfigurationType(String configuration) { FormatConfigurationType formatConfigurationType = formatType.getFormatConfigurations().getMap().get(configuration); if (formatConfigurationType == null) { throw new ConversionException(String.format("No configuration '%s' found for format '%s'.", configuration, formatType.getName())); } return formatConfigurationType; }
private void executeMediaInfoCommand(SequenceType seqType, String essence, File outputFile) throws IOException { MediaInfoCommandType mediaInfoCommand; switch (seqType) { case VIDEO: mediaInfoCommand = format.getMediaInfoCommandVideo(); break; case AUDIO: mediaInfoCommand = format.getMediaInfoCommandAudio(); break; case SUBTITLE: mediaInfoCommand = format.getMediaInfoCommandSubtitle(); break; default: throw new ConversionException(String.format("Can not get media info. Unknown sequence type '%s'", seqType.toString())); } String operationName = String.format("%s_%s", mediaInfoCommand.getClass().getSimpleName(), new File(essence).getName()); OperationInfo operationInfo = new OperationInfo( mediaInfoCommand.getValue(), operationName, ContextInfo.EMPTY, false, outputFile); executeStrategyFactory.createExecuteOnceStrategy(contextProvider).execute(operationInfo); }
private void selectDestContext() { DestContextTypeMap destContext = getDestContextMap(conversionProvider.getFormat().getDestContexts()); this.destContextMap = conversionProvider.getFormat().getDefaultDestContext(); if (destContext != null) { // merge with default this.destContextMap.getMap().putAll(destContext.getMap()); this.destContextMap.setName(destContext.getName()); } }
/** * Returns a list of all conversion configuration for the given format ({@link #getFormat()}). * * @return a list of all conversion configuration for the given format ({@link #getFormat()}). */ public List<String> getConvertConfiguration() { if (formatType == null) { return Collections.emptyList(); } return new ArrayList<>(formatType.getFormatConfigurations().getMap().keySet()); }
/** * Gets all template parameter values as a string. * * @return Gets all template parameter values as a string */ public Collection<String> getAllParametersAsString() { return format.getTmpContext().getMap().values().stream() .map(TmpParamType::getValue) .collect(Collectors.toList()); }
@Override public FormatTypesMap<String, FormatType> unmarshal(FormatTypes formatTypes) throws Exception { FormatTypesMap<String, FormatType> map = new FormatTypesMap<>(); for (FormatType ft : formatTypes.getFormat()) { map.getMap().put(ft.getName(), ft); } return map; }
private MediaInfoCommandType getMediaInfoCommand() throws MediaInfoException { MediaInfoCommandOthersTypeMap commandsMap = contextProvider.getConversionProvider() .getFormat() .getMediaInfoCommandOthers(); checkMediaInfoCommand(commandsMap, commandName); return commandsMap.getMap().get(commandName); }
@Test public void testParseCorrectConversion() throws Exception { ConversionXmlProvider conversionProvider = new ConversionXmlProvider(ConversionUtils.getCorrectConversionXml(), ConversionUtils.getCorrectConversionXmlPath(), new FakeFormat()); assertNotNull(conversionProvider.getFormat()); assertNotNull(conversionProvider.getFormat().getFormatConfigurations()); assertFalse(conversionProvider.getFormat().getFormatConfigurations().getMap().isEmpty()); }
/** * Gets all parameter value instances with additional information besides parameter value string. * * @return gets all parameter value instances with additional information besides parameter value string. */ public Collection<CustomParameterValue> getAllParameters() { return format.getTmpContext().getMap().values().stream() .map((TmpParamType param) -> new CustomParameterValue(param.getValue(), param.isDeleteOnExit())) .collect(Collectors.toList()); }
/** * Create an instance of {@link FormatType } * */ public FormatType createFormatType() { return new FormatType(); }
/** * Gets the parameter value as {@link CustomParameterValue} instance. * The returned parameter value contains additional information about the parameter, such as whether it should be deleted on exit. * * @param templateParameter a enum defining the parameter name * @return a parameter value instance with additional information besides parameter value string. */ public CustomParameterValue getParameterValue(TemplateParameter templateParameter) { if (format.getTmpContext() == null) { throw new TemplateParameterNotFoundException( templateParameter.toString(), "Conversion.xml doesn't contain any tmp context parameters."); } TmpParamType param = format.getTmpContext().getMap().get(templateParameter.getName()); if (param == null) { throw new TemplateParameterNotFoundException( templateParameter.toString(), "Conversion.xml doesn't contain '%s' tmp parameter."); } String paramValue = param.getValue(); if (StringUtils.isEmpty(paramValue)) { throw new TemplateParameterNotFoundException( templateParameter.toString(), "Conversion.xml contains an empty '%s' tmp parameter value."); } paramValue = paramValue.trim(); if (StringUtils.isEmpty(paramValue)) { throw new TemplateParameterNotFoundException( templateParameter.toString(), "Conversion.xml contains an empty '%s' tmp parameter value."); } return new CustomParameterValue(paramValue, param.isDeleteOnExit()); }