public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items)
            throws BackgroundException {
        final Transfer transfer;
        final TerminalAction type = TerminalActionFinder.get(input);
        if(null == type) {
            throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type");
        }
        switch(type) {
            case download:
                if(StringUtils.containsAny(remote.getName(), '*')) {
                    transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName()));
                }
                else {
                    transfer = new DownloadTransfer(host, items);
                }
                if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) {
                    final DownloadFilterOptions options = new DownloadFilterOptions(host);
                    options.checksum = Boolean.parseBoolean(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name()));
                    ((DownloadTransfer) transfer).withOptions(options);
                }
                break;
            case upload:
                transfer = new UploadTransfer(host, items);
                if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) {
                    final UploadFilterOptions options = new UploadFilterOptions(host);
                    options.checksum = Boolean.parseBoolean(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name()));
                    ((UploadTransfer) transfer).withOptions(options);
                }
                break;
            case synchronize:
                transfer = new SyncTransfer(host, items.iterator().next());
                break;
            default:
                throw new BackgroundException(LocaleFactory.localizedString("Unknown"),
                        String.format("Unknown transfer type %s", type.name()));
        }
        if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) {
            try {
                transfer.setBandwidth(Float.parseFloat(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name())));
            }
            catch(NumberFormatException ignore) {
                //
            }
        }
        return transfer;
    }
@Test
    public void testFilter() throws Exception {
        final CommandLineParser parser = new PosixParser();

        final Transfer transfer = new TerminalTransferFactory().create(parser.parse(TerminalOptionsBuilder.options(), new String[]{"--download", "rackspace://cdn.cyberduck.ch/remote/*.css"}),
                new Host(new SwiftProtocol()), new Path("/remote/*.css", EnumSet.of(Path.Type.directory)), Collections.<TransferItem>emptyList());
        assertEquals(Transfer.Type.download, transfer.getType());
        final PathCache cache = new PathCache(1);
        transfer.withCache(cache);
        cache.clear();
        cache.put(new Path("/remote", EnumSet.of(Path.Type.directory)), new AttributedList<Path>(Collections.singletonList(new Path("/remote/file.css", EnumSet.of(Path.Type.file)))));
        assertFalse(transfer.list(null, new Path("/remote", EnumSet.of(Path.Type.directory)), new Local("/tmp"), new DisabledListProgressListener()).isEmpty());
        cache.clear();
        cache.put(new Path("/remote", EnumSet.of(Path.Type.directory)), new AttributedList<Path>(Collections.singletonList(new Path("/remote/file.png", EnumSet.of(Path.Type.file)))));
        assertTrue(transfer.list(null, new Path("/remote", EnumSet.of(Path.Type.directory)), new Local("/tmp"), new DisabledListProgressListener()).isEmpty());
    }